Calculates NN distance and density estimates for each timestep