2 #ifndef vpdl_mixture_of_h_ 3 #define vpdl_mixture_of_h_ 28 template<
class dist_t>
31 vpdt_dist_traits<dist_t>::dimension>
44 typedef typename dist_t::field_type
F;
72 {
return impl_.distribution(index); }
84 bool insert(
const dist_t& d,
const T& wght =
T(0))
85 {
return impl_.insert(d,wght); }
102 return impl_.gradient_density(pt,g);
113 {
return impl_.cumulative_prob(pt); }
134 void sort(
unsigned int idx1,
unsigned int idx2) {
impl_.sort(idx1, idx2); }
143 template <
class comp_type_>
147 template <
class comp_type_>
148 void sort(comp_type_ comp,
unsigned int idx1,
unsigned int idx2) {
impl_.sort(comp,idx1,idx2); }
152 #endif // vpdl_mixture_of_h_ virtual void compute_covar(matrix &covar) const
Compute the covariance of the distribution.
T box_prob(const vector &min_pt, const vector &max_pt) const
The probability integrated over a box.
virtual T cumulative_prob(const vector &pt) const
Evaluate the cumulative distribution function at a point.
virtual unsigned int dimension() const
Return the run time dimension.
A mixture of a fixed type of distributions.
base class for multiple component distributions
The basic functions for probability calculations.
dist_t component_type
define the component type.
void sort(comp_type_ comp, unsigned int idx1, unsigned int idx2)
Sort the components in the range idx1 to idx2 using any StrictWeakOrdering function.
void sort(unsigned int idx1, unsigned int idx2)
Sort the components in the range idx1 to idx2 in order of decreasing weight.
T weight(unsigned int index) const
Return the weight of a component in the mixture.
vpdt_mixture_of< dist_t > impl_
virtual vpdl_distribution< T, n > * clone() const
Create a copy on the heap and return base class pointer.
dist_t::field_type F
the data type to represent a point in the field.
T vpdt_box_prob(const vpdl_distribution< T, n > &d, const typename vpdt_field_default< T, n >::type &min_pt, const typename vpdt_field_default< T, n >::type &max_pt)
The box probability wrapper for vpdt.
T density(const vector &pt) const
Compute the unnormalized density at this point.
static const unsigned int n
define the fixed dimension (normally specified by template parameter n).
vpdt_field_traits< field_type >::vector_type vector
define the vector type.
void set_weight(unsigned int index, const T &w)
Set the weight of a component in the mixture.
virtual void compute_mean(vector &mean) const
Compute the mean of the distribution.
const dist_t & distribution(unsigned int index) const
Access (const) a component distribution of the mixture.
void normalize_weights()
Normalize the weights of the components to add to 1.
void sort(comp_type_ comp)
Sort the components using any StrictWeakOrdering function.
void sort()
Sort the components in order of decreasing weight.
bool insert(const dist_t &d, const T &wght=T(0))
Insert a new component at the end of the vector.
T vpdt_prob_density(const vpdl_distribution< T, n > &d, const typename vpdt_field_default< T, n >::type &pt)
probability density wrapper for vpdt.
T prob_density(const vector &pt) const
Compute the probability density at this point.
virtual T norm_const() const
The normalization constant for the density.
The field traits class (scalar).
The base class for all probability distributions.
virtual T gradient_density(const vector &pt, vector &g) const
Compute the gradient of the unnormalized density at a point.
A mixture of a fixed type of distributions.
A mixture of a fixed type of distributions.
The base class for all multiple component probability distributions.
vpdt_field_traits< field_type >::matrix_type matrix
the data type used for matrices.
dist_t & distribution(unsigned int index)
Access a component distribution of the mixture.
Overloaded functions to allow uniform API access to various field types.
specialized template trait classes for properties of a distribution type
virtual ~vpdl_mixture_of()
dist_t::field_type field_type
the data type to represent a point in the field.
bool remove_last()
Remove the last component in the vector.
unsigned int num_components() const
Return the number of components in the mixture.
vpdt_field_traits< field_type >::scalar_type T
define the scalar type (normally specified by template parameter T).