35 #include "../wrappers/matrix/vector_wrapper.h" 36 #include "../wrappers/matrix/matrix_wrapper.h" 37 #include "../sample/sample.h" 38 #include "../bfl_err.h" 39 #include "../bfl_constants.h" 47 #define DEFAULT 0 // Default sampling method, must be valid for every PDF!! 50 #define RIPLEY 3 // For efficient sampling from discrete/mcpdfs 53 template <
typename T>
class Pdf 60 Pdf(
unsigned int dimension=0);
68 virtual Pdf<T>* Clone()
const = 0;
87 virtual bool SampleFrom (vector<
Sample<T> >& list_samples,
88 const unsigned int num_samples,
90 void * args = NULL)
const;
103 virtual bool SampleFrom (
Sample<T>& one_sample,
105 void * args = NULL)
const;
111 virtual Probability ProbabilityGet(
const T& input)
const;
116 unsigned int DimensionGet()
const;
121 virtual void DimensionSet(
unsigned int dim);
132 virtual T ExpectedValueGet()
const;
141 virtual MatrixWrapper::SymmetricMatrix CovarianceGet()
const;
152 assert((
int)dim >= 0);
155 #ifdef __CONSTRUCTOR__ 156 cout <<
"Pdf constructor" << endl;
163 #ifdef __DESTRUCTOR__ 164 cout <<
"Pdf destructor" << endl;
168 template<
typename T>
inline unsigned int 174 template<
typename T>
void 177 assert((
int)dim >= 0);
181 template<
typename T>
bool 183 const unsigned int num_samples,
187 list_samples.resize(num_samples);
188 typename vector<Sample<T> >::iterator sample_it;
189 for (sample_it = list_samples.begin(); sample_it != list_samples.end() ; sample_it++)
190 if (!this->SampleFrom(*sample_it, method,args))
196 template<
typename T>
bool 201 cerr <<
"Error Pdf<T>: The SampleFrom function was called, but you didn't implement it!\n";
209 cerr <<
"Error Pdf<T>: The ProbabilityGet function was called, but you didn't implement it!\n";
214 template<
typename T> T
217 cerr <<
"Error Pdf<T>: The ExpectedValueGet function was called, but you didn't implement it!\n";
224 template<
typename T> MatrixWrapper::SymmetricMatrix
227 cerr <<
"Error Pdf<T>: The CovarianceGet function was called, but you didn't implement it!\n";
229 MatrixWrapper::SymmetricMatrix m;
virtual void DimensionSet(unsigned int dim)
Set the dimension of the argument.
Class PDF: Virtual Base class representing Probability Density Functions.
unsigned int _dimension
Dimension of the argument x of P(x | ...).
virtual T ExpectedValueGet() const
Get the expected value E[x] of the pdf.
Pdf(unsigned int dimension=0)
Constructor.
virtual Probability ProbabilityGet(const T &input) const
Get the probability of a certain argument.
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)
virtual ~Pdf()
Destructor.
Class representing a probability (a double between 0 and 1)
virtual MatrixWrapper::SymmetricMatrix CovarianceGet() const
Get the Covariance Matrix E[(x - E[x])^2] of the Analytic pdf.
unsigned int DimensionGet() const
Get the dimension of the argument.