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
| Name | Type | Description |
|---|---|---|
| data | sequence of real numbers | Nonempty observations used for kernel estimation. |
| h | float | Positive kernel bandwidth. |
| kernel | str | Supported kernel name. |
| cumulative | bool | Estimate 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))