tweak comment wording

This commit is contained in:
Dominic Hamon 2023-08-25 09:58:30 +01:00
parent 9f254bddf0
commit 78220d6f0d
1 changed files with 3 additions and 2 deletions

View File

@ -44,8 +44,9 @@ double StatisticsMedian(const std::vector<double>& v) {
// Did we have an odd number of samples? If yes, then center is the median.
// If not, then we are looking for the average between center and the value
// before. Instead of resorting, we just look for the max value before it.
// (Since `copy` is partially sorted.)
// before. Instead of resorting, we just look for the max value before it,
// which is not necessarily the element immediately preceding `center` Since
// `copy` is only partially sorted by `nth_element`.
if (v.size() % 2 == 1) return *center;
auto center2 = std::max_element(copy.begin(), center);
return (*center + *center2) / 2.0;