Skip to content

Commit

Permalink
Add comment about the non-zero weights correction
Browse files Browse the repository at this point in the history
Signed-off-by: Nahuel Espinosa <[email protected]>
  • Loading branch information
nahueespinosa committed Oct 15, 2024
1 parent c587bad commit ab0c5d1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions beluga/include/beluga/algorithm/estimation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ struct covariance_fn {
assert(weights_it == ranges::end(normalized_weights));
assert(non_zero_weight_count > 1);

// Apply Bessel's correction for weighted statistical variance.
// See https://en.wikipedia.org/wiki/Bessel%27s_correction and
// https://www.itl.nist.gov/div898/software/dataplot/refman2/ch2/weighvar.pdf.
accumulator *= non_zero_weight_count / (non_zero_weight_count - 1);
return accumulator;
}
Expand Down

0 comments on commit ab0c5d1

Please sign in to comment.