= Gaussian kernel density worked example
{c}
{title2=$\widehat f(0)=0.337949\ldots$}
Take the realized <statistical sample> $(-1,0,1)$, the <Gaussian density kernel> $\phi(u)=(2\pi)^{-1/2}e^{-u^2/2}$ and <smoothing bandwidth> $h=1/2$. Then
$$
\widehat f(x)=\frac23\bigl[\phi(2x+2)+\phi(2x)+\phi(2x-2)\bigr].
$$
At $x=0$, the three contributions are $0.03599398$, $0.26596152$, and $0.03599398$, because $\phi(0)=0.39894228$ and $\phi(2)=e^{-2}/\sqrt{2\pi}=0.05399097$. Their sum is
$$
\widehat f(0)=\frac{2(1+2e^{-2})}{3\sqrt{2\pi}}=0.33794948\ldots.
$$
This is a <probability density function> value, not the <probability> of observing exactly zero. Each of the three component curves has area $1/3$, despite having a different height at zero.
Let $\Phi$ be the <cumulative distribution function> of the <standard normal distribution>. The fitted <probability> of the interval $[-1/2,1/2]$ is its area under the <kernel density estimator>:
$$
\begin{aligned}
\int_{-1/2}^{1/2}\widehat f(x)\,dx
&=\frac13\sum_{a\in\{-1,0,1\}}\bigl[\Phi(1-2a)-\Phi(-1-2a)\bigr]\\
&=\frac{[\Phi(3)-\Phi(1)]+[\Phi(1)-\Phi(-1)]+[\Phi(-1)-\Phi(-3)]}{3}\\
&=\frac{0.15730536+0.68268949+0.15730536}{3}=0.33243340\ldots.
\end{aligned}
$$
The shaded area in the diagram is this fitted <probability>. Its agreement to a few digits with $1/3$ is incidental: the <empirical measure> gives this interval mass $1/3$ exactly, whereas <kernel density estimation> redistributes that mass into neighboring intervals.
Back to article page