Portability | portable |
---|---|
Stability | experimental |
Maintainer | [email protected] |
Statistics.KernelDensity
Contents
Description
Kernel density estimation code, providing non-parametric ways to estimate the probability density function of a sample.
- epanechnikovPDF :: Int -> Sample -> (Points, UArr Double)
- gaussianPDF :: Int -> Sample -> (Points, UArr Double)
- newtype Points = Points {
- fromPoints :: UArr Double
- choosePoints :: Int -> Double -> Sample -> Points
- type Bandwidth = Double
- bandwidth :: (Double -> Bandwidth) -> Sample -> Bandwidth
- epanechnikovBW :: Double -> Bandwidth
- gaussianBW :: Double -> Bandwidth
- type Kernel = Double -> Double -> Double -> Double -> Double
- epanechnikovKernel :: Kernel
- gaussianKernel :: Kernel
- estimatePDF :: Kernel -> Bandwidth -> Sample -> Points -> UArr Double
- simplePDF :: (Double -> Double) -> Kernel -> Double -> Int -> Sample -> (Points, UArr Double)
Simple entry points
Simple Epanechnikov kernel density estimator. Returns the uniformly spaced points from the sample range at which the density function was estimated, and the estimates at those points.
Simple Gaussian kernel density estimator. Returns the uniformly spaced points from the sample range at which the density function was estimated, and the estimates at those points.
Building blocks
Choosing points from a sample
Points from the range of a Sample
.
Constructors
Points | |
Fields
|
Arguments
:: Int | Number of points to select, n |
-> Double | Sample bandwidth, h |
-> Sample | Input data |
-> Points |
Choose a uniform range of points at which to estimate a sample's probability density function.
If you are using a Gaussian kernel, multiply the sample's bandwidth by 3 before passing it to this function.
If this function is passed an empty vector, it returns values of positive and negative infinity.
Bandwidth estimation
bandwidth :: (Double -> Bandwidth) -> Sample -> BandwidthSource
Compute the optimal bandwidth from the observed data for the given kernel.
epanechnikovBW :: Double -> BandwidthSource
Bandwidth estimator for an Epanechnikov kernel.
gaussianBW :: Double -> BandwidthSource
Bandwidth estimator for a Gaussian kernel.
Kernels
type Kernel = Double -> Double -> Double -> Double -> DoubleSource
The convolution kernel. Its parameters are as follows:
- Scaling factor, 1/nh
- Bandwidth, h
- A point at which to sample the input, p
- One sample value, v
epanechnikovKernel :: KernelSource
Epanechnikov kernel for probability density function estimation.
gaussianKernel :: KernelSource
Gaussian kernel for probability density function estimation.
Low-level estimation
Arguments
:: Kernel | Kernel function |
-> Bandwidth | Bandwidth, h |
-> Sample | Sample data |
-> Points | Points at which to estimate |
-> UArr Double |
Kernel density estimator, providing a non-parametric way of estimating the PDF of a random variable.
Arguments
:: (Double -> Double) | Bandwidth function |
-> Kernel | Kernel function |
-> Double | Bandwidth scaling factor (3 for a Gaussian kernel, 1 for all others) |
-> Int | Number of points at which to estimate |
-> Sample | Sample data |
-> (Points, UArr Double) |
A helper for creating a simple kernel density estimation function with automatically chosen bandwidth and estimation points.