MCPdf Class Template Reference

Monte Carlo Pdf: Sample based implementation of Pdf. More...

#include <mcpdf.h>

Inheritance diagram for MCPdf:

Pdf

List of all members.

Public Member Functions

 MCPdf (unsigned int num_samples=0, unsigned int dimension=0)
 Constructor.
virtual ~MCPdf ()
 destructor
 MCPdf (const MCPdf< T > &)
 copy constructor
virtual MCPdf< T > * Clone () const
 Clone function.
bool SampleFrom (Sample< T > &one_sample, int method=DEFAULT, void *args=NULL) const
 Draw 1 sample from the Pdf:.
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).
ExpectedValueGet () const
 Get the expected value E[x] of the pdf.
MatrixWrapper::SymmetricMatrix CovarianceGet () const
 Get the Covariance Matrix E[(x - E[x])^2] of the Analytic pdf.
void NumSamplesSet (unsigned int num_samples)
 Set number of samples.
unsigned int NumSamplesGet () const
 Get number of samples.
const WeightedSample< T > & SampleGet (unsigned int i) const
 Get one sample.
bool ListOfSamplesSet (const vector< WeightedSample< T > > &list_of_samples)
 Set the list of weighted samples.
bool ListOfSamplesSet (const vector< Sample< T > > &list_of_samples)
 Overloading: Set the list of Samples (uniform weights).
const vector< WeightedSample
< T > > & 
ListOfSamplesGet () const
 Get the list of weighted samples.
bool ListOfSamplesUpdate (const vector< WeightedSample< T > > &list_of_samples)
 Update the list of samples (overloaded).
bool ListOfSamplesUpdate (const vector< Sample< T > > &list_of_samples)
 Update the list of samples (overloaded).
vector< double > & CumulativePDFGet ()
 Add a sample to the list.
virtual Probability ProbabilityGet (const T &input) const
 Get the probability of a certain argument.
unsigned int DimensionGet () const
 Get the dimension of the argument.
virtual void DimensionSet (unsigned int dim)
 Set the dimension of the argument.

Protected Member Functions

bool SumWeightsUpdate ()
 STL-iterator for cumulative PDF list.
bool NormalizeWeights ()
 Normalizing the weights.
void CumPDFUpdate ()
 After updating weights, we have to update the cumPDF.

Protected Attributes

double _SumWeights
 Sum of all weights: used for normalising purposes.
vector< WeightedSample< T > > _listOfSamples
 STL-list containing the list of samples.
vector< double > _CumPDF
 STL-iterator.


Detailed Description

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

Monte Carlo Pdf: Sample based implementation of Pdf.

Class Monte Carlo Pdf: This is a sample based representation of a Pdf P(x), which can both be continu or discrete

Todo:
This class can and should be made far more efficient!!!

Definition at line 49 of file mcpdf.h.


Constructor & Destructor Documentation

MCPdf ( unsigned int  num_samples = 0,
unsigned int  dimension = 0 
) [inline]

Constructor.

Parameters:
num_samples the number of samples this pdf has
dimension the dimension of these samples (necessary for if you want to avoid too much memory allocation at runtime)

Definition at line 172 of file mcpdf.h.

References MCPdf::_CumPDF, MCPdf::_listOfSamples, and MCPdf::_SumWeights.


Member Function Documentation

bool SumWeightsUpdate (  )  [inline, protected]

STL-iterator for cumulative PDF list.

After updating weights, we have to recalculate the sum of weights

Definition at line 471 of file mcpdf.h.

References MCPdf::_listOfSamples, and MCPdf::_SumWeights.

Referenced by MCPdf::NormalizeWeights().

bool SampleFrom ( Sample< T > &  one_sample,
int  method = DEFAULT,
void *  args = NULL 
) const [inline, virtual]

Draw 1 sample from the Pdf:.

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

Parameters:
one_sample sample that will contain result of sampling
method Sampling method to be used. Each sampling method is currently represented by a define statement, eg. define BOXMULLER 1
args Pointer to a struct representing extra sample arguments
See also:
SampleFrom()
Bug:
Sometimes the compiler doesn't know which method to choose!

Reimplemented from Pdf.

Definition at line 300 of file mcpdf.h.

References MCPdf::_CumPDF, and MCPdf::_listOfSamples.

bool SampleFrom ( vector< Sample< T > > &  list_samples,
const unsigned int  num_samples,
int  method = DEFAULT,
void *  args = NULL 
) const [inline, virtual]

Draw multiple samples from the Pdf (overloaded).

Parameters:
list_samples list of samples that will contain result of sampling
num_samples Number of Samples to be drawn (iid)
method Sampling method to be used. Each sampling method is currently represented by a define statement, eg. define BOXMULLER 1
args Pointer 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.

Definition at line 233 of file mcpdf.h.

References MCPdf::_CumPDF, and MCPdf::_listOfSamples.

T ExpectedValueGet (  )  const [inline, 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.

Definition at line 534 of file mcpdf.h.

MatrixWrapper::SymmetricMatrix CovarianceGet (  )  const [inline, 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.

Definition at line 546 of file mcpdf.h.

void NumSamplesSet ( unsigned int  num_samples  )  [inline]

Set number of samples.

Parameters:
num_samples the number of samples offcourse :-)
See also:
sample, weightedsample

Definition at line 349 of file mcpdf.h.

References MCPdf::_CumPDF, and MCPdf::_listOfSamples.

Referenced by MCPdf::ListOfSamplesSet(), and MCPdf::ListOfSamplesUpdate().

unsigned int NumSamplesGet (  )  const [inline]

Get number of samples.

Returns:
the number of samples

Definition at line 335 of file mcpdf.h.

References MCPdf::_listOfSamples.

Referenced by MCPdf::SampleGet().

const WeightedSample< T > & SampleGet ( unsigned int  i  )  const [inline]

Get one sample.

Returns:
sample
Parameters:
i the ith sample

Definition at line 341 of file mcpdf.h.

References MCPdf::_listOfSamples, and MCPdf::NumSamplesGet().

bool ListOfSamplesSet ( const vector< WeightedSample< T > > &  list_of_samples  )  [inline]

Set the list of weighted samples.

Parameters:
list_of_samples an STL-list containing the list of all weighted samples

Definition at line 387 of file mcpdf.h.

References MCPdf::_listOfSamples, MCPdf::NormalizeWeights(), and MCPdf::NumSamplesSet().

bool ListOfSamplesSet ( const vector< Sample< T > > &  list_of_samples  )  [inline]

Overloading: Set the list of Samples (uniform weights).

Parameters:
list_of_samples an STL-list containing the list of all samples

Definition at line 400 of file mcpdf.h.

References MCPdf::_listOfSamples, MCPdf::_SumWeights, MCPdf::CumPDFUpdate(), and MCPdf::NumSamplesSet().

const vector< WeightedSample< T > > & ListOfSamplesGet (  )  const [inline]

Get the list of weighted samples.

Returns:
an STL-list with the list of weighted samples

Definition at line 427 of file mcpdf.h.

References MCPdf::_listOfSamples.

bool ListOfSamplesUpdate ( const vector< WeightedSample< T > > &  list_of_samples  )  [inline]

Update the list of samples (overloaded).

Parameters:
list_of_samples the list of weighted samples
Precondition:
list_of_samples must contain exactly as many elements as this->NumSamplesGet() returns

Definition at line 434 of file mcpdf.h.

References MCPdf::_listOfSamples, and MCPdf::NormalizeWeights().

bool ListOfSamplesUpdate ( const vector< Sample< T > > &  list_of_samples  )  [inline]

Update the list of samples (overloaded).

Parameters:
list_of_samples the list of samples
Precondition:
list_of_samples must contain exactly as many elements as this->NumSamplesGet() returns

Definition at line 446 of file mcpdf.h.

References MCPdf::_listOfSamples, MCPdf::_SumWeights, MCPdf::CumPDFUpdate(), and MCPdf::NumSamplesSet().

vector< double > & CumulativePDFGet (  )  [inline]

Add a sample to the list.

Parameters:
sample the sample to be added
Todo:
what's the best way to remove some samples?
Get the Cumulative Pdf
Returns:
a vector of doubles representing the CumulativePDF

Definition at line 559 of file mcpdf.h.

References MCPdf::_CumPDF.

Probability ProbabilityGet ( const T &  input  )  const [inline, virtual, inherited]

Get the probability of a certain argument.

Parameters:
input T argument of the Pdf
Returns:
the probability value of the argument

Reimplemented in ConditionalGaussian, DiscreteConditionalPdf, DiscretePdf, Gaussian, Mixture, and Uniform.

Definition at line 207 of file pdf.h.

unsigned int DimensionGet (  )  const [inline, inherited]

Get the dimension of the argument.

Returns:
the dimension of the argument

Definition at line 169 of file pdf.h.

void DimensionSet ( unsigned int  dim  )  [inline, virtual, inherited]

Set the dimension of the argument.

Parameters:
dim the dimension

Definition at line 175 of file pdf.h.


Member Data Documentation

vector<double> _CumPDF [protected]

STL-iterator.

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

Definition at line 60 of file mcpdf.h.

Referenced by MCPdf::CumPDFUpdate(), MCPdf::CumulativePDFGet(), MCPdf::MCPdf(), MCPdf::NumSamplesSet(), and MCPdf::SampleFrom().


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

Generated on Mon Mar 30 05:43:59 2009 for Bayesian Filtering Library by  doxygen 1.5.5