PhpBench\Math\Kde::setBandwidth PHP Метод

setBandwidth() публичный Метод

The new bandwidth calculated after a call to setBandwidth is used for subsequent evaluations of the estimated density.
public setBandwidth ( string $bwMethod = null )
$bwMethod string Either "scott" or "silverman"
    public function setBandwidth($bwMethod = null)
    {
        if ($bwMethod == 'scott' || null === $bwMethod) {
            $this->coVarianceFactor = function () {
                return pow(count($this->dataset), -1.0 / 5);
            };
        } elseif ($bwMethod == 'silverman') {
            $this->coVarianceFactor = function () {
                return pow(count($this->dataset) * 3.0 / 4.0, -1.0 / 5);
            };
        } elseif (is_numeric($bwMethod)) {
            $this->coVarianceFactor = function () use($bwMethod) {
                return $bwMethod;
            };
        } else {
            throw new \InvalidArgumentException(sprintf('Unknown bandwidth method "%s"', $bwMethod));
        }
        $this->computeCovariance();
    }