20 #include "../wrappers/rng/rng.h" 29 int num_conditional_arguments,
30 int cond_arg_dimensions[])
32 , _num_states(num_states)
34 , _valuelist(num_states+1)
38 for (
int arg = 0 ; arg < num_conditional_arguments; arg++)
41 total_dim *= cond_arg_dimensions[arg];
44 #ifdef __CONSTRUCTOR__ 45 cout <<
"DCPdf Constructor: total dimension allocated: " 47 #endif // __CONSTRUCTOR__ 54 cout <<
"DCPdf Destructor:" << endl;
55 #endif // __DCPDFDEBUG__ 77 for (
int prob = 0 ; prob < total_dim ; prob++)
97 const std::vector<int>& condargs)
const 103 index += input * blocksize;
108 index += condargs[arg] * blocksize;
111 #ifdef __INDEXDEBUG__ 112 cout <<
"DCPdf::IndexGet -> Index = " << index << endl;
113 #endif // __INDEXDEBUG__ 129 const std::vector<int>& condargs)
const 131 int index = this->
IndexGet(input, condargs);
139 double SumWeights = 0.0;
double CumSum=0.0;
146 #ifdef __DCPDFDEBUG__ 148 cout << setw(TABWIDTH) <<
_probs[index];
149 #endif // __DCPDFDEBUG__ 155 CumSum +=
_probs[index-1]/SumWeights;
165 double unif_sample; unif_sample =
runif();
180 int num_samples,
int method,
183 list_samples.resize(num_samples);
unsigned int _num_states
number of discrete states
virtual bool SampleFrom(Sample< int > &one_sample, int method, void *args) const
Draw 1 sample from the Pdf:
int * _cond_arg_dims_p
"Possible discrete states" of all the conditional arguments
void ValueSet(const T &value)
Set the value of the Sample.
virtual ~DiscreteConditionalPdf()
Destructor.
DiscreteConditionalPdf(int num_states=1, int num_conditional_arguments=1, int cond_arg_dimensions[]=NULL)
Constructor.
double * _probability_p
Pointer to the probability values.
Abstract Class representing conditional Pdfs P(x | ...)
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)
Probability ProbabilityGet(const int &input) const
Get the probability of a certain argument.
unsigned int NumConditionalArgumentsGet() const
Get the Number of conditional arguments.
Abstract Class representing all FULLY Discrete Conditional PDF's.
std::vector< double > _valuelist
int _total_dimension
Total dimension of the likelihoodtable.
Class representing a probability (a double between 0 and 1)
#define NUMERIC_PRECISION
virtual DiscreteConditionalPdf * Clone() const
Clone function.
void ProbabilitySet(const double &prob, const int &input, const std::vector< int > &condargs) const
Set the probability (Typical for discrete Pdf's)
const std::vector< int > & ConditionalArgumentsGet() const
Get the whole list of conditional arguments.
std::vector< double > _probs
unsigned int NumStatesGet() const
Get the number of discrete states.
int IndexGet(const int &input, const std::vector< int > &condargs) const
Get the correct index in the row of doubles (double * probability)