Bayesian Filtering Library Generated from SVN r
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DiscretePdf Class Reference

Class representing a PDF on a discrete variable. More...

#include <discretepdf.h>

Inheritance diagram for DiscretePdf:
Pdf< int >

Public Member Functions

 DiscretePdf (unsigned int num_states=0)
 Constructor (dimension = number of classes) An equal probability is set for all classes.
 
 DiscretePdf (const DiscretePdf &)
 Copy Constructor.
 
virtual ~DiscretePdf ()
 Destructor.
 
virtual DiscretePdfClone () const
 Clone function.
 
unsigned int NumStatesGet () const
 Get the number of discrete States.
 
Probability ProbabilityGet (const int &state) const
 Implementation of virtual base class method.
 
bool ProbabilitySet (int state, Probability a)
 Function to change/set the probability of a single state.
 
bool SampleFrom (vector< Sample< int > > &list_samples, const unsigned int num_samples, const SampleMthd method=SampleMthd::DEFAULT, void *args=NULL) const
 Draw multiple samples from the Pdf (overloaded)
 
bool SampleFrom (Sample< int > &one_sample, const SampleMthd method=SampleMthd::DEFAULT, void *args=NULL) const
 Draw 1 sample from the Pdf:
 
vector< ProbabilityProbabilitiesGet () const
 Get all probabilities.
 
bool ProbabilitiesSet (vector< Probability > &values)
 Set all probabilities.
 
int MostProbableStateGet ()
 Get the index of the most probable state.
 
unsigned int DimensionGet () const
 Get the dimension of the argument.
 
virtual void DimensionSet (unsigned int dim)
 Set the dimension of the argument.
 
virtual int ExpectedValueGet () const
 Get the expected value E[x] of the pdf.
 
virtual MatrixWrapper::SymmetricMatrix CovarianceGet () const
 Get the Covariance Matrix E[(x - E[x])^2] of the Analytic pdf.
 

Protected Member Functions

bool NormalizeProbs ()
 Normalize all the probabilities (eg. after setting a probability)
 
bool CumPDFUpdate ()
 Updates the cumPDF.
 

Protected Attributes

unsigned int _num_states
 The number of discrete state.
 
vector< Probability > * _Values_p
 Pointer to the discrete PDF-values, the sum of the elements = 1.
 
vector< double > _CumPDF
 STL-vector containing the Cumulative PDF (for efficient sampling)
 

Detailed Description

Class representing a PDF on a discrete variable.

This class is an instantation from the template class Pdf, with added methods to get a set the probability of a certain discrete value (methods only relevant for discrete pdfs)

Definition at line 34 of file discretepdf.h.

Constructor & Destructor Documentation

◆ DiscretePdf()

DiscretePdf ( unsigned int num_states = 0)

Constructor (dimension = number of classes) An equal probability is set for all classes.

Parameters
num_statesnumber of different classes or states

Member Function Documentation

◆ Clone()

virtual DiscretePdf * Clone ( ) const
virtual

Clone function.

Implements Pdf< int >.

◆ CovarianceGet()

MatrixWrapper::SymmetricMatrix CovarianceGet ( ) const
virtualinherited

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!

Definition at line 138 of file pdf.h.

◆ DimensionGet()

unsigned int DimensionGet ( ) const
inlineinherited

Get the dimension of the argument.

Returns
the dimension of the argument

Definition at line 113 of file pdf.h.

◆ DimensionSet()

void DimensionSet ( unsigned int dim)
virtualinherited

Set the dimension of the argument.

Parameters
dimthe dimension

Definition at line 118 of file pdf.h.

◆ ExpectedValueGet()

int ExpectedValueGet ( ) const
virtualinherited

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?

Definition at line 129 of file pdf.h.

◆ ProbabilitiesSet()

bool ProbabilitiesSet ( vector< Probability > & values)

Set all probabilities.

Parameters
valuesvector<Probability> containing the new probability values. The sum of the probabilities of this list is not required to be one since the normalization is automatically carried out.

◆ ProbabilityGet()

Probability ProbabilityGet ( const int & state) const
virtual

Implementation of virtual base class method.

Reimplemented from Pdf< int >.

◆ ProbabilitySet()

bool ProbabilitySet ( int state,
Probability a )

Function to change/set the probability of a single state.

Changes the probabilities such that AFTER normalization the probability of the state "state" is equal to the probability a

Parameters
statenumber of state of which the probability will be set
aprobability value to which the probability of state "state" will be set (must be <= 1)

◆ SampleFrom() [1/2]

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

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 from Pdf< int >.

◆ SampleFrom() [2/2]

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

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 from Pdf< int >.

Member Data Documentation

◆ _CumPDF

vector<double> _CumPDF
protected

STL-vector containing the Cumulative PDF (for efficient sampling)

Definition at line 47 of file discretepdf.h.

◆ _num_states

unsigned int _num_states
protected

The number of discrete state.

Definition at line 38 of file discretepdf.h.

◆ _Values_p

vector<Probability>* _Values_p
protected

Pointer to the discrete PDF-values, the sum of the elements = 1.

Definition at line 41 of file discretepdf.h.


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