3.8.3.2.4. statsmodels.nonparametric.kde.kdensityfft

statsmodels.nonparametric.kde.kdensityfft(X, kernel='gau', bw='normal_reference', weights=None, gridsize=None, adjust=1, clip=(-inf, inf), cut=3, retgrid=True)[source]

Rosenblatt-Parzen univariate kernel density estimator

Parameters:

X : array-like

The variable for which the density estimate is desired.

kernel : str

ONLY GAUSSIAN IS CURRENTLY IMPLEMENTED. “bi” for biweight “cos” for cosine “epa” for Epanechnikov, default “epa2” for alternative Epanechnikov “gau” for Gaussian. “par” for Parzen “rect” for rectangular “tri” for triangular

bw : str, float

“scott” - 1.059 * A * nobs ** (-1/5.), where A is min(std(X),IQR/1.34) “silverman” - .9 * A * nobs ** (-1/5.), where A is min(std(X),IQR/1.34) If a float is given, it is the bandwidth.

weights : array or None

WEIGHTS ARE NOT CURRENTLY IMPLEMENTED. Optional weights. If the X value is clipped, then this weight is also dropped.

gridsize : int

If gridsize is None, min(len(X), 512) is used. Note that the provided number is rounded up to the next highest power of 2.

adjust : float

An adjustment factor for the bw. Bandwidth becomes bw * adjust. clip : tuple Observations in X that are outside of the range given by clip are dropped. The number of observations in X is then shortened.

cut : float

Defines the length of the grid past the lowest and highest values of X so that the kernel goes to zero. The end points are -/+ cut*bw*{X.min() or X.max()}

retgrid : bool

Whether or not to return the grid over which the density is estimated.

Returns:

density : array

The densities estimated at the grid points.

grid : array, optional

The grid points at which the density is estimated.

Notes

Only the default kernel is implemented. Weights aren’t implemented yet. This follows Silverman (1982) with changes suggested by Jones and Lotwick (1984). However, the discretization step is replaced by linear binning of Fan and Marron (1994). This should be extended to accept the parts that are dependent only on the data to speed things up for cross-validation.

References

Fan, J. and J.S. Marron. (1994) `Fast implementations of nonparametric
curve estimators`. Journal of Computational and Graphical Statistics. 3.1, 35-56.
Jones, M.C. and H.W. Lotwick. (1984) `Remark AS R50: A Remark on Algorithm
AS 176. Kernal Density Estimation Using the Fast Fourier Transform`. Journal of the Royal Statistical Society. Series C. 33.1, 120-2.
Silverman, B.W. (1982) `Algorithm AS 176. Kernel density estimation using
the Fast Fourier Transform. Journal of the Royal Statistical Society. Series C. 31.2, 93-9.