1 #ifndef KNEARESTNEIGHBOURS_HH
2 #define KNEARESTNEIGHBOURS_HH
14 #include <nanoflann.hpp>
15 #include "KDTreeVectorOfVectorsAdaptor.h"
21 typedef KDTreeVectorOfVectorsAdaptor<std::vector<std::vector<double>>> KDTree;
75 double Evaluate(
const std::vector<double>& v)
const;
81 double Evaluate(
const double& v)
const;
87 double Evaluate(
const double* v)
const;
93 double Distance(
const std::vector<double>& point)
const;
96 double Volume(
const std::vector<double>& point)
const;
99 double Density(
const std::vector<double>& point)
const;
double Evaluate(const std::vector< double > &v) const
Performs the density estimation at an n-point v.
Definition: KNearestNeighbours.cc:108
const size_t & GetDimension() const
Returns the dimension of the space.
Definition: KNearestNeighbours.hh:90
void Initialize()
Checks that the input is sensible.
Definition: KNearestNeighbours.cc:54
~KNearestNeighbours()
Destructor.
Definition: KNearestNeighbours.cc:49
KNearestNeighbours & operator=(const KNearestNeighbours &knn)
Equality operator.
Definition: KNearestNeighbours.cc:25
TMatrixD _metric
Metric of the points.
Definition: KNearestNeighbours.hh:108
Set of functions that compose the Statistics package.
double Density(const std::vector< double > &point) const
Returns the density of points in the hypersphere that contains the k NN of a point.
Definition: KNearestNeighbours.cc:155
KNearestNeighbours()
Default constructor, initilizes everything to 0.
Definition: KNearestNeighbours.cc:3
double Volume(const std::vector< double > &point) const
Returns the volume of the hypersphere that contains the k NN of a point.
Definition: KNearestNeighbours.cc:147
size_t _dim
Dimension of the space.
Definition: KNearestNeighbours.hh:103
double operator()(const std::vector< double > &v) const
Overloaded function operator, calls Evaluate.
Definition: KNearestNeighbours.hh:51
KDTree * _kdtree
k-d Tree of the points to find NNs
Definition: KNearestNeighbours.hh:106
size_t _k
Number of neighbours to consider.
Definition: KNearestNeighbours.hh:105
Computes the k-Nearest Neighbour (kNN) density estimator of a set of points.
Definition: KNearestNeighbours.hh:27
double _scale
Scaling factor of the metric.
Definition: KNearestNeighbours.hh:109
double Distance(const std::vector< double > &point) const
Returns the distance to the k^th NN of a point.
Definition: KNearestNeighbours.cc:134
bool _rotate
Whether or not a rotated metric is used.
Definition: KNearestNeighbours.hh:107
double operator()(const double &v) const
Overloaded function operator, calls Evaluate.
Definition: KNearestNeighbours.hh:57
std::vector< std::vector< double > > _points
Cloud of points.
Definition: KNearestNeighbours.hh:104
double operator()(const double *v) const
Overloaded function operator, calls Evaluate.
Definition: KNearestNeighbours.hh:63