Skip to content

Commit acbd0b2

Browse files
authored
Merge pull request #43 from SWIFTSIM/make_bin_centre_eq_to_medians
Compute bin centers as medians of the data points
2 parents 4d4d33c + c063d9a commit acbd0b2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

velociraptor/tools/lines.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ def binned_mean_line(
9999
means.append(np.mean(y_values_in_this_bin))
100100
standard_deviations.append(np.std(y_values_in_this_bin))
101101

102-
centers.append(0.5 * (x_bins[bin - 1].value + x_bins[bin].value))
102+
# Bin center is computed as the median of the X values of the data points
103+
# in the bin
104+
centers.append(np.median(x[indicies_in_this_bin].value))
103105

104106
# If the number of data points in the bin is less than minimum_in_bin,
105107
# collect these data points if needed
@@ -224,7 +226,9 @@ def binned_median_line(
224226
medians.append(np.median(y_values_in_this_bin))
225227
deviations.append(np.percentile(y_values_in_this_bin, percentiles))
226228

227-
centers.append(0.5 * (x_bins[bin - 1].value + x_bins[bin].value))
229+
# Bin center is computed as the median of the X values of the data points
230+
# in the bin
231+
centers.append(np.median(x[indicies_in_this_bin].value))
228232

229233
# If the number of data points in the bin is less than minimum_in_bin,
230234
# collect these data points if needed

0 commit comments

Comments
 (0)