23 VarType total = 0, total_count = 0;
29 total += (*m_counts)[i] * center;
30 total_count += (*m_counts)[i];
31 sigma += (*m_counts)[i] * center * center;
34 VarType mean = total / total_count;
35 sigma = sigma / total_count - mean * mean;
42 WeightType low_sum = 0., high_sum = 0.;
44 while (low_i <= high_i) {
45 if (low_sum < high_sum) {
46 low_sum += (*m_counts)[low_i++];
48 high_sum += (*m_counts)[high_i--];
52 assert(low_sum + high_sum == total_count);
56 auto edges =
m_binning.getBinEdges(high_i + 1);
57 auto bin_width = (edges.second - edges.first);
59 median = edges.first + bin_width * (high_sum - low_sum) / (2.0 * max_counts);