bpp-core3  3.0.0
bpp::AdaptiveKernelDensityEstimation Class Reference

Density estimation using the adaptive kernel method. More...

#include <Bpp/Numeric/AdaptiveKernelDensityEstimation.h>

+ Collaboration diagram for bpp::AdaptiveKernelDensityEstimation:

Public Member Functions

 AdaptiveKernelDensityEstimation (const Matrix< double > &x, double gamma=0.5)
 Build a new AdaptiveKernelDensityEstimation object. More...
 
virtual ~AdaptiveKernelDensityEstimation ()
 
double kDensity (const std::vector< double > &x)
 

Private Member Functions

void init_ ()
 
void sampleMean_ (const Matrix< double > &x, std::vector< double > &mean)
 
double kernel_ (const Matrix< double > &x)
 The kernel function. More...
 

Private Attributes

RowMatrix< double > x_
 
size_t n_
 
size_t r_
 
RowMatrix< double > covar_
 
RowMatrix< double > invSqrtCovar_
 
std::vector< double > xMean_
 
double gamma_
 
double c1_
 
std::vector< double > c2_
 
double h_
 
std::vector< double > lambda_
 
std::vector< double > pilot_
 

Detailed Description

Density estimation using the adaptive kernel method.

For now this implementation is quite restricted, more options may be implemented later...

The source for this method can be found is the appendix of the following paper: Ivan Kojadinovic, Computational Statistics and Data Analaysis (2004), 46:269-294

Author
Julien Dutheil

Definition at line 23 of file AdaptiveKernelDensityEstimation.h.

Constructor & Destructor Documentation

◆ AdaptiveKernelDensityEstimation()

bpp::AdaptiveKernelDensityEstimation::AdaptiveKernelDensityEstimation ( const Matrix< double > &  x,
double  gamma = 0.5 
)
inline

Build a new AdaptiveKernelDensityEstimation object.

Parameters
xA mtrix contianing the sample point, one point per column. The row of the matrix are the dimension of the sampled vectors, wich can be 1.
gammaControls the influence of the pilot density. A value of 0 maximizes the impact of the pilot density, and hence corresponds to the standard Kernel Density Estimation method. A value in ]0,1] allows a local adjustement of the bandwith. The 0.5 value is commonly used.

Definition at line 49 of file AdaptiveKernelDensityEstimation.h.

References init_().

◆ ~AdaptiveKernelDensityEstimation()

virtual bpp::AdaptiveKernelDensityEstimation::~AdaptiveKernelDensityEstimation ( )
inlinevirtual

Definition at line 57 of file AdaptiveKernelDensityEstimation.h.

References init_(), kDensity(), kernel_(), and sampleMean_().

Member Function Documentation

◆ init_()

◆ kDensity()

double AdaptiveKernelDensityEstimation::kDensity ( const std::vector< double > &  x)
Returns
The value of the estimated density for point x.
Parameters
xThe point where to estimate the density.

Definition at line 104 of file AdaptiveKernelDensityEstimation.cpp.

References bpp::MatrixTools::mult(), and bpp::MatrixTools::scale().

Referenced by bpp::VectorTools::miContinuous(), bpp::VectorTools::shannonContinuous(), and ~AdaptiveKernelDensityEstimation().

◆ kernel_()

double AdaptiveKernelDensityEstimation::kernel_ ( const Matrix< double > &  x)
private

The kernel function.

For now a standard normal density is used, further options may be added later, including the possibility to use your own function.

Parameters
xThe point for which to compute the density, as a matrix with 1 column and r_ rows.
Returns
The value of the kernel function at the corresponding point.

Definition at line 91 of file AdaptiveKernelDensityEstimation.cpp.

References bpp::NumConstants::PI().

Referenced by ~AdaptiveKernelDensityEstimation().

◆ sampleMean_()

void AdaptiveKernelDensityEstimation::sampleMean_ ( const Matrix< double > &  x,
std::vector< double > &  mean 
)
private

Member Data Documentation

◆ c1_

double bpp::AdaptiveKernelDensityEstimation::c1_
private

Definition at line 33 of file AdaptiveKernelDensityEstimation.h.

◆ c2_

std::vector<double> bpp::AdaptiveKernelDensityEstimation::c2_
private

Definition at line 34 of file AdaptiveKernelDensityEstimation.h.

◆ covar_

RowMatrix<double> bpp::AdaptiveKernelDensityEstimation::covar_
private

Definition at line 29 of file AdaptiveKernelDensityEstimation.h.

◆ gamma_

double bpp::AdaptiveKernelDensityEstimation::gamma_
private

Definition at line 32 of file AdaptiveKernelDensityEstimation.h.

◆ h_

double bpp::AdaptiveKernelDensityEstimation::h_
private

Definition at line 35 of file AdaptiveKernelDensityEstimation.h.

◆ invSqrtCovar_

RowMatrix<double> bpp::AdaptiveKernelDensityEstimation::invSqrtCovar_
private

Definition at line 30 of file AdaptiveKernelDensityEstimation.h.

◆ lambda_

std::vector<double> bpp::AdaptiveKernelDensityEstimation::lambda_
private

Definition at line 36 of file AdaptiveKernelDensityEstimation.h.

◆ n_

size_t bpp::AdaptiveKernelDensityEstimation::n_
private

Definition at line 27 of file AdaptiveKernelDensityEstimation.h.

◆ pilot_

std::vector<double> bpp::AdaptiveKernelDensityEstimation::pilot_
private

Definition at line 37 of file AdaptiveKernelDensityEstimation.h.

◆ r_

size_t bpp::AdaptiveKernelDensityEstimation::r_
private

Definition at line 28 of file AdaptiveKernelDensityEstimation.h.

◆ x_

RowMatrix<double> bpp::AdaptiveKernelDensityEstimation::x_
private

Definition at line 26 of file AdaptiveKernelDensityEstimation.h.

◆ xMean_

std::vector<double> bpp::AdaptiveKernelDensityEstimation::xMean_
private

Definition at line 31 of file AdaptiveKernelDensityEstimation.h.


The documentation for this class was generated from the following files: