From 2c83a519b8474c95a496b603ff548846877d7d12 Mon Sep 17 00:00:00 2001 From: Jon Smit Date: Tue, 28 Jun 2016 16:37:12 +0200 Subject: [PATCH] Statistics: Fixed incorrect formula in WeightedPearson that could cause the correlation to be greater than 1. --- src/Numerics/Statistics/Correlation.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Numerics/Statistics/Correlation.cs b/src/Numerics/Statistics/Correlation.cs index e2646a2b..fb096fa7 100644 --- a/src/Numerics/Statistics/Correlation.cs +++ b/src/Numerics/Statistics/Correlation.cs @@ -146,9 +146,8 @@ namespace MathNet.Numerics.Statistics meanB += rY; varB += sumWeight*deltaY*rY; + covariance += deltaX*deltaY*wi*(sumWeight/temp); sumWeight = temp; - - covariance += deltaX*deltaY*(n - 1)*wi/n; } if (ieB.MoveNext()) {