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();
}