diff --git a/src/Phpml/Math/Distance/Euclidean.php b/src/Phpml/Math/Distance/Euclidean.php index ceaf510f..ad60e871 100644 --- a/src/Phpml/Math/Distance/Euclidean.php +++ b/src/Phpml/Math/Distance/Euclidean.php @@ -24,10 +24,9 @@ public function distance(array $a, array $b): float } $distance = 0; - $count = count($a); - for ($i = 0; $i < $count; ++$i) { - $distance += pow($a[$i] - $b[$i], 2); + foreach ($a as $i => $val) { + $distance += ($val - $b[$i]) ** 2; } return sqrt((float) $distance);