statsmodels.nonparametric.kde.KDEUnivariate

class statsmodels.nonparametric.kde.KDEUnivariate(endog)[source]

Univariate Kernel Density Estimator.

Parameters:

endog : array-like

The variable for which the density estimate is desired.

See also

KDEMultivariate, kdensity, kdensityfft

Notes

If cdf, sf, cumhazard, or entropy are computed, they are computed based on the definition of the kernel rather than the FFT approximation, even if the density is fit with FFT = True.

KDEUnivariate is much faster than KDEMultivariate, due to its FFT-based implementation. It should be preferred for univariate, continuous data. KDEMultivariate also supports mixed data.

Examples

>>> import statsmodels.api as sm
>>> import matplotlib.pyplot as plt
>>> nobs = 300
>>> np.random.seed(1234)  # Seed random generator
>>> dens = sm.nonparametric.KDEUnivariate(np.random.normal(size=nobs))
>>> dens.fit()
>>> plt.plot(dens.cdf)
>>> plt.show()

Methods

cdf() Returns the cumulative distribution function evaluated at the support.
cumhazard() Returns the hazard function evaluated at the support.
entropy() Returns the differential entropy evaluated at the support
evaluate(point) Evaluate density at a single point.
fit([kernel, bw, fft, weights, gridsize, ...]) Attach the density estimate to the KDEUnivariate class.
icdf() Inverse Cumulative Distribution (Quantile) Function
sf() Returns the survival function evaluated at the support.

Methods

cdf() Returns the cumulative distribution function evaluated at the support.
cumhazard() Returns the hazard function evaluated at the support.
entropy() Returns the differential entropy evaluated at the support
evaluate(point) Evaluate density at a single point.
fit([kernel, bw, fft, weights, gridsize, ...]) Attach the density estimate to the KDEUnivariate class.
icdf() Inverse Cumulative Distribution (Quantile) Function
sf() Returns the survival function evaluated at the support.