From ab0c5d1876ae49cac99eded3ca885ba5d0b8c556 Mon Sep 17 00:00:00 2001 From: Nahuel Espinosa Date: Tue, 15 Oct 2024 08:47:03 -0300 Subject: [PATCH] Add comment about the non-zero weights correction Signed-off-by: Nahuel Espinosa --- beluga/include/beluga/algorithm/estimation.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/beluga/include/beluga/algorithm/estimation.hpp b/beluga/include/beluga/algorithm/estimation.hpp index 2024ddbe9..d83a4b851 100644 --- a/beluga/include/beluga/algorithm/estimation.hpp +++ b/beluga/include/beluga/algorithm/estimation.hpp @@ -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; }