lib/Math/Kde.php
public function setBandwidth($bwMethod = null)
    {
        if ($bwMethod == 'scott' || null === $bwMethod) {
            $this->coVarianceFactor = function () {
                return pow(count($this->dataset), -1. / (5));
            };
        } elseif ($bwMethod == 'silverman') {
            $this->coVarianceFactor = function () {
                return pow(count($this->dataset) * (3.0) / 4.0, -1. / (5));
            };
        } elseif (is_numeric($bwMethod)) {
            $this->coVarianceFactor = function () use ($bwMethod) {
                return $bwMethod;
            };
        } else {
            throw new \InvalidArgumentException(sprintf(
                'Unknown bandwidth method "%s"',
                $bwMethod
            ));
        }

        $this->computeCovariance();
    }
public function setBandwidth($bwMethod = null)
    {
        if ($bwMethod == 'scott' || null === $bwMethod) {
            $this->coVarianceFactor = function () {
                return pow(count($this->dataset), -1. / (5));
            };
        } elseif ($bwMethod == 'silverman') {
            $this->coVarianceFactor = function () {
                return pow(count($this->dataset) * (3.0) / 4.0, -1. / (5));
            };
        } elseif (is_numeric($bwMethod)) {
            $this->coVarianceFactor = function () use ($bwMethod) {
                return $bwMethod;
            };
        } else {
            throw new \InvalidArgumentException(sprintf(
                'Unknown bandwidth method "%s"',
                $bwMethod
            ));
        }

        $this->computeCovariance();
    }
public function setBandwidth ( $ bwMethod = null ) { if ( $ bwMethod == 'scott' || null === $ bwMethod ) { $ this -> coVarianceFactor = function ( ) { return pow ( count ( $ this -> dataset ) , - 1. / ( 5 ) ) ; } ; } elseif ( $ bwMethod == 'silverman' ) { $ this -> coVarianceFactor = function ( ) { return pow ( count ( $ this -> dataset ) * ( 3.0 ) / 4.0 , - 1. / ( 5 ) ) ; } ; } elseif ( is_numeric ( $ bwMethod ) ) { $ this -> coVarianceFactor = function ( ) use ( $ bwMethod ) { return $ bwMethod ; } ; } else { throw new \ InvalidArgumentException ( sprintf ( 'Unknown bandwidth method "%s"' , $ bwMethod ) ) ; } $ this -> computeCovariance ( ) ; }
Compute the estimator bandwidth with given method.

The new bandwidth calculated after a call to `setBandwidth` is used
for subsequent evaluations of the estimated density.

@param string $bwMethod Either "scott" or "silverman"
Compute the estimator bandwidth with given method .