On this page
  1. statistics.kde
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

statistics.kde

Prev: statistics.harmonic_mean | Up: statistics | Next: statistics.kde_random
Rel: statistics.correlation, statistics.covariance, statistics.fmean, statistics.geometric_mean
Ref: docs.python.org — statistics.kde
Tags: #public #python3 #stdlib #statistics


Import

import statistics
from statistics import kde

Signature & Overview

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

Kernel Density Estimation: Create a continuous probability density function or cumulative distribution function from discrete samples.

Usage

import statistics

# Python 3.13+: kernel density estimation returning a callable PDF
if hasattr(statistics, 'kde'):
    pdf = statistics.kde([1.0, 2.0, 2.5, 3.0], h=0.5)
    assert pdf(2.0) > 0

Gotchas

REPL Inspect

from statistics import kde
help(kde)

Linked from

Related notes