Statistics Functions

statistics.kde()

Construct a one-dimensional kernel density estimator from nonempty data and positive bandwidth h. cumulative=True estimates the CDF instead of density. Added in 3.13.

Formal Syntax & Structure

python syntaxpython
statistics.kde(data, h, kernel='normal', *, cumulative=False)

Parameters & Attributes

NameTypeDescription
datasequence of real numbersNonempty observations used for kernel estimation.
hfloatPositive kernel bandwidth.
kernelstrSupported kernel name.
cumulativeboolEstimate cumulative probability rather than density when true.

Return Value

Callable[[float], float]

Estimator function taking one evaluation point.

Working Example

Example Snippetpython
import statisticsprint(round(statistics.kde([0.0, 2.0], 1.0, kernel='rectangular')(0.0), 6))
Python Reference