Bayesian Filtering Library  Generated from SVN r
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Mixture< T > Class Template Reference

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

#include <mixture.h>

Inheritance diagram for Mixture< T >:
Pdf< T >

Public Member Functions

 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.
 
virtual ~Mixture ()
 Destructor.
 
virtual MixtureClone () const
 Clone function.
 
unsigned int NumComponentsGet () const
 Get the number of components.
 
Probability ProbabilityGet (const T &state) const
 Implementation of virtual base class method.
 
bool SampleFrom (vector< Sample< T > > &list_samples, const unsigned int num_samples, const SampleMthd method=SampleMthd::DEFAULT, void *args=NULL) const
 
bool SampleFrom (Sample< T > &one_sample, const SampleMthd method=SampleMthd::DEFAULT, void *args=NULL) const
 
ExpectedValueGet () const
 Get the expected value E[x] of the pdf. More...
 
MatrixWrapper::SymmetricMatrix CovarianceGet () const
 Get the Covariance Matrix E[(x - E[x])^2] of the Analytic pdf. More...
 
vector< ProbabilityWeightsGet () const
 Get all component weights.
 
Probability WeightGet (unsigned int componentNumber) const
 Get the component weight of component "componentNumber". More...
 
bool WeightsSet (vector< Probability > &weights)
 Set all component weights. More...
 
bool WeightSet (unsigned int componentNumber, Probability w)
 Function to change/set the weigth of a single component. More...
 
int MostProbableComponentGet () const
 Get the index of the most probable component, if a few component are.
 
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...
 
bool DeleteComponent (unsigned int componentNumber)
 Delete a component pdf: THIS IS A NON_REALTIME OPERATION. More...
 
vector< Pdf< T > * > ComponentsGet () const
 Get the vector of pointers to the component pdfs.
 
Pdf< T > * ComponentGet (unsigned int componentNumber) const
 Get the pointer to the component pdf of component "componentNumber". More...
 
virtual bool SampleFrom (vector< Sample< T > > &list_samples, const unsigned int num_samples, const SampleMthd method=SampleMthd::DEFAULT, void *args=NULL) const
 Draw multiple samples from the Pdf (overloaded) More...
 
virtual bool SampleFrom (Sample< T > &one_sample, const SampleMthd method=SampleMthd::DEFAULT, void *args=NULL) const
 Draw 1 sample from the Pdf: More...
 
unsigned int DimensionGet () const
 Get the dimension of the argument. More...
 
virtual void DimensionSet (unsigned int dim)
 Set the dimension of the argument. More...
 

Protected Member Functions

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

Protected Attributes

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

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/2]

Mixture ( const unsigned int  dimension = 0)

Constructor: An equal weight is set for all components.

Parameters
dimensionthe dimension of the state space

◆ Mixture() [2/2]

Mixture ( const U &  componentVector)

Constructor: An equal weights is set for all components.

Parameters
componentVectorvector of components (Pdf<T>*)

Member Function Documentation

◆ AddComponent() [1/2]

bool AddComponent ( Pdf< T > &  pdf)

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

Parameters
pdfComponent pdf which will be added

◆ AddComponent() [2/2]

bool 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

◆ ComponentGet()

Pdf<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)

◆ CovarianceGet()

MatrixWrapper::SymmetricMatrix 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 Pdf< T >.

◆ DeleteComponent()

bool 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)

◆ DimensionGet()

unsigned int DimensionGet ( ) const
inlineinherited

Get the dimension of the argument.

Returns
the dimension of the argument

Definition at line 166 of file mixtureParticleFilter.h.

◆ DimensionSet()

void DimensionSet ( unsigned int  dim)
virtualinherited

Set the dimension of the argument.

Parameters
dimthe dimension

Reimplemented in Gaussian.

Definition at line 172 of file mixtureParticleFilter.h.

◆ ExpectedValueGet()

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 Pdf< T >.

◆ SampleFrom() [1/2]

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

Draw multiple samples from the Pdf (overloaded)

Parameters
list_sampleslist of samples that will contain result of sampling
num_samplesNumber of Samples to be drawn (iid)
methodSampling method to be used. Each sampling method is currently represented by an enum eg. SampleMthd::BOXMULLER
argsPointer to a struct representing extra sample arguments. "Sample Arguments" can be anything (the number of steps a gibbs-iterator should take, the interval width in MCMC, ... (or nothing), so it is hard to give a meaning to what exactly Sample Arguments should represent...
Todo:
replace the C-call "void * args" by a more object-oriented structure: Perhaps something like virtual Sample * Sample (const int num_samples,class Sampler)
Bug:
Sometimes the compiler doesn't know which method to choose!

Reimplemented in Mixture< T >, MCPdf< T >, and DiscretePdf.

Definition at line 179 of file mixtureParticleFilter.h.

◆ SampleFrom() [2/2]

bool SampleFrom ( Sample< T > &  one_sample,
const SampleMthd  method = SampleMthd::DEFAULT,
void *  args = NULL 
) const
virtualinherited

Draw 1 sample from the Pdf:

There's no need to create a list for only 1 sample!

Parameters
one_samplesample that will contain result of sampling
methodSampling method to be used. Each sampling method is currently represented by an enum, eg. SampleMthd::BOXMULLER
argsPointer to a struct representing extra sample arguments
See also
SampleFrom()
Bug:
Sometimes the compiler doesn't know which method to choose!

Reimplemented in Mixture< T >, MCPdf< T >, and DiscretePdf.

Definition at line 194 of file mixtureParticleFilter.h.

◆ WeightGet()

Probability WeightGet ( unsigned int  componentNumber) const

Get the component weight of component "componentNumber".

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

◆ WeightSet()

bool 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)

◆ WeightsSet()

bool WeightsSet ( vector< Probability > &  weights)

Set all component weights.

@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


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