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

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

#include <mcpdf.h>

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

Public Member Functions

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

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

Protected Attributes

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

Private Attributes

SymmetricMatrix _covariance
 
_CumSum
 
_diff
 
Matrix _diffsum
 
vector< WeightedSample< T > >::iterator _it_los
 
vector< WeightedSample< T > > _los
 
_mean
 

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() [1/4]

template<typename T>
BFL::MCPdf< T >::MCPdf ( unsigned int  num_samples = 0,
unsigned int  dimension = 0 
)

Constructor.

Parameters
num_samplesthe number of samples this pdf has
dimensionthe dimension of these samples. You can use this parameter to avoid runtime memory allocation and

◆ ~MCPdf()

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

destructor

◆ MCPdf() [2/4]

template<typename T>
BFL::MCPdf< T >::MCPdf ( const MCPdf< T > &  )

copy constructor

◆ MCPdf() [3/4]

template<>
BFL::MCPdf< ColumnVector >::MCPdf ( unsigned int  num_samples,
unsigned int  dimension 
)
inline

Definition at line 31 of file mcpdf.cpp.

◆ MCPdf() [4/4]

template<>
BFL::MCPdf< ColumnVector >::MCPdf ( const MCPdf< T > &  pdf)
inline

Definition at line 57 of file mcpdf.cpp.

Member Function Documentation

◆ Clone()

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

Clone function.

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

◆ CovarianceGet() [1/3]

template<>
SymmetricMatrix BFL::MCPdf< ColumnVector >::CovarianceGet ( ) const
inlinevirtual

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

Definition at line 88 of file mcpdf.cpp.

◆ CovarianceGet() [2/3]

template<typename T>
MatrixWrapper::SymmetricMatrix BFL::MCPdf< 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 >.

◆ CovarianceGet() [3/3]

template<>
SymmetricMatrix BFL::MCPdf< unsigned int >::CovarianceGet ( ) const
inlinevirtual

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

Definition at line 130 of file mcpdf.cpp.

◆ CumPDFUpdate()

template<typename T>
void BFL::MCPdf< T >::CumPDFUpdate ( )
protected

After updating weights, we have to update the cumPDF.

◆ CumulativePDFGet()

template<typename T>
vector<double>& BFL::MCPdf< T >::CumulativePDFGet ( )

Add a sample to the list.

Parameters
samplethe 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

◆ ExpectedValueGet() [1/3]

template<>
ColumnVector BFL::MCPdf< 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 77 of file mcpdf.cpp.

◆ ExpectedValueGet() [2/3]

template<typename T>
T BFL::MCPdf< 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() [3/3]

template<>
unsigned int BFL::MCPdf< 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 111 of file mcpdf.cpp.

◆ ListOfSamplesGet()

template<typename T>
const vector<WeightedSample<T> >& BFL::MCPdf< T >::ListOfSamplesGet ( ) const

Get the list of weighted samples.

Returns
an STL-list with the list of weighted samples

◆ ListOfSamplesSet() [1/2]

template<typename T>
bool BFL::MCPdf< T >::ListOfSamplesSet ( const vector< WeightedSample< T > > &  list_of_samples)

Set the list of weighted samples.

Parameters
list_of_samplesan STL-list containing the list of all weighted samples

◆ ListOfSamplesSet() [2/2]

template<typename T>
bool BFL::MCPdf< T >::ListOfSamplesSet ( const vector< Sample< T > > &  list_of_samples)

Overloading: Set the list of Samples (uniform weights)

Parameters
list_of_samplesan STL-list containing the list of all samples

◆ ListOfSamplesUpdate() [1/2]

template<typename T>
bool BFL::MCPdf< T >::ListOfSamplesUpdate ( const vector< WeightedSample< T > > &  list_of_samples)

Update the list of samples (overloaded)

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

◆ ListOfSamplesUpdate() [2/2]

template<typename T>
bool BFL::MCPdf< T >::ListOfSamplesUpdate ( const vector< Sample< T > > &  list_of_samples)

Update the list of samples (overloaded)

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

◆ NormalizeWeights()

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

Normalizing the weights.

◆ NumSamplesGet()

template<typename T>
unsigned int BFL::MCPdf< T >::NumSamplesGet ( ) const

Get number of samples.

Returns
the number of samples

◆ NumSamplesSet()

template<typename T>
void BFL::MCPdf< T >::NumSamplesSet ( unsigned int  num_samples)

Set number of samples.

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

◆ SampleFrom() [1/2]

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

◆ SampleFrom() [2/2]

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

◆ SampleGet()

template<typename T>
const WeightedSample<T>& BFL::MCPdf< T >::SampleGet ( unsigned int  i) const

Get one sample.

Returns
sample
Parameters
ithe ith sample

◆ SumWeightsUpdate()

template<typename T>
bool BFL::MCPdf< T >::SumWeightsUpdate ( )
protected

STL-iterator for cumulative PDF list.

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

Member Data Documentation

◆ _covariance

template<typename T>
SymmetricMatrix BFL::MCPdf< T >::_covariance
mutableprivate

Definition at line 79 of file mcpdf.h.

◆ _CumPDF

template<typename T>
vector<double> BFL::MCPdf< T >::_CumPDF
protected

STL-iterator.

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

Definition at line 60 of file mcpdf.h.

◆ _CumSum

template<typename T>
T BFL::MCPdf< T >::_CumSum
mutableprivate

Definition at line 75 of file mcpdf.h.

◆ _diff

template<typename T>
T BFL::MCPdf< T >::_diff
mutableprivate

Definition at line 78 of file mcpdf.h.

◆ _diffsum

template<typename T>
Matrix BFL::MCPdf< T >::_diffsum
mutableprivate

Definition at line 80 of file mcpdf.h.

◆ _it_los

template<typename T>
vector<WeightedSample<T> >::iterator BFL::MCPdf< T >::_it_los
mutableprivate

Definition at line 81 of file mcpdf.h.

◆ _listOfSamples

template<typename T>
vector<WeightedSample<T> > BFL::MCPdf< T >::_listOfSamples
protected

STL-list containing the list of samples.

Definition at line 56 of file mcpdf.h.

◆ _los

template<typename T>
vector<WeightedSample<T> > BFL::MCPdf< T >::_los
mutableprivate

Definition at line 76 of file mcpdf.h.

◆ _mean

template<typename T>
T BFL::MCPdf< T >::_mean
mutableprivate

Definition at line 77 of file mcpdf.h.

◆ _SumWeights

template<typename T>
double BFL::MCPdf< T >::_SumWeights
protected

Sum of all weights: used for normalising purposes.

Definition at line 54 of file mcpdf.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