1 #ifndef DENSITYESTIMATOR_HH
2 #define DENSITYESTIMATOR_HH
17 #include "OptimalBinning.hh"
18 #include "KNearestNeighbours.hh"
19 #include "LocalReachability.hh"
22 #include "ProbabilityContour.hh"
44 const std::string algo=
"bin",
46 const double norm=1.);
82 double Evaluate(
const std::vector<double>& v)
const;
88 double Evaluate(
const double& v)
const;
94 double Evaluate(
const double* v)
const;
108 const std::string method=
"mc",
109 const bool draw=
true,
110 std::vector<double> lower=std::vector<double>(),
111 std::vector<double> upper=std::vector<double>(),
112 const size_t nsamples=1e6);
145 TH3F*
Contour3D(
size_t idx=0,
size_t idy=1,
size_t idz=2)
const
152 const std::vector<std::vector<double>>&
GetPoints()
const
168 const std::vector<double> lower=std::vector<double>(),
169 const std::vector<double> upper=std::vector<double>())
const;
175 std::vector<TPolyLine*>
Meshing()
const;
193 TGraph*
Graph(
double xmin,
double xmax,
194 size_t idx=0, std::vector<double> x=std::vector<double>())
const;
206 TH2F*
Graph2D(
double xmin,
double xmax,
double ymin,
double ymax,
207 size_t idx=0,
size_t idy=1, std::vector<double> x=std::vector<double>())
const;
220 void Draw(
double xmin,
double xmax,
double ymin=0,
double ymax=0,
const std::string opt=
"",
221 int idx=0,
int idy=1, std::vector<double> x=std::vector<double>())
const;
234 void Print(
double xmin,
double xmax,
double ymin=0,
double ymax=0,
const std::string opt=
"",
235 int idx=0,
int idy=1, std::vector<double> x=std::vector<double>())
const;
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.
Definition: DensityEstimator.cc:162
std::string _algo
Density estimation algorithm.
Definition: DensityEstimator.hh:241
PBATDE _pbatde
PBA tesselation density estimator.
Definition: DensityEstimator.hh:247
double operator()(const double &v) const
Overloaded function operator, calls Evaluate.
Definition: DensityEstimator.hh:64
double _norm
Norm. factor (truncated parent)
Definition: DensityEstimator.hh:250
bool _ex
Extrapolation switch.
Definition: DensityEstimator.hh:249
size_t _dim
Dimension of the space.
Definition: DensityEstimator.hh:239
double ContourVolumeError()
Returns the uncertainty on the uncertainty on the reconstructed contour volume.
Definition: DensityEstimator.cc:283
Computes the Optimal Binning density estimator of a set of points.
Definition: OptimalBinning.hh:28
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.
Definition: DensityEstimator.cc:398
TDE _tde
Tesselation density estimator.
Definition: DensityEstimator.hh:246
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.
Definition: DensityEstimator.cc:309
double operator()(const double *v) const
Overloaded function operator, calls Evaluate.
Definition: DensityEstimator.hh:70
LocalReachability _lrd
LRD density estimator.
Definition: DensityEstimator.hh:245
DensityEstimator()
Default constructor, initilizes everything to 0.
Definition: DensityEstimator.cc:3
Data structure for a grid of points and their mapping onto a scalar field.
Definition: Grid.hh:19
Set of functions that compose the Geometry package.
Computes the non parametric density estimator of a set of points.
Definition: DensityEstimator.hh:31
KNearestNeighbours _knn
kNN density estimator
Definition: DensityEstimator.hh:244
TH3F * Contour3D(size_t idx=0, size_t idy=1, size_t idz=2) const
Returns the requested 3D contour on a function.
Definition: DensityEstimator.hh:145
const size_t & GetDimension() const
Returns the dimension of the space in which the estimator is constructed.
Definition: DensityEstimator.hh:149
std::string _name
Name of the density estimator.
Definition: DensityEstimator.hh:240
double operator()(const std::vector< double > &v) const
Overloaded function operator, calls Evaluate.
Definition: DensityEstimator.hh:58
Computes the Tesselation Density Estimator (TDE) of a set of points.
Definition: TDE.hh:22
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.
Definition: DensityEstimator.cc:445
TH3F * Contour3D(size_t idx=0, size_t idy=1, size_t idz=2) const
Returns the requested 2D contour on a function.
Definition: ProbabilityContour.cc:157
ProbabilityContour _prob
Stores the last requested contour.
Definition: DensityEstimator.hh:248
DensityEstimator & operator=(const DensityEstimator &de)
Equality operator.
Definition: DensityEstimator.cc:29
void SetName(const std::string &name)
Sets the name of the density estimator.
Definition: DensityEstimator.hh:184
TH1F * Contour1D(size_t idx=0) const
Returns segments that represent the 1D contour on a function.
Definition: ProbabilityContour.cc:70
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.
Definition: DensityEstimator.cc:369
void Initialize()
Initializes the requested density estimator.
Definition: DensityEstimator.cc:51
TH2F * Contour2D(size_t idx=0, size_t idy=1) const
Returns the requested 2D contour on a function.
Definition: ProbabilityContour.cc:114
OptimalBinning _ob
Optimal binning density estimator.
Definition: DensityEstimator.hh:243
Computes the Local Reachability density estimator of a set of points.
Definition: LocalReachability.hh:24
Computes the k-Nearest Neighbour (kNN) density estimator of a set of points.
Definition: KNearestNeighbours.hh:27
TH1F * Contour1D(size_t idx=0) const
Returns segments that represent the 1D contour on a function.
Definition: DensityEstimator.hh:126
Reconstructs the optimal α-contour of a Probability Density Function.
Definition: ProbabilityContour.hh:31
double Evaluate(const std::vector< double > &v) const
Performs the density estimation at an n-point v.
Definition: DensityEstimator.cc:121
std::vector< std::vector< double > > _points
Array of input points.
Definition: DensityEstimator.hh:242
const std::vector< std::vector< double > > & GetCVTpoints() const
Returns the CVT points of the space.
Definition: DensityEstimator.hh:156
std::vector< TPolyLine * > Meshing() const
Returns the meshing used to build the interpolation as polygons.
Definition: DensityEstimator.cc:342
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)
Definition: DensityEstimator.cc:430
TH2F * Contour2D(size_t idx=0, size_t idy=1) const
Returns the requested 2D contour on a function.
Definition: DensityEstimator.hh:135
const std::vector< std::vector< double > > & GetPointArray() const
Returns the array of points on which the triangulation is constructed.
Definition: TDE.hh:90
const std::vector< std::vector< double > > & GetPoints() const
Returns the points on which the DensityEstimator is constructed.
Definition: DensityEstimator.hh:152
~DensityEstimator()
Destructor.
Definition: DensityEstimator.cc:49
std::vector< TPolyLine * > Tesselation() const
Returns the tesselation of the space as polygons.
Definition: DensityEstimator.cc:358
Computes the Penalised Bootstrap Aggregate Tesselation Density Estimator (PBATDE) of a set of points...
Definition: PBATDE.hh:31