diff --git a/src/Phpml/Math/Statistic/Correlation.php b/src/Phpml/Math/Statistic/Correlation.php index a6047a8..1d2e8ac 100644 --- a/src/Phpml/Math/Statistic/Correlation.php +++ b/src/Phpml/Math/Statistic/Correlation.php @@ -23,8 +23,8 @@ class Correlation } $count = count($x); - $meanX = array_sum($x) / $count; - $meanY = array_sum($y) / $count; + $meanX = Mean::arithmetic($x); + $meanY = Mean::arithmetic($y); $axb = 0; $a2 = 0; diff --git a/src/Phpml/Math/Statistic/StandardDeviation.php b/src/Phpml/Math/Statistic/StandardDeviation.php index a05faa4..2b03c54 100644 --- a/src/Phpml/Math/Statistic/StandardDeviation.php +++ b/src/Phpml/Math/Statistic/StandardDeviation.php @@ -28,7 +28,7 @@ class StandardDeviation throw InvalidArgumentException::arraySizeToSmall(2); } - $mean = array_sum($a) / $n; + $mean = Mean::arithmetic($a); $carry = 0.0; foreach ($a as $val) { $d = $val - $mean;