SynAPSE  0.6.0
Synergistic Analysis of Phase Space Evolution
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
Public Member Functions | Private Attributes
DensityEstimator Class Reference

Computes the non parametric density estimator of a set of points. More...

#include <DensityEstimator.hh>

Public Member Functions

 DensityEstimator ()
 Default constructor, initilizes everything to 0. More...
 
 DensityEstimator (const std::vector< std::vector< double >> &points, const std::string algo="bin", const bool ex=true, const double norm=1.)
 Cloud constructor, sets vector of points on which to perform the density estimation. More...
 
 DensityEstimator (const DensityEstimator &de)
 Copy constructor. More...
 
DensityEstimator & operator= (const DensityEstimator &de)
 Equality operator. More...
 
double operator() (const std::vector< double > &v) const
 Overloaded function operator, calls Evaluate. More...
 
double operator() (const double &v) const
 Overloaded function operator, calls Evaluate. More...
 
double operator() (const double *v) const
 Overloaded function operator, calls Evaluate. More...
 
 ~DensityEstimator ()
 Destructor. More...
 
void Initialize ()
 Initializes the requested density estimator. More...
 
double Evaluate (const std::vector< double > &v) const
 Performs the density estimation at an n-point v. More...
 
double Evaluate (const double &v) const
 Performs the density estimation at an n-point v. More...
 
double Evaluate (const double *v) const
 Performs the density estimation at an n-point v. More...
 
double ContourVolume (double alpha, const std::string method="mc", const bool draw=true, std::vector< double > lower=std::vector< double >(), std::vector< double > upper=std::vector< double >(), const size_t nsamples=1e6)
 Returns the volume of an alpha contour of the probability density function. More...
 
double ContourVolumeError ()
 Returns the uncertainty on the uncertainty on the reconstructed contour volume. More...
 
TH1F * Contour1D (size_t idx=0) const
 Returns segments that represent the 1D contour on a function. More...
 
TH2F * Contour2D (size_t idx=0, size_t idy=1) const
 Returns the requested 2D contour on a function. More...
 
TH3F * Contour3D (size_t idx=0, size_t idy=1, size_t idz=2) const
 Returns the requested 3D contour on a function. More...
 
const size_t & GetDimension () const
 Returns the dimension of the space in which the estimator is constructed. More...
 
const std::vector< std::vector
< double > > & 
GetPoints () const
 Returns the points on which the DensityEstimator is constructed. More...
 
const std::vector< std::vector
< double > > & 
GetCVTpoints () const
 Returns the CVT points of the space. More...
 
Grid GetGrid (const std::vector< size_t > &number, const std::vector< double > lower=std::vector< double >(), const std::vector< double > upper=std::vector< double >()) const
 Returns a grid built on the DensityEstimator, which is defined everywhere. More...
 
std::vector< TPolyLine * > Meshing () const
 Returns the meshing used to build the interpolation as polygons. More...
 
std::vector< TPolyLine * > Tesselation () const
 Returns the tesselation of the space as polygons. More...
 
void SetName (const std::string &name)
 Sets the name of the density estimator. More...
 
TGraph * Graph (double xmin, double xmax, size_t idx=0, std::vector< double > x=std::vector< double >()) const
 Returns a 1D graph of the estimator in the requested axis. More...
 
TH2F * Graph2D (double xmin, double xmax, double ymin, double ymax, size_t idx=0, size_t idy=1, std::vector< double > x=std::vector< double >()) const
 Returns a 2D histogram of the estimator in the requested axis. More...
 
void Draw (double xmin, double xmax, double ymin=0, double ymax=0, const std::string opt="", int idx=0, int idy=1, std::vector< double > x=std::vector< double >()) const
 Draws the estimator on whichever TCanvas is currently being used (ROOT) More...
 
void Print (double xmin, double xmax, double ymin=0, double ymax=0, const std::string opt="", int idx=0, int idy=1, std::vector< double > x=std::vector< double >()) const
 Creates a canvas, draws the estimator on it and save it to a file. More...
 

Private Attributes

size_t _dim
 Dimension of the space. More...
 
std::string _name
 Name of the density estimator. More...
 
std::string _algo
 Density estimation algorithm. More...
 
std::vector< std::vector
< double > > 
_points
 Array of input points. More...
 
OptimalBinning _ob
 Optimal binning density estimator. More...
 
KNearestNeighbours _knn
 kNN density estimator More...
 
LocalReachability _lrd
 LRD density estimator. More...
 
TDE _tde
 Tesselation density estimator. More...
 
PBATDE _pbatde
 PBA tesselation density estimator. More...
 
ProbabilityContour _prob
 Stores the last requested contour. More...
 
bool _ex
 Extrapolation switch. More...
 
double _norm
 Norm. factor (truncated parent) More...
 

Detailed Description

Computes the non parametric density estimator of a set of points.

Builds a non parametric density estimator based on a training set of points in n dimensions, sampled from the true parent distribution to estimate.

This class encompasses a broad array of non parametric methods to produce an estimate.

Constructor & Destructor Documentation

DensityEstimator::DensityEstimator ( )

Default constructor, initilizes everything to 0.

DensityEstimator::DensityEstimator ( const std::vector< std::vector< double >> &  points,
const std::string  algo = "bin",
const bool  ex = true,
const double  norm = 1. 
)

Cloud constructor, sets vector of points on which to perform the density estimation.

Parameters
pointsN points in a _dim dimensional space
algoDefines the density estimation algorithm to be used
exExtrapolate outside the outmost points if requested
normNormalization factor for the density (if truncated distribution)
DensityEstimator::DensityEstimator ( const DensityEstimator &  de)

Copy constructor.

DensityEstimator::~DensityEstimator ( )

Destructor.

Member Function Documentation

TH1F* DensityEstimator::Contour1D ( size_t  idx = 0) const
inline

Returns segments that represent the 1D contour on a function.

Parameters
idxID of the axis in which to plot the contour
Returns
Set of lines representing the contours
TH2F* DensityEstimator::Contour2D ( size_t  idx = 0,
size_t  idy = 1 
) const
inline

Returns the requested 2D contour on a function.

Parameters
idxID of the first axis in which to plot the contour
idyID of the second axis in which to plot the contour
Returns
Histogram at a certain contour level
TH3F* DensityEstimator::Contour3D ( size_t  idx = 0,
size_t  idy = 1,
size_t  idz = 2 
) const
inline

Returns the requested 3D contour on a function.

Parameters
idxID of the first axis in which to plot the contour
idyID of the second axis in which to plot the contour
idzID of the third axis in which to plot the contour
Returns
Isosurface of a TF3 at a certain contour level
double DensityEstimator::ContourVolume ( double  alpha,
const std::string  method = "mc",
const bool  draw = true,
std::vector< double >  lower = std::vector<double>(),
std::vector< double >  upper = std::vector<double>(),
const size_t  nsamples = 1e6 
)

Returns the volume of an alpha contour of the probability density function.

Parameters
alphaIntegrated probability to achieve
methodContour volume calculation method
drawCreates a grid to be able to draw the contour if requested
lowerLower bounds of the bounding box in each dimension
upperUpper bounds of the bounding box in each dimension
nsamplesNumber of samples to produce for the MC estimate
Returns
Volume of the alpha contour
double DensityEstimator::ContourVolumeError ( )

Returns the uncertainty on the uncertainty on the reconstructed contour volume.

Returns
Contour volume uncertainty
void DensityEstimator::Draw ( double  xmin,
double  xmax,
double  ymin = 0,
double  ymax = 0,
const std::string  opt = "",
int  idx = 0,
int  idy = 1,
std::vector< double >  x = std::vector<double>() 
) const

Draws the estimator on whichever TCanvas is currently being used (ROOT)

Parameters
xminMinimum of the range of the first coordinate to plot
xmaxMaximum of the range of the first coordinate to plot
yminMinimum of the range of the second coordinate to plot
ymaxMaximum of the range of the second coordinate to plot
optDrawing options
idxID of the first coordinate to represent
idyID of the second coordinate to represent
xPoint that the projection intersects
double DensityEstimator::Evaluate ( const std::vector< double > &  v) const

Performs the density estimation at an n-point v.

Parameters
vVector of coordinates of the n-point
double DensityEstimator::Evaluate ( const double &  v) const

Performs the density estimation at an n-point v.

Parameters
vOne dimensional value of the point
double DensityEstimator::Evaluate ( const double *  v) const

Performs the density estimation at an n-point v.

Parameters
vPointer to an array of coordinates of the n-point
const std::vector<std::vector<double> >& DensityEstimator::GetCVTpoints ( ) const
inline

Returns the CVT points of the space.

const size_t& DensityEstimator::GetDimension ( ) const
inline

Returns the dimension of the space in which the estimator is constructed.

Grid DensityEstimator::GetGrid ( const std::vector< size_t > &  number,
const std::vector< double >  lower = std::vector<double>(),
const std::vector< double >  upper = std::vector<double>() 
) const

Returns a grid built on the DensityEstimator, which is defined everywhere.

Parameters
numberNumber of steps between min and max values
lowerLower bounds of the grid in each dimension
upperUpper bounds of the grid in each dimension
Returns
Grid evaluated with the density estimator
const std::vector<std::vector<double> >& DensityEstimator::GetPoints ( ) const
inline

Returns the points on which the DensityEstimator is constructed.

TGraph * DensityEstimator::Graph ( double  xmin,
double  xmax,
size_t  idx = 0,
std::vector< double >  x = std::vector<double>() 
) const

Returns a 1D graph of the estimator in the requested axis.

Parameters
xminMinimum of the range of the coordinate to plot
xmaxMaximum of the range of the coordinate to plot
idxID of the first coordinate to represent
xPoint that the projection intersects
TH2F * DensityEstimator::Graph2D ( double  xmin,
double  xmax,
double  ymin,
double  ymax,
size_t  idx = 0,
size_t  idy = 1,
std::vector< double >  x = std::vector<double>() 
) const

Returns a 2D histogram of the estimator in the requested axis.

Parameters
xminMinimum of the range of the first coordinate to plot
xmaxMaximum of the range of the first coordinate to plot
yminMinimum of the range of the second coordinate to plot
ymaxMaximum of the range of the second coordinate to plot
idxID of the first coordinate to represent
idyID of the second coordinate to represent
xPoint that the projection intersects
void DensityEstimator::Initialize ( )

Initializes the requested density estimator.

std::vector< TPolyLine * > DensityEstimator::Meshing ( ) const

Returns the meshing used to build the interpolation as polygons.

Returns
Meshing
double DensityEstimator::operator() ( const std::vector< double > &  v) const
inline

Overloaded function operator, calls Evaluate.

Parameters
vVector of coordinates
double DensityEstimator::operator() ( const double &  v) const
inline

Overloaded function operator, calls Evaluate.

Parameters
vOne dimensional value
double DensityEstimator::operator() ( const double *  v) const
inline

Overloaded function operator, calls Evaluate.

Parameters
vPointer to an array of coordinates
DensityEstimator & DensityEstimator::operator= ( const DensityEstimator &  de)

Equality operator.

void DensityEstimator::Print ( double  xmin,
double  xmax,
double  ymin = 0,
double  ymax = 0,
const std::string  opt = "",
int  idx = 0,
int  idy = 1,
std::vector< double >  x = std::vector<double>() 
) const

Creates a canvas, draws the estimator on it and save it to a file.

Parameters
xminMinimum of the range of the first coordinate to plot
xmaxMaximum of the range of the first coordinate to plot
yminMinimum of the range of the second coordinate to plot
ymaxMaximum of the range of the second coordinate to plot
optDrawing options
idxID of the first coordinate to represent
idyID of the second coordinate to represent
xPoint that the projection intersects
void DensityEstimator::SetName ( const std::string &  name)
inline

Sets the name of the density estimator.

std::vector< TPolyLine * > DensityEstimator::Tesselation ( ) const

Returns the tesselation of the space as polygons.

Returns
Tesselation

Field Documentation

std::string DensityEstimator::_algo
private

Density estimation algorithm.

size_t DensityEstimator::_dim
private

Dimension of the space.

bool DensityEstimator::_ex
private

Extrapolation switch.

KNearestNeighbours DensityEstimator::_knn
private

kNN density estimator

LocalReachability DensityEstimator::_lrd
private

LRD density estimator.

std::string DensityEstimator::_name
private

Name of the density estimator.

double DensityEstimator::_norm
private

Norm. factor (truncated parent)

OptimalBinning DensityEstimator::_ob
private

Optimal binning density estimator.

PBATDE DensityEstimator::_pbatde
private

PBA tesselation density estimator.

std::vector<std::vector<double> > DensityEstimator::_points
private

Array of input points.

ProbabilityContour DensityEstimator::_prob
private

Stores the last requested contour.

TDE DensityEstimator::_tde
private

Tesselation density estimator.


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