From afe7224dc663e56674fbccd8fb7e76fdb203530b Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 19 Apr 2022 14:20:34 +0200 Subject: [PATCH] fix: counting states --- Exercise_02/task04.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Exercise_02/task04.py b/Exercise_02/task04.py index 1399c31..55e5471 100644 --- a/Exercise_02/task04.py +++ b/Exercise_02/task04.py @@ -74,10 +74,13 @@ lower_tri = np.tril_indices(position.shape[0], k = -1) max_dist = box_size / 2.0 # second iteration to estimate pairwise distance CDF +nr_time_points = 0 for i, ((position, velocity), box_size) in enumerate(iter_load(config.input)): # ignore the first 25% (just keep it simple) if 4 * i < nr_states: continue + # Count number of actually considured states / time points + nr_time_points += 1 # magic for all particle pair distances diff = position[:, np.newaxis, :] - position diff = diff[lower_tri[0], lower_tri[1], :] @@ -90,7 +93,7 @@ for i, ((position, velocity), box_size) in enumerate(iter_load(config.input)): # accumulate per timepoint partial mean estimates of the CDF CDF += np.mean(dist[:, np.newaxis] < radii, axis = 0) # final division by timesteps as mean over pairs and time. -CDF /= nr_states +CDF /= nr_time_points # store the CDF estimate to the second file with open(config.outputB, "w") as output: