impl. standard epsilon value

This commit is contained in:
Dennis Eichhorn 2022-03-11 23:16:16 +01:00
parent a7fc3812ae
commit 1d583a03ea

View File

@ -24,6 +24,14 @@ namespace phpOMS\Algorithm\Clustering;
*/ */
final class Kmeans final class Kmeans
{ {
/**
* Epsilon for float comparison.
*
* @var float
* @since 1.0.0
*/
public const EPSILON = 4.88e-04;
/** /**
* Metric to calculate the distance between two points * Metric to calculate the distance between two points
* *
@ -163,7 +171,7 @@ final class Kmeans
} }
} }
if ($changed <= $n * 0.001 || $n * 0.001 < 2) { if ($changed <= $n * self::EPSILON || $n * self::EPSILON < 2) {
break; break;
} }
} }