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
KNearestNeighbours Class Reference

Computes the k-Nearest Neighbour (kNN) density estimator of a set of points. More...

#include <KNearestNeighbours.hh>

Public Member Functions

 KNearestNeighbours ()
 Default constructor, initilizes everything to 0. More...
 
 KNearestNeighbours (const std::vector< std::vector< double >> &points, const size_t k, bool rotate=false)
 Normal constructor, fills the cloud with the provided points. More...
 
 KNearestNeighbours (const KNearestNeighbours &knn)
 Copy constructor. More...
 
KNearestNeighbours & operator= (const KNearestNeighbours &knn)
 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...
 
 ~KNearestNeighbours ()
 Destructor. More...
 
void Initialize ()
 Checks that the input is sensible. 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...
 
const size_t & GetDimension () const
 Returns the dimension of the space. More...
 
double Distance (const std::vector< double > &point) const
 Returns the distance to the k^th NN of a point. More...
 
double Volume (const std::vector< double > &point) const
 Returns the volume of the hypersphere that contains the k NN of a point. More...
 
double Density (const std::vector< double > &point) const
 Returns the density of points in the hypersphere that contains the k NN of a point. More...
 

Private Attributes

size_t _dim
 Dimension of the space. More...
 
std::vector< std::vector
< double > > 
_points
 Cloud of points. More...
 
size_t _k
 Number of neighbours to consider. More...
 
KDTree * _kdtree
 k-d Tree of the points to find NNs More...
 
bool _rotate
 Whether or not a rotated metric is used. More...
 
TMatrixD _metric
 Metric of the points. More...
 
double _scale
 Scaling factor of the metric. More...
 

Detailed Description

Computes the k-Nearest Neighbour (kNN) density estimator of a set of points.

Computes the volume and density of the hypersphere containing the k nearest neighbours.

Constructor & Destructor Documentation

KNearestNeighbours::KNearestNeighbours ( )

Default constructor, initilizes everything to 0.

KNearestNeighbours::KNearestNeighbours ( const std::vector< std::vector< double >> &  points,
const size_t  k,
bool  rotate = false 
)

Normal constructor, fills the cloud with the provided points.

Parameters
pointsN points to fill the cloud with
kNumber of neighbours to probe
rotateIf true, use the metric of the covariance matrix
KNearestNeighbours::KNearestNeighbours ( const KNearestNeighbours &  knn)

Copy constructor.

KNearestNeighbours::~KNearestNeighbours ( )

Destructor.

Member Function Documentation

double KNearestNeighbours::Density ( const std::vector< double > &  point) const

Returns the density of points in the hypersphere that contains the k NN of a point.

double KNearestNeighbours::Distance ( const std::vector< double > &  point) const

Returns the distance to the k^th NN of a point.

double KNearestNeighbours::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 KNearestNeighbours::Evaluate ( const double &  v) const

Performs the density estimation at an n-point v.

Parameters
vOne dimensional value of the point
double KNearestNeighbours::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 size_t& KNearestNeighbours::GetDimension ( ) const
inline

Returns the dimension of the space.

void KNearestNeighbours::Initialize ( )

Checks that the input is sensible.

double KNearestNeighbours::operator() ( const std::vector< double > &  v) const
inline

Overloaded function operator, calls Evaluate.

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

Overloaded function operator, calls Evaluate.

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

Overloaded function operator, calls Evaluate.

Parameters
vPointer to an array of coordinates
KNearestNeighbours & KNearestNeighbours::operator= ( const KNearestNeighbours &  knn)

Equality operator.

double KNearestNeighbours::Volume ( const std::vector< double > &  point) const

Returns the volume of the hypersphere that contains the k NN of a point.

Field Documentation

size_t KNearestNeighbours::_dim
private

Dimension of the space.

size_t KNearestNeighbours::_k
private

Number of neighbours to consider.

KDTree* KNearestNeighbours::_kdtree
private

k-d Tree of the points to find NNs

TMatrixD KNearestNeighbours::_metric
private

Metric of the points.

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

Cloud of points.

bool KNearestNeighbours::_rotate
private

Whether or not a rotated metric is used.

double KNearestNeighbours::_scale
private

Scaling factor of the metric.


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