On this page
statistics.kde_random
Prev: statistics.kde | Up: statistics | Next: statistics.linear_regression
Rel: statistics.correlation, statistics.covariance, statistics.fmean, statistics.geometric_mean
Ref: docs.python.org — statistics.kde_random
Tags: #public #python3 #stdlib #statistics
Import
import statistics
from statistics import kde_random
Signature & Overview
statistics.kde_random(data, h, kernel='normal', *, seed=None)
Return a function that makes a random selection from the estimated probability density function created by kde(data, h, kernel).
Usage
import statistics
# Python 3.13+: creates a sampler from a KDE distribution
if hasattr(statistics, 'kde_random'):
sampler = statistics.kde_random([1.0, 2.0, 3.0], h=0.5, seed=42)
assert isinstance(sampler(), float)
Gotchas
- Requires Python 3.13+.
REPL Inspect
from statistics import kde_random
help(kde_random)
Linked from
Related notes
- tuts/python3/stdlib_module/statistics/kde Linked here; links to this page; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/linear_regression Linked here; links to this page; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/statistics/correlation Linked here; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/covariance Linked here; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/fmean Linked here; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/geometric_mean Linked here; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/harmonic_mean shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/mean shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/median shared tags: #statistics, #stdlib