Kernel Density Estimation
A nonparametric method estimating a continuous probability density by summing bandwidth-scaled kernels over observations.
Kernel density estimation (KDE) constructs a continuous density curve without placing observations into fixed histogram bins. For a univariate, equally weighted sample:
f̂_h(x) = [1/(n×h)] × Σ K((x−x_i)/h)K is a kernel integrating to 1 and h>0 is the bandwidth. With a Gaussian kernel, each observation contributes a smooth bump centered at its value. The normalized sum estimates density; the curve's height at one point is not itself a probability.
Bandwidth controls the picture
A small h may preserve local peaks but exaggerate sampling noise. A large h can hide separated modes. In practice bandwidth usually matters more than the precise kernel shape. Cross-validation, plug-in methods and reference rules provide alternative selection strategies.
For SciPy's gaussian_kde, the default Scott scale factor is n^(−1/(d+4)) in d dimensions. It must not be confused with the n^(−1/3) dependence in Scott's histogram rule.
Limits of a smooth curve
A KDE is an estimate of an unknown population density, not an exact reconstruction. On bounded or nonnegative variables, a Gaussian kernel can allocate density outside the valid measurement range; boundary correction or transformations may be necessary. Discrete measurements, extensive ties and high-dimensional samples introduce further limitations.
A histogram reports interval frequencies, and an ECDF reports cumulative observed proportions. KDE addresses the different question of estimating a smooth density.