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 enum class SampleMthd { DEFAULT, BOXMULLER, CHOLESKY, RIPLEY };
50 template <
typename T>
class Pdf
57 Pdf(
unsigned int dimension=0);
65 virtual Pdf<T>* Clone()
const = 0;
84 virtual bool SampleFrom (vector<Sample<T> >& list_samples,
85 const unsigned int num_samples,
86 const SampleMthd method = SampleMthd::DEFAULT,
87 void * args = NULL)
const;
100 virtual bool SampleFrom (Sample<T>& one_sample,
101 const SampleMthd method = SampleMthd::DEFAULT,
102 void * args = NULL)
const;
108 virtual Probability ProbabilityGet(
const T& input)
const;
113 unsigned int DimensionGet()
const;
118 virtual void DimensionSet(
unsigned int dim);
129 virtual T ExpectedValueGet()
const;
142 unsigned int _dimension;
149 assert((
int)dim >= 0);
152 #ifdef __CONSTRUCTOR__
153 cout <<
"Pdf constructor" << endl;
160 #ifdef __DESTRUCTOR__
161 cout <<
"Pdf destructor" << endl;
165 template<
typename T>
inline unsigned int
171 template<
typename T>
void
174 assert((
int)dim >= 0);
178 template<
typename T>
bool
180 const unsigned int num_samples,
181 const SampleMthd method,
184 list_samples.resize(num_samples);
185 typename vector<Sample<T> >::iterator sample_it;
186 for (sample_it = list_samples.begin(); sample_it != list_samples.end() ; sample_it++)
187 if (!this->SampleFrom(*sample_it, method,args))
193 template<
typename T>
bool
195 const SampleMthd method,
198 cerr <<
"Error Pdf<T>: The SampleFrom function was called, but you didn't implement it!\n";
199 exit(-BFL_ERRMISUSE);
206 cerr <<
"Error Pdf<T>: The ProbabilityGet function was called, but you didn't implement it!\n";
207 exit(-BFL_ERRMISUSE);
211 template<
typename T> T
214 cerr <<
"Error Pdf<T>: The ExpectedValueGet function was called, but you didn't implement it!\n";
215 exit(-BFL_ERRMISUSE);
224 cerr <<
"Error Pdf<T>: The CovarianceGet function was called, but you didn't implement it!\n";
225 exit(-BFL_ERRMISUSE);