Canopy  1.0
The header-only random forests library
Public Member Functions | Protected Attributes | Friends | List of all members
canopy::vonMisesDistribution Class Reference

A distribution that defines the probabilities over a circular-valued label. More...

#include <vonMisesDistribution.hpp>

Public Member Functions

 vonMisesDistribution ()
 Basic constructor.
 
void initialise ()
 Initialise the distribution before fitting.
 
template<class TLabelIterator , class TIdIterator >
void fit (TLabelIterator first_label, const TLabelIterator last_label, TIdIterator)
 Fit the distribution to a set of labels. More...
 
template<class TId >
float pdf (const float x, const TId) const
 Returns the probability of a particular label. More...
 
float pdf (const float x) const
 Returns the probability of a particular label. More...
 
void printOut (std::ofstream &stream) const
 Prints the defining parameters of the distribution to an output filestream. More...
 
void readIn (std::ifstream &stream)
 Reads the defining parameters of the distribution from a filestream. More...
 
float entropy () const
 Return the (differential) entropy of the distribution.
 
template<class TId >
void combineWith (const vonMisesDistribution &dist, const TId)
 Combine this distribution with a second by summing the probability values, without normalisation. More...
 
void normalise ()
 Normalise the distribution to ensure it is valid. More...
 
void reset ()
 Reset method. More...
 
float getMu () const
 Get the mu parameter. More...
 
float getKappa () const
 Get the kappa parameter. More...
 

Protected Attributes

float mu
 The distribution's circular mean parameter.
 
float kappa
 The distribution's concentration parameter.
 
double S
 Sum of sines, used during fitting and combining distributions.
 
double C
 Sum of cosines, used during fitting and combining distributions.
 
float pdf_normaliser
 Pre-calculated normalisation constant of the pdf equation.
 

Friends

std::ofstream & operator<< (std::ofstream &stream, const vonMisesDistribution &dist)
 Allows the distribution to be written to a file via the streaming operator '<<'.
 
std::ifstream & operator>> (std::ifstream &stream, vonMisesDistribution &dist)
 Allows the distribution to be written to read from a file via the streaming operator '>>'.
 

Detailed Description

A distribution that defines the probabilities over a circular-valued label.

The von Mises distribution has the characteristics of both a node distribution and an output distribution, and is used as the node and output distribution for the circularRegressor

Member Function Documentation

template<class TId >
void canopy::vonMisesDistribution::combineWith ( const vonMisesDistribution dist,
const TId   
)
inline

Combine this distribution with a second by summing the probability values, without normalisation.

This method is used by the randomForestBase methods to aggregate the distributions in several leaf nodes into one output distribution. In this case, the sensor fusion approach of Stienne 2011 is used.

Template Parameters
TIdThe type of the IDs of the data points. The ID is unused but required for compatibility with randomForestBase.
Parameters
distThe distribution that this distribution should be combined with.
-The second parameter is unused and but required for compatibility with randomForestBase
template<class TLabelIterator , class TIdIterator >
void canopy::vonMisesDistribution::fit ( TLabelIterator  first_label,
const TLabelIterator  last_label,
TIdIterator   
)
inline

Fit the distribution to a set of labels.

Fits the von Mises distribution to the set of labels between first_label and last label.

Template Parameters
TLabelIteratorThe type of the iterator used to access the labels of the training data. Must be a forward iterator that dereferences to numerical floating point type.
TIdIteratorThe type of the iterator used to access the IDs of the data points. The ID is unused but required for compatibility with randomForestBase.
Parameters
first_labelIterator to the first label
last_labelIterator to the last label
-The third parameter is unused but required for compatibility with randomForestBase
float canopy::vonMisesDistribution::getKappa ( ) const
inline

Get the kappa parameter.

Returns
Kappa, the concentration parameter of the distribution
float canopy::vonMisesDistribution::getMu ( ) const
inline

Get the mu parameter.

Returns
Mu, the circular mean parameter of the distribution
void canopy::vonMisesDistribution::normalise ( )
inline

Normalise the distribution to ensure it is valid.

This may be used after several combineWith() operations to ensure that the resulting distribution represents a valid probability distribution

template<class TId >
float canopy::vonMisesDistribution::pdf ( const float  x,
const TId   
) const
inline

Returns the probability of a particular label.

This is the version used by the randomForestBase methods.

Template Parameters
TIdThe type of the IDs of the data points. The ID is unused but required for compatibility with randomForestBase.
Parameters
xThe angular label (in radians) of for which the probability is sought
-The second parameter is unused and but required for compatibility with randomForestBase
float canopy::vonMisesDistribution::pdf ( const float  x) const
inline

Returns the probability of a particular label.

This overloaded version does not require the ID and is intended for use by user code.

Template Parameters
TIdThe type of the IDs of the data points. The ID is unused but required for compatibility with randomForestBase.
Parameters
xThe angular label (in radians) of for which the probability is sought
void canopy::vonMisesDistribution::printOut ( std::ofstream &  stream) const
inline

Prints the defining parameters of the distribution to an output filestream.

Parameters
streamThe stream to which the parameters (mu and kappa) are printed
void canopy::vonMisesDistribution::readIn ( std::ifstream &  stream)
inline

Reads the defining parameters of the distribution from a filestream.

Parameters
streamThe stream from which the parameters (mu, kappa) are to be read
void canopy::vonMisesDistribution::reset ( )
inline

Reset method.

Use this when using the class as an output distribution to create a new blank distribution before combining with new node distributions


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