From 1063c4e9408a0555c885e8b52f5eb4e3ab582469 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Tue, 22 Sep 2020 17:44:28 -0500 Subject: [PATCH] MathUtil: Add Population (vs Sample) versions of Variance and StandardDeviation to RunningVariance. --- Source/Core/Common/MathUtil.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/Core/Common/MathUtil.h b/Source/Core/Common/MathUtil.h index c616b3d74d..5ad9ee0dcd 100644 --- a/Source/Core/Common/MathUtil.h +++ b/Source/Core/Common/MathUtil.h @@ -135,8 +135,12 @@ public: constexpr size_t Count() const { return m_running_mean.Count(); } constexpr T Mean() const { return m_running_mean.Mean(); } + constexpr T Variance() const { return m_variance / (Count() - 1); } - constexpr T StandardDeviation() const { return std::sqrt(Variance()); } + T StandardDeviation() const { return std::sqrt(Variance()); } + + constexpr T PopulationVariance() const { return m_variance / Count(); } + T PopulationStandardDeviation() const { return std::sqrt(PopulationVariance()); } private: RunningMean m_running_mean;