From 03208332ae186460a5f4a2e2a7464dd886e6d738 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Fri, 23 Feb 2018 17:55:17 +0100 Subject: [PATCH] Fix error bugs --- Math/Functions/Functions.php | 4 ++-- Math/Statistic/Forecast/Error.php | 4 ++-- tests/Math/Functions/FunctionsTest.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Math/Functions/Functions.php b/Math/Functions/Functions.php index 82d9ff418..79ca16a8a 100644 --- a/Math/Functions/Functions.php +++ b/Math/Functions/Functions.php @@ -258,7 +258,7 @@ class Functions $squared = []; foreach ($values as $value) { - $squared[] = $value * $exp; + $squared[] = $value ** $exp; } return $squared; @@ -280,7 +280,7 @@ class Functions $squared = []; foreach ($values as $value) { - $squared[] = $value * $exp; + $squared[] = $value ** $exp; } return $squared; diff --git a/Math/Statistic/Forecast/Error.php b/Math/Statistic/Forecast/Error.php index 74afcc5ab..e8c0ff10b 100644 --- a/Math/Statistic/Forecast/Error.php +++ b/Math/Statistic/Forecast/Error.php @@ -111,7 +111,7 @@ class Error */ public static function getMeanAbsoulteError(array $errors) : float { - return Average::arithmeticMean(Functions::abs($errors)); + return MeasureOfDispersion::meanAbsoluteDeviation($errors); } /** @@ -125,7 +125,7 @@ class Error */ public static function getMeanSquaredError(array $errors) : float { - return Average::arithmeticMean(Functions::powerInt($errors, 2)); + return MeasureOfDispersion::squaredMeanDeviation($errors); } /** diff --git a/tests/Math/Functions/FunctionsTest.php b/tests/Math/Functions/FunctionsTest.php index 7dc9e2aed..9fa493b10 100644 --- a/tests/Math/Functions/FunctionsTest.php +++ b/tests/Math/Functions/FunctionsTest.php @@ -74,7 +74,7 @@ class FunctionsTest extends \PHPUnit\Framework\TestCase self::assertEquals([4, 9, 16], Functions::powerInt([2, 3, 4], 2)); self::assertEquals([8, 27, 64], Functions::powerInt([2, 3, 4], 3)); - self::assertEquals([2, 3, 8], Functions::powerFloat([4, 9, 16], 1/2), '', 0.0); - self::assertEquals([2, 3, 8], Functions::powerFloat([8, 27, 64], 1/3), '', 0.0); + self::assertEquals([2.0, 3.0, 4.0], Functions::powerFloat([4, 9, 16], 1/2), '', 0.0); + self::assertEquals([2.0, 3.0, 4.0], Functions::powerFloat([8, 27, 64], 1/3), '', 0.0); } }