#include <mcpdf.h>
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). | |
T | 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. |
Class Monte Carlo Pdf: This is a sample based representation of a Pdf P(x), which can both be continu or discrete
Definition at line 49 of file mcpdf.h.
MCPdf | ( | unsigned int | num_samples = 0 , |
|
unsigned int | dimension = 0 | |||
) | [inline] |
Constructor.
num_samples | the number of samples this pdf has | |
dimension | the dimension of these samples. You can use this parameter to avoid runtime memory allocation and |
Definition at line 171 of file mcpdf.h.
References MCPdf< T >::_CumPDF, MCPdf< T >::_listOfSamples, and MCPdf< T >::_SumWeights.
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
Reimplemented from Pdf< T >.
vector< double > & CumulativePDFGet | ( | ) | [inline] |
Add a sample to the list.
sample | the sample to be added |
Definition at line 554 of file mcpdf.h.
References MCPdf< T >::_CumPDF.
unsigned int DimensionGet | ( | ) | const [inherited] |
Get the dimension of the argument.
virtual void DimensionSet | ( | unsigned int | dim | ) | [virtual, inherited] |
Set the dimension of the argument.
dim | the dimension |
T ExpectedValueGet | ( | ) | const [inline, virtual] |
Get the expected value E[x] of the pdf.
Get low order statistic (Expected Value) of this AnalyticPdf
For certain discrete Pdfs, this function has no meaning, what is the average between yes and no?
Reimplemented from Pdf< T >.
const vector< WeightedSample< T > > & ListOfSamplesGet | ( | ) | const [inline] |
Get the list of weighted samples.
Definition at line 422 of file mcpdf.h.
References MCPdf< T >::_listOfSamples.
bool ListOfSamplesSet | ( | const vector< Sample< T > > & | list_of_samples | ) | [inline] |
Overloading: Set the list of Samples (uniform weights).
list_of_samples | an STL-list containing the list of all samples |
Definition at line 395 of file mcpdf.h.
References MCPdf< T >::_listOfSamples, MCPdf< T >::_SumWeights, MCPdf< T >::CumPDFUpdate(), and MCPdf< T >::NumSamplesSet().
bool ListOfSamplesSet | ( | const vector< WeightedSample< T > > & | list_of_samples | ) | [inline] |
Set the list of weighted samples.
list_of_samples | an STL-list containing the list of all weighted samples |
Definition at line 382 of file mcpdf.h.
References MCPdf< T >::_listOfSamples, MCPdf< T >::NormalizeWeights(), and MCPdf< T >::NumSamplesSet().
bool ListOfSamplesUpdate | ( | const vector< Sample< T > > & | list_of_samples | ) | [inline] |
Update the list of samples (overloaded).
list_of_samples | the list of samples |
Definition at line 441 of file mcpdf.h.
References MCPdf< T >::_listOfSamples, MCPdf< T >::_SumWeights, MCPdf< T >::CumPDFUpdate(), and MCPdf< T >::NumSamplesSet().
bool ListOfSamplesUpdate | ( | const vector< WeightedSample< T > > & | list_of_samples | ) | [inline] |
Update the list of samples (overloaded).
list_of_samples | the list of weighted samples |
Definition at line 429 of file mcpdf.h.
References MCPdf< T >::_listOfSamples, and MCPdf< T >::NormalizeWeights().
unsigned int NumSamplesGet | ( | ) | const [inline] |
Get number of samples.
Definition at line 330 of file mcpdf.h.
References MCPdf< T >::_listOfSamples.
Referenced by MCPdf< T >::SampleGet().
void NumSamplesSet | ( | unsigned int | num_samples | ) | [inline] |
Set number of samples.
num_samples | the number of samples offcourse :-) |
Definition at line 344 of file mcpdf.h.
References MCPdf< T >::_CumPDF, and MCPdf< T >::_listOfSamples.
Referenced by MCPdf< T >::ListOfSamplesSet(), and MCPdf< T >::ListOfSamplesUpdate().
virtual Probability ProbabilityGet | ( | const T & | input | ) | const [virtual, inherited] |
Get the probability of a certain argument.
input | T argument of the Pdf |
Reimplemented in Mixture< T >.
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).
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... |
Reimplemented from Pdf< T >.
Definition at line 228 of file mcpdf.h.
References MCPdf< T >::_CumPDF, MCPdf< T >::_listOfSamples, and MCPdf< T >::SampleFrom().
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!
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 |
Reimplemented from Pdf< T >.
Definition at line 295 of file mcpdf.h.
References MCPdf< T >::_CumPDF, and MCPdf< T >::_listOfSamples.
Referenced by MCPdf< T >::SampleFrom().
const WeightedSample< T > & SampleGet | ( | unsigned int | i | ) | const [inline] |
Get one sample.
i | the ith sample |
Definition at line 336 of file mcpdf.h.
References MCPdf< T >::_listOfSamples, and MCPdf< T >::NumSamplesGet().
bool SumWeightsUpdate | ( | ) | [inline, protected] |
STL-iterator for cumulative PDF list.
After updating weights, we have to recalculate the sum of weights
Definition at line 466 of file mcpdf.h.
References MCPdf< T >::_listOfSamples, and MCPdf< T >::_SumWeights.
Referenced by MCPdf< T >::NormalizeWeights().
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< T >::CumPDFUpdate(), MCPdf< T >::CumulativePDFGet(), MCPdf< T >::MCPdf(), MCPdf< T >::NumSamplesSet(), and MCPdf< T >::SampleFrom().