3.8.3.2.3. statsmodels.nonparametric.kde.kdensity

statsmodels.nonparametric.kde.kdensity(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

The Kernel to be used. Choices are - “biw” for biweight - “cos” for cosine - “epa” for Epanechnikov - “gau” for Gaussian. - “tri” for triangular - “triw” for triweight - “uni” for uniform

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

Optional weights. If the X value is clipped, then this weight is also dropped.

gridsize : int

If gridsize is None, max(len(X), 50) is used.

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*{min(X) or max(X)}

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

Creates an intermediate (gridsize x nobs) array. Use FFT for a more computationally efficient version.