nag_kernel_density_estim (g10bac) performs kernel density estimation using a Gaussian kernel.
Given a sample of
, from a distribution with unknown density function,
, an estimate of the density function,
, may be required. The simplest form of density estimator is the histogram. This may be defined by:
is the number of observations falling in the interval
is the lower bound to the histogram and
is the upper bound. The value
is known as the window width. To produce a smoother density estimate a kernel method can be used. A kernel function,
, satisfies the conditions:
The kernel density estimator is then defined as:
The choice of
is usually not important but to ease the computational burden use can be made of the Gaussian kernel defined as:
The smoothness of the estimator depends on the window width
. The larger the value of
the smoother the density estimate. The value of
can be chosen by examining plots of the smoothed density for different values of
or by using cross-validation methods (see Silverman (1990)
and Silverman (1990)
show how the Gaussian kernel density estimator can be computed using a fast Fourier transform (FFT). In order to compute the kernel density estimate over the range
the following steps are required:
||discretize the data to give equally spaced points with weights (see Jones and Lotwick (1984));
||compute the FFT of the weights to give ;
||compute where ;
||find the inverse FFT of to give .
Jones M C and Lotwick H W (1984) Remark AS R50. A remark on algorithm AS 176. Kernel density estimation using the Fast Fourier Transform Appl. Statist. 33 120–122
Silverman B W (1982) Algorithm AS 176. Kernel density estimation using the fast Fourier transform Appl. Statist. 31 93–99
See Jones and Lotwick (1984)
for a discussion of the accuracy of this method.
A sample of 1000 standard Normal (0,1) variates are generated using nag_rand_normal (g05skc)
and the density estimated on 100 points with a window width of 0.1.