See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401]
1 <?php 2 3 declare(strict_types=1); 4 5 namespace Phpml\Math\Kernel; 6 7 use Phpml\Exception\InvalidArgumentException; 8 use Phpml\Math\Kernel; 9 use Phpml\Math\Product; 10 11 class RBF implements Kernel 12 { 13 /** 14 * @var float 15 */ 16 private $gamma; 17 18 public function __construct(float $gamma) 19 { 20 $this->gamma = $gamma; 21 } 22 23 public function compute($a, $b): float 24 { 25 if (!is_array($a) || !is_array($b)) { 26 throw new InvalidArgumentException(sprintf('Arguments of %s must be arrays', __METHOD__)); 27 } 28 29 $score = 2 * Product::scalar($a, $b); 30 $squares = Product::scalar($a, $a) + Product::scalar($b, $b); 31 32 return exp(-$this->gamma * ($squares - $score)); 33 } 34 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body