Skip to contents

ESL Eqs. (6.23)-(6.24). In one dimension the estimate IS the empirical distribution convolved with a Gaussian of standard deviation lambda: F_hat puts mass 1/N at each observation and is jumpy, and the estimate smooths it by adding independent Gaussian noise to each point. That is why lambda is a standard deviation here rather than a generic bandwidth.

Usage

morie_esl_kernel_density(x, data, lambda_ = NULL)

Arguments

x

evaluation points: a vector, or a matrix with p columns.

data

sample: a vector, or a matrix with p columns.

lambda_

kernel standard deviation; Silverman's normal reference 1.06 sigma N^(-1/5) when NULL, which is a DENSITY rule and correct here.

Value

list: x, density, lambda, n, p, mass (1-D only), normaliser, is_convolution, method.

Details

In p dimensions the Gaussian product kernel (6.24) normalises by N (2 lambda^2 pi)^(p/2) – the exponent is p/2, not p.

References

Hastie, Tibshirani and Friedman (2009), Sec. 6.6, Eqs. (6.22)-(6.24); Parzen (1962).

Examples

set.seed(1)
morie_esl_kernel_density(c(-1, 0, 1), stats::rnorm(200))$density
#> [1] 0.2309164 0.4073686 0.2288376