PHP Class PhpBench\Math\Kde

Currently, only Gaussian kernels are implemented. Original Python version by: Robert Kern Date: 2004-08-09 Modified: 2005-02-10 by Robert Kern. Contributed to Scipy 2005-10-07 by Robert Kern. Some fixes to match the new scipy_core Copyright 2004-2005 by Enthought, Inc. Copyright 2003-2013 SciPy Developers. All rights reserved.
Mostrar archivo Open project: dantleech/phpbench Class Usage Examples

Public Methods

Method Description
__construct ( array $dataset, string $bwMethod = null ) Representation of a kernel-density estimate using Gaussian kernels.
evaluate ( array $points ) : array Evaluate the estimated pdf on a set of points.
setBandwidth ( string $bwMethod = null ) Compute the estimator bandwidth with given method.

Private Methods

Method Description
computeCovariance ( ) Computes the covariance matrix for each Gaussian kernel using coVarianceFactor().

Method Details

__construct() public method

Kernel density estimation is a way to estimate the probability density function (PDF) of a random variable in a non-parametric way. gaussian_kde works for both uni-variate and multi-variate data. It includes automatic bandwidth determination. The estimation works best for a unimodal distribution; bimodal or multi-modal distributions tend to be oversmoothed. Note: Bandwidth selection strongly influences the estimate obtained from the KDE (much more so than the actual shape of the kernel). Bandwidth selection can be done by a "rule of thumb", by cross-validation, by "plug-in methods" or by other means; see [3]_, [4]_ for reviews. gaussian_kde uses a rule of thumb, the default is Scott's Rule. Scott's Rule [1]_, implemented as scotts_factor, is:: n**(-1./(d+4)), with n the number of data points and d the number of dimensions. Silverman's Rule [2]_, implemented as silverman_factor, is:: (n * (d + 2) / 4.)**(-1. / (d + 4)). Good general descriptions of kernel density estimation can be found in [1]_ and [2]_, the mathematics for this multi-dimensional implementation can be found in [1]_. References .. [1] D.W. Scott, "Multivariate Density Estimation: Theory, Practice, and Visualization", John Wiley & Sons, New York, Chicester, 1992. .. [2] B.W. Silverman, "Density Estimation for Statistics and Data Analysis", Vol. 26, Monographs on Statistics and Applied Probability, Chapman and Hall, London, 1986.
public __construct ( array $dataset, string $bwMethod = null )
$dataset array Array of univariate data points.
$bwMethod string : Either "scott", "silverman" or an explicit (float) value.

evaluate() public method

Evaluate the estimated pdf on a set of points.
public evaluate ( array $points ) : array
$points array 1-D array of points on to which we will map the kde
return array

setBandwidth() public method

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"