lambda = $lambda; $this->inverse = 1.0 / $lambda; } /** * Return the data types that this kernel is compatible with. * * @internal * * @return list */ public function compatibility() : array { return [ DataType::continuous(), ]; } /** * Compute the distance given two vectors. * * @internal * * @param list $a * @param list $b * @return float */ public function compute(array $a, array $b) : float { $distance = 0.0; foreach ($a as $i => $value) { $distance += abs($value - $b[$i]) ** $this->lambda; } return $distance ** $this->inverse; } /** * Return the string representation of the object. * * @internal * * @return string */ public function __toString() : string { return "Minkowski (lambda: {$this->lambda})"; } }