% Kernel Density Estimation Toolbox.
% Version 1.2         1-Dec-1996
% Christian C. Beardah
%
% Demonstrations:
%
% KDEDEMO1    Demonstrate UIControls with 1D Kernel Density Estimates.
% KDEDEMO2    Demonstrate UIControls with 2D Kernel Density Estimates.
% KDEDEMO3    Demonstrate UIControls with 3D Kernel Density Estimates.
%
% Fundamental background routines:
%
% AKDEST1D    Adaptive Kernel Density Estimator for uni-variate data.
% AKDEST2D    Adaptive Kernel Density Estimator for bi-variate data.
% KDEST1D     Uni-variate Kernel Density Estimator.
% KDEST2D     Bi-variate Kernel Density Estimator with generalised smoothing.
% KDEST3D     Tri-variate Kernel Density Estimator with generalised smoothing.
% KDFFT1      KDE plot for 1D data using FFTs.
% KDFFT2      KDE plot for 2D data using FFTs.
% KDPLOT      Kernel Density Estimate plot for 1D or 2D data.
% KDPLOT3     Kernel Density Estimate plot for 3D data.
%
% Kernel functions:
%
% CBIWE       Canonical Bi-weight Kernel Function for univariate data.
% CEPAN       Canonical Epanechikov Kernel Function.
% CLAPL       Canonical Laplace Kernel Function for univariate data.
% CLOGI       Canonical Logistic Kernel Function for univariate data.
% CNORM       Canonical Uni- or Bi-variate Normal Density Function.
% CRECT       Canonical Rectangular Kernel Function for univariate data.
% CTRIA       Canonical Triangular Kernel Function for univariate data.
% CTRIW       Canonical Tri-weight Kernel Function for univariate data.
% DERIV       4th, 6th, 8th and 10th derivatives of the Normal kernel.
% DERIV2      High order partial derivatives of the Normal kernel.
% KBIWE       Bi-weight Kernel Function for univariate data.
% KEPAN       Multivariate Epanechikov Kernel Function.
% KEPV2       Epanechnikov variant Kernal Function for d=2.
% KEPV3       Epanechnikov variant Kernal Function for d=2.
% KLAPL       Laplace Kernel Function for univariate data.
% KLOGI       Logistic Kernel Function for univariate data.
% KMVN        Multivariate Normal Density Function.
% KNORM       Uni-, Bi- or Tri-variate Normal Density Function.
% KRECT       Rectangular Kernel Function for univariate data.
% KTRIA       Triangular Kernel Function for univariate data.
% KTRIW       Tri-weight Kernel Function for univariate data.
%
% Smoothing parameter selection:
%
% BCV2        Biased cross-validation criterion function.
% DIFFH       Difference between KDE's using two different values of h.
% H2DPI       L-stage Direct Plug-In estimate of h1, h2 for bi-variate data.
% HBCV        Biased cross-validation estimate of h.
% HBCV2       Biased cross-validation for bi-variate data.
% HBOOT       Bootstrap cross-validation estimate of h.
% HDPI        L-stage Direct plug-in estimate of smoothing parameter.
% HLSCV       Least squares cross-validation estimate of h.
% HNS         Basic Normal Scale estimate of smoothing parameter.
% HSCV        Smoothed cross-validation estimate of h.
% HSTE        2-stage Solve the Equation estimate of h.
% HSTT        Scott-Tapia-Thompson estimate of h.
% LCV         LCV(H,A,K)
% PSIM        Calculate psi_m by brute force.
% SIQR        Sample Interquartile Range.
% 
% Densities and Normal Mixture Densities:
%
% CDF         Cumulative Density Function. 
% NMD2MISE    MISE(h) for bi-variate normal mixture densities.
% NMD2PLOT    Bi-variate normal mixture density plot.
% NMDMISE     MISE(h) for normal mixture densities.
% NMDPLOT     Plot normal mixture density.
% NPDF        Normal probability density function.
% NPDF2       Bi-variate Normal probability density function.
% NPDF3       Tri-variate Normal probability density function.
%
% Contouring:
%
% KDCONT3     Contour surfaces for tri-variate data.
% OUTL2       Calculates the distance of points outside a p% contour level.
% PCCONT      p% contour plot for bi-variate data.
% PCCONT1     p% contour plot for bi-variate data.
% PCCONT3     p% contour plot for tri-variate data.
% PCLVL1      Calculates p% contour levels for uni-variate data.
% PCLVL2      Calculates p% contour levels for bi-variate data.
% PCLVL3      Calculates p% contour levels for tri-variate data.
% PCLVL3A     p% contour plot for tri-variate data.
%
% Sampling:
%
% KDSMPL1D    Compare sample and population K.d.e.'s.
% KDSSMPL     Evaluates I(f;g) for various partitions.
% REPSAMP     Repeated sampling from a population.
% REPSNMD     Repeated sampling from a normal mixture density.
% REPSNMD2    Repeated sampling from a bi-variate normal mixture density.
% SAMP1       Repeated sampling with increasing sample size from a population.
% SAMP2       Repeated sampling with increasing sample size for NMDs.
% SAMP3       Repeated sampling for bi-variate NMDs.
% SAMPLE      Random sampling of points from a data-set.
% SNMD        Normal mixture density random sample.
% SNMD2       Bi-variate normal mixture density random sample.
%
% Matrix handling:
%
% ADDSPACE    Add an action space to a matrix grid.
% GENSPACE    Convert matrix to dataset.
% INPOLY      Test whether points lie in a polygon.
% M2LL        Map matrix to Long./Lat. co-ordinates.
% XYN2DATA    Convert multiple (X,Y) co-ordinates to dataset.
% ZDENS1      Extract bi-variate densities at grid points.
% ZDENS2      Extract bi-variate densities at grid points.
%
% Boundary KDEs:
%
% BKDEST1D    Uni-variate Boundary Kernel Density Estimator.
% KB_BOUND    Bi-weight Boundary Kernel Function for univariate data.
% KN_BOUND    Normal Boundary Kernel Function for univariate data.
%
% Miscellaneous:
%
% CDATA       Centre a data-set about its mean.
% COLORMENU   Add a color map menu to the current figure (variation of standard routine).
% CROSSVAL    Cross validation for Non-parametric discriminant analysis.
% DENS3D      Density plots of 3D data.
% DENSITY     Smooth density plot.
% DISCANAL    Non-parametric discriminant analysis.
% DPLOTS      Density plots of 2D data based on simple box counting.
% GRAD2KN     Gradient of bi-variate normal kernel.
% KB_INT      Evaluates x^l*K(x) for the Bi-weight kernel.
% KDINT2      Calculate kde height using linear interpolation.
% KN_INT      Evaluates x^l*K(x) for the Normal kernel.
% MVKDEST     Multivariate Kernel Density Estimator.
% NDATA       Normalise a data-set.
%
% Testing for normality:
%
% NTEST1      Test of uni-variate normality.
% NTEST2      Test of bi-variate normality.
% NTEST3      Test of tri-variate normality.
%
% Optimization of KDEs:
%
% BUMP1       1D local maximisation by function height.
% BUMP2       2D local maximisation by function height.
% FZERO1      Find a zero of a function of one variable (variant of standard routine). 
% INVKDE1     Reciprocal of kdest1d for maximisation routines.
% INVKDE2     Reciprocal of kdest2d for maximisation routines.
% KDOPT2D     Numerical optimization (Steepest descent method) for KDE's.
% KDSLOPE     Numerical derivative of a KDE.