mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2024-11-05 04:57:52 +00:00
Euclidean optimization (#42)
* Euclidean optimization * Euclidean with foreach
This commit is contained in:
parent
1d73503958
commit
0a58a71d77
@ -24,10 +24,9 @@ class Euclidean implements Distance
|
||||
}
|
||||
|
||||
$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);
|
||||
|
Loading…
Reference in New Issue
Block a user