XMM - Probabilistic Models for Motion Recognition and Mapping

Public Types | Public Member Functions | List of all members
xmm::GaussianDistribution Class Reference

Multivariate Gaussian Distribution. More...

#include <xmmGaussianDistribution.hpp>

Inheritance diagram for xmm::GaussianDistribution:
[legend]
Collaboration diagram for xmm::GaussianDistribution:
[legend]

Public Types

enum  CovarianceMode { CovarianceMode::Full = 0, CovarianceMode::Diagonal = 1 }
 Covariance Mode. More...
 

Public Member Functions

 GaussianDistribution (bool bimodal=false, unsigned int dimension=1, unsigned int dimension_input=0, CovarianceMode covariance_mode=CovarianceMode::Full)
 Default Constructor. More...
 
 GaussianDistribution (GaussianDistribution const &src)
 Copy constructor. More...
 
 GaussianDistribution (Json::Value const &root)
 Constructor from Json Structure. More...
 
GaussianDistributionoperator= (GaussianDistribution const &src)
 Assignment. More...
 
Likelihood & Regression
double likelihood (const float *observation) const
 Get Likelihood of a data vector. More...
 
double likelihood_input (const float *observation_input) const
 Get Likelihood of a data vector for input modality. More...
 
double likelihood_bimodal (const float *observation_input, const float *observation_output) const
 Get Likelihood of a data vector for bimodal mode. More...
 
void regression (std::vector< float > const &observation_input, std::vector< float > &predicted_output) const
 Linear Regression using the Gaussian Distribution (covariance-based) More...
 
Utilities
void regularize (std::vector< double > regularization)
 Add offset to the diagonal of the covariance matrix. More...
 
void updateInverseCovariance ()
 Compute inverse covariance matrix. More...
 
Ellipse toEllipse (unsigned int dimension1, unsigned int dimension2)
 Compute the 68%?? Confidence Interval ellipse of the Gaussian. More...
 
void fromEllipse (Ellipse const &gaussian_ellipse, unsigned int dimension1, unsigned int dimension2)
 Sets the parameters of the Gaussian distribution according to the 68%?? Confidence Interval ellipse. More...
 
JSON I/O
Json::Value toJson () const
 Write the object to a JSON Structure. More...
 
void fromJson (Json::Value const &root)
 Read the object from a JSON Structure. More...
 
Python File I/O
void writeFile (char *fileName) const
 write method for python wrapping ('write' keyword forbidden, name has to be different) More...
 
void readFile (char *fileName)
 read method for python wrapping ('read' keyword forbidden, name has to be different) More...
 
std::string __str__ () const
 "print" method for python => returns the results of write method More...
 

Conversion & Extraction

Attribute< unsigned int > dimension
 Convert to bimodal distribution in place. More...
 
Attribute< unsigned int > dimension_input
 Input Dimension of the multivariate normal. More...
 
std::vector< double > mean
 Mean of the Gaussian Distribution. More...
 
Attribute< CovarianceModecovariance_mode
 Covariance Mode. More...
 
std::vector< double > covariance
 Covariance Matrix of the Gaussian Distribution. More...
 
std::vector< double > output_covariance
 Conditional Output Variance (updated when covariances matrices are inverted) More...
 
bool bimodal_
 Defines if regression parameters need to be computed. More...
 
double covariance_determinant_
 Determinant of the covariance matrix. More...
 
std::vector< double > inverse_covariance_
 Inverse covariance matrix. More...
 
double covariance_determinant_input_
 Determinant of the covariance matrix of the input modality. More...
 
std::vector< double > inverse_covariance_input_
 Inverse covariance matrix of the input modality. More...
 
void allocate ()
 Resize Mean and Covariance Vectors to appropriate dimension. More...
 
virtual void onAttributeChange (AttributeBase *attr_pointer)
 notification function called when a member attribute is changed More...
 
void updateOutputCovariance ()
 Compute the conditional variance vector of the output modality (conditioned over the input). More...
 

Detailed Description

Multivariate Gaussian Distribution.

Full covariance, optionally multimodal with support for regression

Member Enumeration Documentation

Covariance Mode.

Enumerator
Full 

Full covariance.

Diagonal 

Diagonal covariance (diagonal matrix)

Constructor & Destructor Documentation

xmm::GaussianDistribution::GaussianDistribution ( bool  bimodal = false,
unsigned int  dimension = 1,
unsigned int  dimension_input = 0,
CovarianceMode  covariance_mode = CovarianceMode::Full 
)

Default Constructor.

Parameters
bimodalspecify if the distribution is bimodal for use in regression
dimensiondimension of the distribution
dimension_inputdimension of the input modality in bimodal mode.
covariance_modecovariance mode (full vs diagonal)
xmm::GaussianDistribution::GaussianDistribution ( GaussianDistribution const &  src)

Copy constructor.

Parameters
srcsource distribution
xmm::GaussianDistribution::GaussianDistribution ( Json::Value const &  root)
explicit

Constructor from Json Structure.

Parameters
rootJson Value

Member Function Documentation

std::string xmm::Writable::__str__ ( ) const
inlineinherited

"print" method for python => returns the results of write method

Warning
only defined if SWIGPYTHON is defined
void xmm::GaussianDistribution::allocate ( )
protected

Resize Mean and Covariance Vectors to appropriate dimension.

void xmm::GaussianDistribution::fromEllipse ( Ellipse const &  gaussian_ellipse,
unsigned int  dimension1,
unsigned int  dimension2 
)

Sets the parameters of the Gaussian distribution according to the 68%?? Confidence Interval ellipse.

the ellipse is 2D, and is therefore projected over 2 axes

Parameters
gaussian_ellipse68% Confidence Interval ellipse parameters (1x std)
dimension1index of the first axis
dimension2index of the second axis
Exceptions
out_of_rangeif the dimensions are out of bounds
void xmm::GaussianDistribution::fromJson ( Json::Value const &  root)
virtual

Read the object from a JSON Structure.

Parameters
rootJSON value containing the object's information
Exceptions
JsonExceptionif the JSON value has a wrong format

Implements xmm::Writable.

double xmm::GaussianDistribution::likelihood ( const float *  observation) const

Get Likelihood of a data vector.

Parameters
observationdata observation (must be of size dimension)
Returns
likelihood
Exceptions
runtime_errorif the Covariance Matrix is not invertible
double xmm::GaussianDistribution::likelihood_bimodal ( const float *  observation_input,
const float *  observation_output 
) const

Get Likelihood of a data vector for bimodal mode.

Parameters
observation_inputobservation of the input modality
observation_outputobservation of the output modality
Exceptions
runtime_errorif the Covariance Matrix is not invertible
runtime_errorif the model is not bimodal
Returns
likelihood
double xmm::GaussianDistribution::likelihood_input ( const float *  observation_input) const

Get Likelihood of a data vector for input modality.

Parameters
observation_inputobservation (must be of size dimension_input)
Returns
likelihood
Exceptions
runtime_errorif the Covariance Matrix of the input modality is not invertible
runtime_errorif the model is not bimodal
void xmm::GaussianDistribution::onAttributeChange ( AttributeBase attr_pointer)
protectedvirtual

notification function called when a member attribute is changed

xmm::GaussianDistribution & xmm::GaussianDistribution::operator= ( GaussianDistribution const &  src)

Assignment.

Parameters
srcsource distribution
void xmm::Writable::readFile ( char *  fileName)
inlineinherited

read method for python wrapping ('read' keyword forbidden, name has to be different)

Warning
only defined if SWIGPYTHON is defined
void xmm::GaussianDistribution::regression ( std::vector< float > const &  observation_input,
std::vector< float > &  predicted_output 
) const

Linear Regression using the Gaussian Distribution (covariance-based)

Parameters
observation_inputinput observation (must be of size: dimension_input)
predicted_outputpredicted output vector (size: dimension-dimension_input)
Exceptions
runtime_errorif the model is not bimodal
void xmm::GaussianDistribution::regularize ( std::vector< double >  regularization)

Add offset to the diagonal of the covariance matrix.

Ensures convergence + generalization on few examples

xmm::Ellipse xmm::GaussianDistribution::toEllipse ( unsigned int  dimension1,
unsigned int  dimension2 
)

Compute the 68%?? Confidence Interval ellipse of the Gaussian.

the ellipse is 2D, and is therefore projected over 2 axes

Parameters
dimension1index of the first axis
dimension2index of the second axis
Exceptions
out_of_rangeif the dimensions are out of bounds
Returns
ellipse parameters
Json::Value xmm::GaussianDistribution::toJson ( ) const
virtual

Write the object to a JSON Structure.

Returns
Json value containing the object's information

Implements xmm::Writable.

void xmm::GaussianDistribution::updateInverseCovariance ( )

Compute inverse covariance matrix.

Exceptions
runtime_errorif the covariance matrix is not invertible
void xmm::GaussianDistribution::updateOutputCovariance ( )
protected

Compute the conditional variance vector of the output modality (conditioned over the input).

Exceptions
runtime_errorif the model is not bimodal
void xmm::Writable::writeFile ( char *  fileName) const
inlineinherited

write method for python wrapping ('write' keyword forbidden, name has to be different)

Warning
only defined if SWIGPYTHON is defined

Member Data Documentation

bool xmm::GaussianDistribution::bimodal_
protected

Defines if regression parameters need to be computed.

std::vector<double> xmm::GaussianDistribution::covariance

Covariance Matrix of the Gaussian Distribution.

double xmm::GaussianDistribution::covariance_determinant_
protected

Determinant of the covariance matrix.

double xmm::GaussianDistribution::covariance_determinant_input_
protected

Determinant of the covariance matrix of the input modality.

Attribute<CovarianceMode> xmm::GaussianDistribution::covariance_mode

Covariance Mode.

Attribute<unsigned int> xmm::GaussianDistribution::dimension

Convert to bimodal distribution in place.

Parameters
dimension_inputdimension of the input modality
Exceptions
runtime_errorif the model is already bimodal
out_of_rangeif the requested input dimension is too large Convert to unimodal distribution in place
runtime_errorif the model is already unimodal extract a sub-distribution with the given columns
Parameters
columnscolumns indices in the target order
Exceptions
runtime_errorif the model is training
out_of_rangeif the number or indices of the requested columns exceeds the current dimension
Returns
a Gaussian Distribution from the current model considering only the target columns extract the sub-distribution of the input modality
Exceptions
runtime_errorif the model is training or if it is not bimodal
Returns
a unimodal Gaussian Distribution of the input modality from the current bimodal model extract the sub-distribution of the output modality
Exceptions
runtime_errorif the model is training or if it is not bimodal
Returns
a unimodal Gaussian Distribution of the output modality from the current bimodal model extract the model with reversed input and output modalities
Exceptions
runtime_errorif the model is training or if it is not bimodal
Returns
a bimodal Gaussian Distribution that swaps the input and output modalities Total Dimension of the multivariate normal
Attribute<unsigned int> xmm::GaussianDistribution::dimension_input

Input Dimension of the multivariate normal.

std::vector<double> xmm::GaussianDistribution::inverse_covariance_
protected

Inverse covariance matrix.

std::vector<double> xmm::GaussianDistribution::inverse_covariance_input_
protected

Inverse covariance matrix of the input modality.

std::vector<double> xmm::GaussianDistribution::mean

Mean of the Gaussian Distribution.

std::vector<double> xmm::GaussianDistribution::output_covariance

Conditional Output Variance (updated when covariances matrices are inverted)


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