Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
BFL::Mixture< T > Class Template Reference

Class representing a mixture of PDFs, the mixture can contain different. More...

#include <mixture.h>

Inheritance diagram for BFL::Mixture< T >:
Inheritance graph
[legend]

Public Member Functions

bool AddComponent (Pdf< T > &pdf)
 Add a component pdf: THIS IS A NON-REALTIME OPERATION. More...
 
bool AddComponent (Pdf< T > &pdf, Probability w)
 Add a component pdf with weight w: THIS IS A NON-REALTIME OPERATION. More...
 
virtual MixtureClone () const
 Clone function. More...
 
Pdf< T > * ComponentGet (unsigned int componentNumber) const
 Get the pointer to the component pdf of component "componentNumber". More...
 
vector< Pdf< T > *> ComponentsGet () const
 Get the vector of pointers to the component pdfs. More...
 
MatrixWrapper::SymmetricMatrix CovarianceGet () const
 Get the Covariance Matrix E[(x - E[x])^2] of the Analytic pdf. More...
 
bool DeleteComponent (unsigned int componentNumber)
 Delete a component pdf: THIS IS A NON_REALTIME OPERATION. More...
 
template<>
ColumnVector ExpectedValueGet () const
 Get the expected value E[x] of the pdf. More...
 
template<>
unsigned int ExpectedValueGet () const
 Get the expected value E[x] of the pdf. More...
 
template<>
int ExpectedValueGet () const
 Get the expected value E[x] of the pdf. More...
 
ExpectedValueGet () const
 Get the expected value E[x] of the pdf. More...
 
template<>
double ExpectedValueGet () const
 Get the expected value E[x] of the pdf. More...
 
 Mixture (const unsigned int dimension=0)
 Constructor: An equal weight is set for all components. More...
 
template<typename U >
 Mixture (const U &componentVector)
 Constructor: An equal weights is set for all components. More...
 
 Mixture (const Mixture &my_mixture)
 Copy Constructor. More...
 
int MostProbableComponentGet () const
 Get the index of the most probable component, if a few component are. More...
 
unsigned int NumComponentsGet () const
 Get the number of components. More...
 
Probability ProbabilityGet (const T &state) const
 Implementation of virtual base class method. More...
 
bool SampleFrom (vector< Sample< T > > &list_samples, const unsigned int num_samples, int method=DEFAULT, void *args=NULL) const
 
bool SampleFrom (Sample< T > &one_sample, int method=DEFAULT, void *args=NULL) const
 
Probability WeightGet (unsigned int componentNumber) const
 Get the component weight of component "componentNumber". More...
 
bool WeightSet (unsigned int componentNumber, Probability w)
 Function to change/set the weigth of a single component. More...
 
vector< ProbabilityWeightsGet () const
 Get all component weights. More...
 
bool WeightsSet (vector< Probability > &weights)
 Set all component weights. More...
 
virtual ~Mixture ()
 Destructor. More...
 
- Public Member Functions inherited from BFL::BFL::Pdf< T >
unsigned int DimensionGet () const
 Get the dimension of the argument. More...
 
virtual void DimensionSet (unsigned int dim)
 Set the dimension of the argument. More...
 
 Pdf (unsigned int dimension=0)
 Constructor. More...
 
virtual bool SampleFrom (vector< Sample< T > > &list_samples, const unsigned int num_samples, int method=DEFAULT, void *args=NULL) const
 Draw multiple samples from the Pdf (overloaded) More...
 
virtual bool SampleFrom (Sample< T > &one_sample, int method=DEFAULT, void *args=NULL) const
 Draw 1 sample from the Pdf: More...
 
virtual ~Pdf ()
 Destructor. More...
 

Protected Member Functions

bool CumWeightsUpdate ()
 Updates the cumWeights. More...
 
bool NormalizeWeights ()
 Normalize the component weigths (eg. after setting a component weight) More...
 
void TestNotInit () const
 Called when a the number of components=0 and if method is called which. More...
 

Protected Attributes

vector< Pdf< T > *> * _componentPdfs
 Pointer to the vector of component pdfs. More...
 
vector< Probability > * _componentWeights
 Pointer to the vector of mixture weights, the sum of the elements = 1. More...
 
vector< double > _cumWeights
 Vector containing the cumulative component weights (for efficient sampling) More...
 
unsigned int _numComponents
 The number of components. More...
 

Detailed Description

template<typename T>
class BFL::Mixture< T >

Class representing a mixture of PDFs, the mixture can contain different.

This class is an instantation from the template class Pdf, with added methods to get a set the individual components and mixture weights

Definition at line 48 of file mixture.h.

Constructor & Destructor Documentation

◆ Mixture() [1/3]

template<typename T>
BFL::Mixture< T >::Mixture ( const unsigned int  dimension = 0)

Constructor: An equal weight is set for all components.

Parameters
dimensionthe dimension of the state space

◆ Mixture() [2/3]

template<typename T>
template<typename U >
BFL::Mixture< T >::Mixture ( const U &  componentVector)

Constructor: An equal weights is set for all components.

Parameters
componentVectorvector of components (Pdf<T>*)

◆ Mixture() [3/3]

template<typename T>
BFL::Mixture< T >::Mixture ( const Mixture< T > &  my_mixture)

Copy Constructor.

◆ ~Mixture()

template<typename T>
virtual BFL::Mixture< T >::~Mixture ( )
virtual

Destructor.

Member Function Documentation

◆ AddComponent() [1/2]

template<typename T>
bool BFL::Mixture< T >::AddComponent ( Pdf< T > &  pdf)

Add a component pdf: THIS IS A NON-REALTIME OPERATION.

Parameters
pdfComponent pdf which will be added

◆ AddComponent() [2/2]

template<typename T>
bool BFL::Mixture< T >::AddComponent ( Pdf< T > &  pdf,
Probability  w 
)

Add a component pdf with weight w: THIS IS A NON-REALTIME OPERATION.

Parameters
pdfComponent pdf which will be added
weightthe weight of the new component

◆ Clone()

template<typename T>
virtual Mixture* BFL::Mixture< T >::Clone ( ) const
virtual

Clone function.

Implements BFL::BFL::Pdf< T >.

◆ ComponentGet()

template<typename T>
Pdf<T>* BFL::Mixture< T >::ComponentGet ( unsigned int  componentNumber) const

Get the pointer to the component pdf of component "componentNumber".

Parameters
componentNumbernumber of the component (must be >=0 and <_numComponents)

◆ ComponentsGet()

template<typename T>
vector<Pdf<T>* > BFL::Mixture< T >::ComponentsGet ( ) const

Get the vector of pointers to the component pdfs.

◆ CovarianceGet()

template<typename T>
MatrixWrapper::SymmetricMatrix BFL::Mixture< T >::CovarianceGet ( ) const
virtual

Get the Covariance Matrix E[(x - E[x])^2] of the Analytic pdf.

Get first order statistic (Covariance) of this AnalyticPdf

Returns
The Covariance of the Pdf (a SymmetricMatrix of dim DIMENSION)
Todo:
extend this more general to n-th order statistic
Bug:
Discrete pdfs should not be able to use this!

Reimplemented from BFL::BFL::Pdf< T >.

◆ CumWeightsUpdate()

template<typename T>
bool BFL::Mixture< T >::CumWeightsUpdate ( )
protected

Updates the cumWeights.

◆ DeleteComponent()

template<typename T>
bool BFL::Mixture< T >::DeleteComponent ( unsigned int  componentNumber)

Delete a component pdf: THIS IS A NON_REALTIME OPERATION.

Parameters
componentNumbernumber of the component which will be deleted (must be >=0 and <_numComponents)

◆ ExpectedValueGet() [1/5]

template<>
ColumnVector BFL::Mixture< ColumnVector >::ExpectedValueGet ( ) const
inlinevirtual

Get the expected value E[x] of the pdf.

Get low order statistic (Expected Value) of this AnalyticPdf

Returns
The Expected Value of the Pdf (a ColumnVector with DIMENSION rows)
Note
No set functions here! This can be useful for analytic functions, but not for sample based representations!
For certain discrete Pdfs, this function has no meaning, what is the average between yes and no?

Reimplemented from BFL::BFL::Pdf< T >.

Definition at line 30 of file mixture.cpp.

◆ ExpectedValueGet() [2/5]

template<>
unsigned int BFL::Mixture< unsigned int >::ExpectedValueGet ( ) const
inlinevirtual

Get the expected value E[x] of the pdf.

Get low order statistic (Expected Value) of this AnalyticPdf

Returns
The Expected Value of the Pdf (a ColumnVector with DIMENSION rows)
Note
No set functions here! This can be useful for analytic functions, but not for sample based representations!
For certain discrete Pdfs, this function has no meaning, what is the average between yes and no?

Reimplemented from BFL::BFL::Pdf< T >.

Definition at line 45 of file mixture.cpp.

◆ ExpectedValueGet() [3/5]

template<>
int BFL::Mixture< int >::ExpectedValueGet ( ) const
inlinevirtual

Get the expected value E[x] of the pdf.

Get low order statistic (Expected Value) of this AnalyticPdf

Returns
The Expected Value of the Pdf (a ColumnVector with DIMENSION rows)
Note
No set functions here! This can be useful for analytic functions, but not for sample based representations!
For certain discrete Pdfs, this function has no meaning, what is the average between yes and no?

Reimplemented from BFL::BFL::Pdf< T >.

Definition at line 81 of file mixture.cpp.

◆ ExpectedValueGet() [4/5]

template<typename T>
T BFL::Mixture< T >::ExpectedValueGet ( ) const
virtual

Get the expected value E[x] of the pdf.

Get low order statistic (Expected Value) of this AnalyticPdf

Returns
The Expected Value of the Pdf (a ColumnVector with DIMENSION rows)
Note
No set functions here! This can be useful for analytic functions, but not for sample based representations!
For certain discrete Pdfs, this function has no meaning, what is the average between yes and no?

Reimplemented from BFL::BFL::Pdf< T >.

◆ ExpectedValueGet() [5/5]

template<>
double BFL::Mixture< double >::ExpectedValueGet ( ) const
inlinevirtual

Get the expected value E[x] of the pdf.

Get low order statistic (Expected Value) of this AnalyticPdf

Returns
The Expected Value of the Pdf (a ColumnVector with DIMENSION rows)
Note
No set functions here! This can be useful for analytic functions, but not for sample based representations!
For certain discrete Pdfs, this function has no meaning, what is the average between yes and no?

Reimplemented from BFL::BFL::Pdf< T >.

Definition at line 115 of file mixture.cpp.

◆ MostProbableComponentGet()

template<typename T>
int BFL::Mixture< T >::MostProbableComponentGet ( ) const

Get the index of the most probable component, if a few component are.

◆ NormalizeWeights()

template<typename T>
bool BFL::Mixture< T >::NormalizeWeights ( )
protected

Normalize the component weigths (eg. after setting a component weight)

◆ NumComponentsGet()

template<typename T>
unsigned int BFL::Mixture< T >::NumComponentsGet ( ) const

Get the number of components.

◆ ProbabilityGet()

template<typename T>
Probability BFL::Mixture< T >::ProbabilityGet ( const T &  state) const
virtual

Implementation of virtual base class method.

Reimplemented from BFL::BFL::Pdf< T >.

◆ SampleFrom() [1/2]

template<typename T>
bool BFL::Mixture< T >::SampleFrom ( vector< Sample< T > > &  list_samples,
const unsigned int  num_samples,
int  method = DEFAULT,
void *  args = NULL 
) const

◆ SampleFrom() [2/2]

template<typename T>
bool BFL::Mixture< T >::SampleFrom ( Sample< T > &  one_sample,
int  method = DEFAULT,
void *  args = NULL 
) const

◆ TestNotInit()

template<typename T>
void BFL::Mixture< T >::TestNotInit ( ) const
protected

Called when a the number of components=0 and if method is called which.

◆ WeightGet()

template<typename T>
Probability BFL::Mixture< T >::WeightGet ( unsigned int  componentNumber) const

Get the component weight of component "componentNumber".

Parameters
componentNumbernumber of the component (must be >=0 and <_numComponents)

◆ WeightSet()

template<typename T>
bool BFL::Mixture< T >::WeightSet ( unsigned int  componentNumber,
Probability  w 
)

Function to change/set the weigth of a single component.

Changes the component weights such that AFTER normalization the weight of the component "componentNumber" is equal to the weight w

Parameters
componentNumbernumber of the component of which the weight will be set (must be >=0 and <_numComponents)
wProbability to which the weight of component "componentNumber" will be set (must be <= 1)

◆ WeightsGet()

template<typename T>
vector<Probability> BFL::Mixture< T >::WeightsGet ( ) const

Get all component weights.

◆ WeightsSet()

template<typename T>
bool BFL::Mixture< T >::WeightsSet ( vector< Probability > &  weights)

Set all component weights.

values vector<Probability> containing the new component weights . The sum of the probabilities of this list is not required to be one since the normalization is automatically carried out. The size of weights should be equal to the number of components

Member Data Documentation

◆ _componentPdfs

template<typename T>
vector<Pdf<T>* >* BFL::Mixture< T >::_componentPdfs
protected

Pointer to the vector of component pdfs.

Definition at line 58 of file mixture.h.

◆ _componentWeights

template<typename T>
vector<Probability>* BFL::Mixture< T >::_componentWeights
protected

Pointer to the vector of mixture weights, the sum of the elements = 1.

Definition at line 55 of file mixture.h.

◆ _cumWeights

template<typename T>
vector<double> BFL::Mixture< T >::_cumWeights
protected

Vector containing the cumulative component weights (for efficient sampling)

Definition at line 66 of file mixture.h.

◆ _numComponents

template<typename T>
unsigned int BFL::Mixture< T >::_numComponents
protected

The number of components.

Definition at line 52 of file mixture.h.


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


bfl
Author(s): Klaas Gadeyne, Wim Meeussen, Tinne Delaet and many others. See web page for a full contributor list. ROS package maintained by Wim Meeussen.
autogenerated on Mon Feb 28 2022 21:56:34