nag_kernel_density_estim (g10bac) performs kernel density estimation using a Gaussian kernel.
Given a sample of
observations,
, 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:
where
is the number of observations falling in the interval
to
,
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)).
Silverman (1982) 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
to
the following steps are required:
1. |
discretize the data to give equally spaced points with weights (see Jones and Lotwick (1984)); |
2. |
compute the FFT of the weights to give ; |
3. |
compute where ; |
4. |
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.
Not applicable.
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.