Statistics Functions
statistics.kde_random()
Construct a random sampler from a kernel density estimate. An optional seed makes repeated runs reproducible within a compatible implementation; sampled values may change across versions. Added in 3.13.
Formal Syntax & Structure
python syntaxpython
statistics.kde_random(data, h, kernel='normal', *, seed=None)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. |
| seed | int, float, str, bytes, bytearray or None | Optional pseudorandom seed; None uses default random initialization. |
Return Value
Callable[[], float]
Zero-argument sampler function.
Working Example
Example Snippetpython
import statisticsprint(statistics.kde_random([1, 2], 0.5, seed=7)() == statistics.kde_random([1, 2], 0.5, seed=7)())