0.6.2-dev0
FORCES
FORtran lib for Comp. Env. Sys.
Loading...
Searching...
No Matches
mo_kernel Module Reference

Module for kernel regression and kernel density estimation. More...

Data Types

interface  allocate_globals
 
interface  cross_valid_density
 
interface  cross_valid_regression
 
interface  golden
 
interface  kernel_cumdensity
 Approximates the cumulative density function (CDF). More...
 
interface  kernel_density
 Approximates the probability density function (PDF). More...
 
interface  kernel_density_h
 Approximates the bandwith h of the kernel. More...
 
interface  kernel_regression
 Multi-dimensional non-parametric kernel regression. More...
 
interface  kernel_regression_h
 Approximates the bandwith h of the kernel for regression. More...
 
interface  mesh
 
interface  nadaraya_watson
 
interface  polint
 
interface  trapzd
 

Functions/Subroutines

real(dp) function, dimension(:), allocatable kernel_cumdensity_1d_dp (ix, h, silverman, xout, romberg, nintegrate, epsint, mask, nodata)
 
real(sp) function, dimension(:), allocatable kernel_cumdensity_1d_sp (ix, h, silverman, xout, romberg, nintegrate, epsint, mask, nodata)
 
real(dp) function, dimension(:), allocatable kernel_density_1d_dp (ix, h, silverman, xout, mask, nodata)
 
real(sp) function, dimension(:), allocatable kernel_density_1d_sp (ix, h, silverman, xout, mask, nodata)
 
real(dp) function kernel_density_h_1d_dp (ix, silverman, mask)
 
real(sp) function kernel_density_h_1d_sp (ix, silverman, mask)
 
real(dp) function, dimension(:), allocatable kernel_regression_1d_dp (ix, iy, h, silverman, xout, mask, nodata)
 
real(sp) function, dimension(:), allocatable kernel_regression_1d_sp (ix, iy, h, silverman, xout, mask, nodata)
 
real(dp) function, dimension(:), allocatable kernel_regression_2d_dp (ix, iy, h, silverman, xout, mask, nodata)
 
real(sp) function, dimension(:), allocatable kernel_regression_2d_sp (ix, iy, h, silverman, xout, mask, nodata)
 
real(dp) function kernel_regression_h_1d_dp (ix, iy, silverman, mask)
 
real(sp) function kernel_regression_h_1d_sp (ix, iy, silverman, mask)
 
real(dp) function, dimension(size(ix, 2)) kernel_regression_h_2d_dp (ix, iy, silverman, mask)
 
real(sp) function, dimension(size(ix, 2)) kernel_regression_h_2d_sp (ix, iy, silverman, mask)
 
real(dp) function nadaraya_watson_1d_dp (z, y, mask, valid)
 
real(sp) function nadaraya_watson_1d_sp (z, y, mask, valid)
 
real(dp) function nadaraya_watson_2d_dp (z, y, mask, valid)
 
real(sp) function nadaraya_watson_2d_sp (z, y, mask, valid)
 
real(dp) function cross_valid_regression_dp (h)
 
real(sp) function cross_valid_regression_sp (h)
 
real(dp) function cross_valid_density_1d_dp (h)
 
real(sp) function cross_valid_density_1d_sp (h)
 
subroutine allocate_globals_1d_dp (x, y, xout)
 
subroutine allocate_globals_1d_sp (x, y, xout)
 
subroutine allocate_globals_2d_dp (x, y, xout)
 
subroutine allocate_globals_2d_sp (x, y, xout)
 
subroutine deallocate_globals ()
 
real(sp) function golden_sp (ax, bx, cx, func, tol, xmin)
 
real(dp) function golden_dp (ax, bx, cx, func, tol, xmin)
 
real(dp) function, dimension(n) mesh_dp (start, end, n, delta)
 
real(sp) function, dimension(n) mesh_sp (start, end, n, delta)
 
subroutine trapzd_dp (kernel, x, h, a, b, res, n)
 
subroutine trapzd_sp (kernel, x, h, a, b, res, n)
 
subroutine polint_dp (xa, ya, x, y, dy)
 
subroutine polint_sp (xa, ya, x, y, dy)
 

Variables

real(sp), dimension(:,:), allocatable global_x_sp
 
real(sp), dimension(:,:), allocatable global_xout_sp
 
real(sp), dimension(:), allocatable global_y_sp
 
real(dp), dimension(:,:), allocatable global_x_dp
 
real(dp), dimension(:,:), allocatable global_xout_dp
 
real(dp), dimension(:), allocatable global_y_dp
 

Detailed Description

Module for kernel regression and kernel density estimation.

This module provides routines for kernel regression of data as well as kernel density estimation of both probability density functions (PDF) and cumulative density functions (CDF).
So far only a Gaussian kernel is implemented (Nadaraya-Watson) which can be used for one- and multidimensional data.
Furthermore, the estimation of the bandwith needed for kernel methods is provided by either Silverman''s rule of thumb or a Cross-Vaildation approach.
The Cross-Validation method is actually an optimization of the bandwith and might be the most costly part of the kernel smoother. Therefore, the bandwith estimation is not necessarily part of the kernel smoothing but can be determined first and given as an optional argument to the smoother.

Changelog
  • Juliane Mai, Mar 2013
  • Stephan Thober, Mar 2013
  • Matthias Cuntz, Mar 2013
  • Matthias Cuntz, May 2013
    • sort -> qsort
    • module procedure golden
  • Stephan Thober, Jul 2015
    • using sort_index in favor of qsort_index
  • Matthias Cuntz, Mar 2016
    • Romberg integration in cumdensity
  • Juliane Mai
Date
Mar 2013

Function/Subroutine Documentation

◆ allocate_globals_1d_dp()

subroutine mo_kernel::allocate_globals_1d_dp ( real(dp), dimension(:), intent(in)  x,
real(dp), dimension(:), intent(in), optional  y,
real(dp), dimension(:), intent(in), optional  xout 
)
private

Definition at line 2268 of file mo_kernel.f90.

◆ allocate_globals_1d_sp()

subroutine mo_kernel::allocate_globals_1d_sp ( real(sp), dimension(:), intent(in)  x,
real(sp), dimension(:), intent(in), optional  y,
real(sp), dimension(:), intent(in), optional  xout 
)
private

Definition at line 2291 of file mo_kernel.f90.

◆ allocate_globals_2d_dp()

subroutine mo_kernel::allocate_globals_2d_dp ( real(dp), dimension(:,:), intent(in)  x,
real(dp), dimension(:), intent(in), optional  y,
real(dp), dimension(:,:), intent(in), optional  xout 
)
private

Definition at line 2314 of file mo_kernel.f90.

◆ allocate_globals_2d_sp()

subroutine mo_kernel::allocate_globals_2d_sp ( real(sp), dimension(:,:), intent(in)  x,
real(sp), dimension(:), intent(in), optional  y,
real(sp), dimension(:,:), intent(in), optional  xout 
)
private

Definition at line 2337 of file mo_kernel.f90.

◆ cross_valid_density_1d_dp()

real(dp) function mo_kernel::cross_valid_density_1d_dp ( real(dp), intent(in)  h)
private

Definition at line 2118 of file mo_kernel.f90.

◆ cross_valid_density_1d_sp()

real(sp) function mo_kernel::cross_valid_density_1d_sp ( real(sp), intent(in)  h)
private

Definition at line 2192 of file mo_kernel.f90.

◆ cross_valid_regression_dp()

real(dp) function mo_kernel::cross_valid_regression_dp ( real(dp), dimension(:), intent(in)  h)
private

Definition at line 2028 of file mo_kernel.f90.

◆ cross_valid_regression_sp()

real(sp) function mo_kernel::cross_valid_regression_sp ( real(sp), dimension(:), intent(in)  h)
private

Definition at line 2073 of file mo_kernel.f90.

◆ deallocate_globals()

subroutine mo_kernel::deallocate_globals
private

Definition at line 2363 of file mo_kernel.f90.

◆ golden_dp()

real(dp) function mo_kernel::golden_dp ( real(dp), intent(in)  ax,
real(dp), intent(in)  bx,
real(dp), intent(in)  cx,
external real(dp) function(real(dp), intent(in) x)  func,
real(dp), intent(in)  tol,
real(dp), intent(out)  xmin 
)
private

Definition at line 2449 of file mo_kernel.f90.

◆ golden_sp()

real(sp) function mo_kernel::golden_sp ( real(sp), intent(in)  ax,
real(sp), intent(in)  bx,
real(sp), intent(in)  cx,
external real(sp) function(real(sp), intent(in) x)  func,
real(sp), intent(in)  tol,
real(sp), intent(out)  xmin 
)
private

Definition at line 2379 of file mo_kernel.f90.

◆ kernel_cumdensity_1d_dp()

real(dp) function, dimension(:), allocatable mo_kernel::kernel_cumdensity_1d_dp ( real(dp), dimension(:), intent(in)  ix,
real(dp), intent(in), optional  h,
logical, intent(in), optional  silverman,
real(dp), dimension(:), intent(in), optional  xout,
logical, intent(in), optional  romberg,
integer(i4), intent(in), optional  nintegrate,
real(dp), intent(in), optional  epsint,
logical, dimension(:), intent(in), optional  mask,
real(dp), intent(in), optional  nodata 
)
private

Definition at line 460 of file mo_kernel.f90.

◆ kernel_cumdensity_1d_sp()

real(sp) function, dimension(:), allocatable mo_kernel::kernel_cumdensity_1d_sp ( real(sp), dimension(:), intent(in)  ix,
real(sp), intent(in), optional  h,
logical, intent(in), optional  silverman,
real(sp), dimension(:), intent(in), optional  xout,
logical, intent(in), optional  romberg,
integer(i4), intent(in), optional  nintegrate,
real(sp), intent(in), optional  epsint,
logical, dimension(:), intent(in), optional  mask,
real(sp), intent(in), optional  nodata 
)
private

Definition at line 659 of file mo_kernel.f90.

◆ kernel_density_1d_dp()

real(dp) function, dimension(:), allocatable mo_kernel::kernel_density_1d_dp ( real(dp), dimension(:), intent(in)  ix,
real(dp), intent(in), optional  h,
logical, intent(in), optional  silverman,
real(dp), dimension(:), intent(in), optional  xout,
logical, dimension(:), intent(in), optional  mask,
real(dp), intent(in), optional  nodata 
)
private

Definition at line 861 of file mo_kernel.f90.

◆ kernel_density_1d_sp()

real(sp) function, dimension(:), allocatable mo_kernel::kernel_density_1d_sp ( real(sp), dimension(:), intent(in)  ix,
real(sp), intent(in), optional  h,
logical, intent(in), optional  silverman,
real(sp), dimension(:), intent(in), optional  xout,
logical, dimension(:), intent(in), optional  mask,
real(sp), intent(in), optional  nodata 
)
private

Definition at line 957 of file mo_kernel.f90.

◆ kernel_density_h_1d_dp()

real(dp) function mo_kernel::kernel_density_h_1d_dp ( real(dp), dimension(:), intent(in)  ix,
logical, intent(in), optional  silverman,
logical, dimension(:), intent(in), optional  mask 
)
private

Definition at line 1056 of file mo_kernel.f90.

◆ kernel_density_h_1d_sp()

real(sp) function mo_kernel::kernel_density_h_1d_sp ( real(sp), dimension(:), intent(in)  ix,
logical, intent(in), optional  silverman,
logical, dimension(:), intent(in), optional  mask 
)
private

Definition at line 1107 of file mo_kernel.f90.

◆ kernel_regression_1d_dp()

real(dp) function, dimension(:), allocatable mo_kernel::kernel_regression_1d_dp ( real(dp), dimension(:), intent(in)  ix,
real(dp), dimension(:), intent(in)  iy,
real(dp), intent(in), optional  h,
logical, intent(in), optional  silverman,
real(dp), dimension(:), intent(in), optional  xout,
logical, dimension(:), intent(in), optional  mask,
real(dp), intent(in), optional  nodata 
)
private

Definition at line 1161 of file mo_kernel.f90.

◆ kernel_regression_1d_sp()

real(sp) function, dimension(:), allocatable mo_kernel::kernel_regression_1d_sp ( real(sp), dimension(:), intent(in)  ix,
real(sp), dimension(:), intent(in)  iy,
real(sp), intent(in), optional  h,
logical, intent(in), optional  silverman,
real(sp), dimension(:), intent(in), optional  xout,
logical, dimension(:), intent(in), optional  mask,
real(sp), intent(in), optional  nodata 
)
private

Definition at line 1259 of file mo_kernel.f90.

◆ kernel_regression_2d_dp()

real(dp) function, dimension(:), allocatable mo_kernel::kernel_regression_2d_dp ( real(dp), dimension(:,:), intent(in)  ix,
real(dp), dimension(:), intent(in)  iy,
real(dp), dimension(:), intent(in), optional  h,
logical, intent(in), optional  silverman,
real(dp), dimension(:,:), intent(in), optional  xout,
logical, dimension(:), intent(in), optional  mask,
real(dp), intent(in), optional  nodata 
)
private

Definition at line 1357 of file mo_kernel.f90.

◆ kernel_regression_2d_sp()

real(sp) function, dimension(:), allocatable mo_kernel::kernel_regression_2d_sp ( real(sp), dimension(:,:), intent(in)  ix,
real(sp), dimension(:), intent(in)  iy,
real(sp), dimension(:), intent(in), optional  h,
logical, intent(in), optional  silverman,
real(sp), dimension(:,:), intent(in), optional  xout,
logical, dimension(:), intent(in), optional  mask,
real(sp), intent(in), optional  nodata 
)
private

Definition at line 1462 of file mo_kernel.f90.

◆ kernel_regression_h_1d_dp()

real(dp) function mo_kernel::kernel_regression_h_1d_dp ( real(dp), dimension(:), intent(in)  ix,
real(dp), dimension(:), intent(in)  iy,
logical, intent(in), optional  silverman,
logical, dimension(:), intent(in), optional  mask 
)
private

Definition at line 1570 of file mo_kernel.f90.

◆ kernel_regression_h_1d_sp()

real(sp) function mo_kernel::kernel_regression_h_1d_sp ( real(sp), dimension(:), intent(in)  ix,
real(sp), dimension(:), intent(in)  iy,
logical, intent(in), optional  silverman,
logical, dimension(:), intent(in), optional  mask 
)
private

Definition at line 1627 of file mo_kernel.f90.

◆ kernel_regression_h_2d_dp()

real(dp) function, dimension(size(ix,2)) mo_kernel::kernel_regression_h_2d_dp ( real(dp), dimension(:,:), intent(in)  ix,
real(dp), dimension(:), intent(in)  iy,
logical, intent(in), optional  silverman,
logical, dimension(:), intent(in), optional  mask 
)
private

Definition at line 1684 of file mo_kernel.f90.

◆ kernel_regression_h_2d_sp()

real(sp) function, dimension(size(ix,2)) mo_kernel::kernel_regression_h_2d_sp ( real(sp), dimension(:,:), intent(in)  ix,
real(sp), dimension(:), intent(in)  iy,
logical, intent(in), optional  silverman,
logical, dimension(:), intent(in), optional  mask 
)
private

Definition at line 1742 of file mo_kernel.f90.

◆ mesh_dp()

real(dp) function, dimension(n) mo_kernel::mesh_dp ( real(dp), intent(in)  start,
real(dp), intent(in)  end,
integer(i4), intent(in)  n,
real(dp), intent(out)  delta 
)
private

Definition at line 2522 of file mo_kernel.f90.

◆ mesh_sp()

real(sp) function, dimension(n) mo_kernel::mesh_sp ( real(sp), intent(in)  start,
real(sp), intent(in)  end,
integer(i4), intent(in)  n,
real(sp), intent(out)  delta 
)
private

Definition at line 2540 of file mo_kernel.f90.

◆ nadaraya_watson_1d_dp()

real(dp) function mo_kernel::nadaraya_watson_1d_dp ( real(dp), dimension(:), intent(in)  z,
real(dp), dimension(:), intent(in), optional  y,
logical, dimension(:), intent(in), optional  mask,
logical, intent(out), optional  valid 
)
private

Definition at line 1807 of file mo_kernel.f90.

◆ nadaraya_watson_1d_sp()

real(sp) function mo_kernel::nadaraya_watson_1d_sp ( real(sp), dimension(:), intent(in)  z,
real(sp), dimension(:), intent(in), optional  y,
logical, dimension(:), intent(in), optional  mask,
logical, intent(out), optional  valid 
)
private

Definition at line 1859 of file mo_kernel.f90.

◆ nadaraya_watson_2d_dp()

real(dp) function mo_kernel::nadaraya_watson_2d_dp ( real(dp), dimension(:,:), intent(in)  z,
real(dp), dimension(:), intent(in), optional  y,
logical, dimension(:), intent(in), optional  mask,
logical, intent(out), optional  valid 
)
private

Definition at line 1911 of file mo_kernel.f90.

◆ nadaraya_watson_2d_sp()

real(sp) function mo_kernel::nadaraya_watson_2d_sp ( real(sp), dimension(:,:), intent(in)  z,
real(sp), dimension(:), intent(in), optional  y,
logical, dimension(:), intent(in), optional  mask,
logical, intent(out), optional  valid 
)
private

Definition at line 1968 of file mo_kernel.f90.

◆ polint_dp()

subroutine mo_kernel::polint_dp ( real(dp), dimension(:), intent(in)  xa,
real(dp), dimension(:), intent(in)  ya,
real(dp), intent(in)  x,
real(dp), intent(out)  y,
real(dp), intent(out)  dy 
)
private

Definition at line 2640 of file mo_kernel.f90.

◆ polint_sp()

subroutine mo_kernel::polint_sp ( real(sp), dimension(:), intent(in)  xa,
real(sp), dimension(:), intent(in)  ya,
real(sp), intent(in)  x,
real(sp), intent(out)  y,
real(sp), intent(out)  dy 
)
private

Definition at line 2679 of file mo_kernel.f90.

◆ trapzd_dp()

subroutine mo_kernel::trapzd_dp ( external real(dp) function, dimension(:), allocatable(real(dp), dimension(:), intent(in) ix, real(dp), intent(in), optional hh, logical, intent(in), optional silverman, real(dp), dimension(:), intent(in), optional xout, logical, dimension(:), intent(in), optional mask, real(dp), intent(in), optional nodata)  kernel,
real(dp), dimension(:), intent(in)  x,
real(dp), intent(in)  h,
real(dp), intent(in)  a,
real(dp), intent(in)  b,
real(dp), intent(inout)  res,
integer(i4), intent(in)  n 
)
private

Definition at line 2558 of file mo_kernel.f90.

◆ trapzd_sp()

subroutine mo_kernel::trapzd_sp ( external real(sp) function, dimension(:), allocatable(real(sp), dimension(:), intent(in) ix, real(sp), intent(in), optional hh, logical, intent(in), optional silverman, real(sp), dimension(:), intent(in), optional xout, logical, dimension(:), intent(in), optional mask, real(sp), intent(in), optional nodata)  kernel,
real(sp), dimension(:), intent(in)  x,
real(sp), intent(in)  h,
real(sp), intent(in)  a,
real(sp), intent(in)  b,
real(sp), intent(inout)  res,
integer(i4), intent(in)  n 
)
private

Definition at line 2599 of file mo_kernel.f90.

Variable Documentation

◆ global_x_dp

real(dp), dimension(:,:), allocatable mo_kernel::global_x_dp
private

Definition at line 450 of file mo_kernel.f90.

◆ global_x_sp

real(sp), dimension(:,:), allocatable mo_kernel::global_x_sp
private

Definition at line 446 of file mo_kernel.f90.

◆ global_xout_dp

real(dp), dimension(:,:), allocatable mo_kernel::global_xout_dp
private

Definition at line 451 of file mo_kernel.f90.

◆ global_xout_sp

real(sp), dimension(:,:), allocatable mo_kernel::global_xout_sp
private

Definition at line 447 of file mo_kernel.f90.

◆ global_y_dp

real(dp), dimension(:), allocatable mo_kernel::global_y_dp
private

Definition at line 452 of file mo_kernel.f90.

◆ global_y_sp

real(sp), dimension(:), allocatable mo_kernel::global_y_sp
private

Definition at line 448 of file mo_kernel.f90.