OpenMS
Loading...
Searching...
No Matches
KernelDensityEstimation Struct Reference

Kernel Density Estimation utilities using FFT-based methods. More...

#include <OpenMS/MATH/STATISTICS/KernelDensityEstimation.h>

Static Public Member Functions

static double bwNrd0 (const std::vector< double > &x)
 Bandwidth selector using the "nrd0" rule-of-thumb for kernel density estimation.
 
static std::vector< double > linBin (const std::vector< double > &x, double xmin, double xmax, std::size_t nbins, const std::vector< double > *weights)
 Linear binning of data onto an equally-spaced grid.
 
static std::vector< double > linBin (const std::vector< double > &x, double xmin, double xmax, std::size_t nbins)
 Convenience overload that uses uniform weights.
 
static std::vector< double > forRt (const std::vector< double > &X, std::size_t M=0)
 Forward FFT of real-valued data using Munro-packed format.
 
static std::vector< double > revRt (const std::vector< double > &Xp, std::size_t M=0)
 Inverse FFT of Munro-packed data to real-valued output.
 
static std::vector< double > silvermanKernelFFT (double bw, std::size_t M, double RANGE)
 Compute the FFT of a Gaussian kernel in Munro-packed format.
 
static std::pair< std::vector< double >, std::vector< double > > gridKdeFFT (const std::vector< double > &x, double bw, std::size_t gridsize=512, double cut=3.0)
 Fast kernel density estimation on a regular grid using FFT convolution.
 
static std::vector< double > kdeFFTEval (const std::vector< double > &x, double bw, std::size_t gridsize=512, double cut=3.0)
 Evaluate kernel density estimates at the data points themselves.
 

Detailed Description

Kernel Density Estimation utilities using FFT-based methods.

This class provides efficient kernel density estimation using Fast Fourier Transform (FFT) based convolution, following the Silverman (1982) algorithm as implemented in Python's statsmodels package.

The FFT-based approach scales as O(n + M*log(M)) compared to O(n*M) for direct evaluation, making it highly efficient for large datasets or fine grids.

Key features:

  • Automatic bandwidth selection using Silverman's rule-of-thumb
  • FFT-based convolution for fast computation
  • Linear binning for grid-based estimation
  • Munro-packed real FFT for memory efficiency

References: Silverman BW. (1982) "Algorithm AS 176: Kernel density estimation using the Fast Fourier Transform." J. R. Statist. Soc. C 31(1):93-99. DOI: 10.2307/2347084

Member Function Documentation

◆ linBin()

static std::vector< double > linBin ( const std::vector< double > &  x,
double  xmin,
double  xmax,
std::size_t  nbins 
)
static

Convenience overload that uses uniform weights.