92 double likelihood = 0;
95 likelihood += (*it_w) * (*it_pdf)->getLikelihood(pdf);
112 assert_msg(
false,
"Mixture does not contain components.");
167 std::string new_indent = indent +
" ";
169 std::stringstream ss;
173 ss << new_indent << (*it_w) <<
" : " << (*it_pdf)->toString(new_indent) <<
"\n";
Mixture * clone() const
Creates a clone of the object. The clone method is cheap since it only copies a pointer. A deep clone will only be created if the original object is modified.
This class represents the weighted sum of a finite set of probability density functions.
#define assert_msg(_Expression, _Msg)
std::vector< double > weights_
void normalizeWeights()
Normalizes the weights of all components.
int components() const
Returns the number of components.
void clear()
Removes all components.
virtual PDF * clone() const =0
iterator(field< oT > &in_M, const bool at_end=false)
Mixture & operator=(const Mixture &other)
Assignment operator. The operation is cheap since it only copies a pointer. A deep clone will only be...
double getMaxDensity() const
NOT IMPLEMENTED FOR MIXTURE.
void addComponent(const PDF &pdf, double w)
Adds a component pdf with given weight.
const PDF & getComponent(int i) const
Returns a reference to the i'th component.
const_iterator(const field< oT > &in_M, const bool at_end=false)
double getLikelihood(const PDF &pdf) const
virtual ~Mixture()
Destructor.
std::vector< PDF * > components_
Mixture()
Constructs a mixture pdf with no initial components.
double getWeight(int i) const
Returns the weight of the i'th component.
std::string toString(const std::string &indent="") const
Represents the Mixture as a string for easier console output.