FORCES
FORtran lib for Comp. Env. Sys.
|
Approximates the bandwith h of the kernel. More...
Public Member Functions | |
real(dp) function | kernel_density_h_1d_dp (ix, silverman, mask) |
real(sp) function | kernel_density_h_1d_sp (ix, silverman, mask) |
Approximates the bandwith h of the kernel.
Approximates the bandwith h of the kernel for a given dataset x either using Silverman''s rule-of-thumb or a cross-validation method.
By default the bandwidth h is approximated by Silverman''s rule-of-thumb
\[ h = \frac{4}{3}^{0.2} n^{-0.2} \sigma_x \]
where n is the number of given data points and \( \sigma \) is the standard deviation of the data.
If the optional argument silverman is set to false, the cross-validation method described by Scott et al. (2005) is applied. Therefore, the likelihood of a given h is maximized using the Nelder-Mead algorithm nelminrange. For large data sets this might be time consuming and should be performed aforehand using the function kernel_density_h.
The dataset x can be single or double precision. The result will have the same numerical precision.
The result of this function can be used as the optional input for kernel_density and kernel_cumdensity.
Example
-> see also example in test directory
Literature
[in] | real(sp/dp) :: x(:) | \( x_i \) 1D-array with data points |
[in] | logical, optional :: silverman | By default Silverman''s Rule-of-thumb will be used to approximate the bandwith of the kernel (silverman=true). If silverman=false the Cross-Validation approach is used to estimate the bandwidth. |
[in] | logical, optional :: mask(:) | mask x values at calculation. |
Definition at line 262 of file mo_kernel.f90.
real(dp) function mo_kernel::kernel_density_h::kernel_density_h_1d_dp | ( | real(dp), dimension(:), intent(in) | ix, |
logical, intent(in), optional | silverman, | ||
logical, dimension(:), intent(in), optional | mask | ||
) |
Definition at line 1056 of file mo_kernel.f90.
real(sp) function mo_kernel::kernel_density_h::kernel_density_h_1d_sp | ( | real(sp), dimension(:), intent(in) | ix, |
logical, intent(in), optional | silverman, | ||
logical, dimension(:), intent(in), optional | mask | ||
) |
Definition at line 1107 of file mo_kernel.f90.