Classes | Public Types | Public Member Functions | Private Attributes
vpdl_mixture< T, n > Class Template Reference

A mixture of distributions. More...

#include <vpdl_mixture.h>

Inheritance diagram for vpdl_mixture< T, n >:
Inheritance graph
[legend]

List of all members.

Classes

struct  component
 A struct to hold the component distributions and weights. More...
class  sort_adaptor
 This adaptor allows users to define ordering functors on the components without accessing the components directly. More...
class  sort_weight
 This functor is used by default for sorting with STL. More...

Public Types

typedef vpdt_field_default< T,
n >::type 
vector
 the data type used for vectors.
typedef vpdt_field_traits
< vector >::matrix_type 
matrix
 the data type used for matrices.
typedef vpdt_field_default< T,
n >::type 
field_type
 the data type used for vectors.

Public Member Functions

 vpdl_mixture ()
 Default Constructor.
 vpdl_mixture (const vpdl_mixture< T, n > &other)
 ~vpdl_mixture ()
vpdl_mixture< T, n > & operator= (const vpdl_mixture< T, n > &rhs)
 Assignment operator.
virtual vpdl_distribution< T, n > * clone () const
 Create a copy on the heap and return base class pointer.
virtual unsigned int dimension () const
 Return the run time dimension, which does not equal n when n==0.
unsigned int num_components () const
 Return the number of components in the mixture.
const vpdl_distribution< T, n > & distribution (unsigned int index) const
 Access (const) a component distribution of the mixture.
vpdl_distribution< T, n > & distribution (unsigned int index)
 Access a component distribution of the mixture.
weight (unsigned int index) const
 Return the weight of a component in the mixture.
void set_weight (unsigned int index, const T &w)
 Set the weight of a component in the mixture.
bool insert (const vpdl_distribution< T, n > &d, const T &wght=T(0))
 Insert a new component at the end of the vector.
bool remove_last ()
 Remove the last component in the vector.
virtual T density (const vector &pt) const
 Evaluate the unnormalized density at a point.
prob_density (const vector &pt) const
 Compute the probability density at this point.
virtual T gradient_density (const vector &pt, vector &g) const
 Compute the gradient of the unnormalized density at a point.
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 void compute_mean (vector &mean) const
 Compute the mean of the distribution.
virtual void compute_covar (matrix &covar) const
 Compute the covariance of the distribution.
virtual T norm_const () const
 The normalization constant for the density.
void normalize_weights ()
 Normalize the weights of the components to add to 1.
void sort ()
 Sort the components in order of decreasing weight.
void sort (unsigned int idx1, unsigned int idx2)
 Sort the components in the range idx1 to idx2 in order of decreasing weight.
template<class comp_type_ >
void sort (comp_type_ comp)
 Sort the components using any StrictWeakOrdering function.
template<class comp_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.
virtual T log_prob_density (const vector &pt) const
 Evaluate the log probability density at a point.
virtual vector inverse_cdf (const T &p) const
 Compute the inverse of the cumulative_prob() function.

Private Attributes

vcl_vector< component * > components_
 The vector of components.

Detailed Description

template<class T, unsigned int n = 0>
class vpdl_mixture< T, n >

A mixture of distributions.

A mixture is a weighted linear combination of other mixtures. This class is the most general, polymorphic version of a mixture. Internally it keeps base class pointers to clones of the supplied distributions. Each distribution in the mixture could potentially be of a different type.

Definition at line 28 of file vpdl_mixture.h.


Member Typedef Documentation

template<class T, unsigned int n = 0>
typedef vpdt_field_default<T,n>::type vpdl_distribution< T, n >::field_type [inherited]

the data type used for vectors.

Reimplemented in vpdl_mixture_of< dist_t >.

Definition at line 36 of file vpdl_distribution.h.

template<class T, unsigned int n = 0>
typedef vpdt_field_traits<vector>::matrix_type vpdl_mixture< T, n >::matrix

the data type used for matrices.

Reimplemented from vpdl_multi_cmp_dist< T, n >.

Definition at line 34 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
typedef vpdt_field_default<T,n>::type vpdl_mixture< T, n >::vector

the data type used for vectors.

Reimplemented from vpdl_multi_cmp_dist< T, n >.

Definition at line 32 of file vpdl_mixture.h.


Constructor & Destructor Documentation

template<class T, unsigned int n = 0>
vpdl_mixture< T, n >::vpdl_mixture ( ) [inline]

Default Constructor.

Definition at line 91 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
vpdl_mixture< T, n >::vpdl_mixture ( const vpdl_mixture< T, n > &  other) [inline]

Definition at line 94 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
vpdl_mixture< T, n >::~vpdl_mixture ( ) [inline]

Definition at line 104 of file vpdl_mixture.h.


Member Function Documentation

template<class T, unsigned int n = 0>
T vpdl_mixture< T, n >::box_prob ( const vector min_pt,
const vector max_pt 
) const [inline, virtual]

The probability integrated over a box.

Reimplemented from vpdl_distribution< T, n >.

Definition at line 238 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
virtual vpdl_distribution<T,n>* vpdl_mixture< T, n >::clone ( ) const [inline, virtual]

Create a copy on the heap and return base class pointer.

Implements vpdl_distribution< T, n >.

Definition at line 127 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
virtual void vpdl_mixture< T, n >::compute_covar ( matrix covar) const [inline, virtual]

Compute the covariance of the distribution.

Implements vpdl_distribution< T, n >.

Definition at line 289 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
virtual void vpdl_mixture< T, n >::compute_mean ( vector mean) const [inline, virtual]

Compute the mean of the distribution.

weighted average of the component means

Implements vpdl_distribution< T, n >.

Definition at line 269 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
virtual T vpdl_mixture< T, n >::cumulative_prob ( const vector pt) const [inline, virtual]

Evaluate the cumulative distribution function at a point.

This is the integral of the density function from negative infinity (in all dimensions) to the point in question

Implements vpdl_distribution< T, n >.

Definition at line 254 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
virtual T vpdl_mixture< T, n >::density ( const vector pt) const [inline, virtual]

Evaluate the unnormalized density at a point.

Implements vpdl_distribution< T, n >.

Definition at line 191 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
virtual unsigned int vpdl_mixture< T, n >::dimension ( ) const [inline, virtual]

Return the run time dimension, which does not equal n when n==0.

Implements vpdl_distribution< T, n >.

Definition at line 133 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
const vpdl_distribution<T,n>& vpdl_mixture< T, n >::distribution ( unsigned int  index) const [inline]

Access (const) a component distribution of the mixture.

Definition at line 144 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
vpdl_distribution<T,n>& vpdl_mixture< T, n >::distribution ( unsigned int  index) [inline]

Access a component distribution of the mixture.

Definition at line 151 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
virtual T vpdl_mixture< T, n >::gradient_density ( const vector pt,
vector g 
) const [inline, virtual]

Compute the gradient of the unnormalized density at a point.

Returns:
the density at pt since it is usually needed as well, and is often trivial to compute while computing gradient
Return values:
gthe gradient vector

Implements vpdl_distribution< T, n >.

Definition at line 220 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
bool vpdl_mixture< T, n >::insert ( const vpdl_distribution< T, n > &  d,
const T &  wght = T(0) 
) [inline]

Insert a new component at the end of the vector.

Definition at line 173 of file vpdl_mixture.h.

template<class T, unsigned int n>
vpdl_distribution< T, n >::vector vpdl_distribution< T, n >::inverse_cdf ( const T &  p) const [virtual, inherited]

Compute the inverse of the cumulative_prob() function.

The value of x: P(x'<x) = P for x' drawn from the distribution.

Note:
This is only valid for univariate distributions multivariate distributions will return a quiet NaN

The value of x: P(x'<x) = P for x' drawn from the distribution. This is only valid for univariate distributions multivariate distributions will return -infinity

Definition at line 75 of file vpdl_distribution.txx.

template<class T, unsigned int n = 0>
virtual T vpdl_distribution< T, n >::log_prob_density ( const vector pt) const [inline, virtual, inherited]

Evaluate the log probability density at a point.

Reimplemented in vpdl_gaussian_sphere< T, n >, vpdl_gaussian_indep< T, n >, and vpdl_gaussian< T, n >.

Definition at line 62 of file vpdl_distribution.h.

template<class T, unsigned int n = 0>
virtual T vpdl_mixture< T, n >::norm_const ( ) const [inline, virtual]

The normalization constant for the density.

When density() is multiplied by this value it becomes prob_density norm_const() is reciprocal of the integral of density over the entire field

Implements vpdl_distribution< T, n >.

Definition at line 321 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
void vpdl_mixture< T, n >::normalize_weights ( ) [inline]

Normalize the weights of the components to add to 1.

Definition at line 332 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
unsigned int vpdl_mixture< T, n >::num_components ( ) const [inline, virtual]

Return the number of components in the mixture.

Implements vpdl_multi_cmp_dist< T, n >.

Definition at line 141 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
vpdl_mixture<T,n>& vpdl_mixture< T, n >::operator= ( const vpdl_mixture< T, n > &  rhs) [inline]

Assignment operator.

Definition at line 112 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
T vpdl_mixture< T, n >::prob_density ( const vector pt) const [inline, virtual]

Compute the probability density at this point.

Reimplemented from vpdl_distribution< T, n >.

Definition at line 203 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
bool vpdl_mixture< T, n >::remove_last ( ) [inline]

Remove the last component in the vector.

Definition at line 181 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
void vpdl_mixture< T, n >::set_weight ( unsigned int  index,
const T &  w 
) [inline]

Set the weight of a component in the mixture.

Definition at line 165 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
void vpdl_mixture< T, n >::sort ( ) [inline]

Sort the components in order of decreasing weight.

Definition at line 341 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
void vpdl_mixture< T, n >::sort ( unsigned int  idx1,
unsigned int  idx2 
) [inline]

Sort the components in the range idx1 to idx2 in order of decreasing weight.

Definition at line 344 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
template<class comp_type_ >
void vpdl_mixture< T, n >::sort ( comp_type_  comp) [inline]

Sort the components using any StrictWeakOrdering function.

The prototype should be

 template <class T>
 bool functor(const vpdl_distribution<T,n>& d1, const T& w1,
              const vpdl_distribution<T,n>& d2, const T& w2);

Definition at line 355 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
template<class comp_type_ >
void vpdl_mixture< T, n >::sort ( comp_type_  comp,
unsigned int  idx1,
unsigned int  idx2 
) [inline]

Sort the components in the range idx1 to idx2 using any StrictWeakOrdering function.

Definition at line 364 of file vpdl_mixture.h.

template<class T, unsigned int n = 0>
T vpdl_mixture< T, n >::weight ( unsigned int  index) const [inline]

Return the weight of a component in the mixture.

Definition at line 158 of file vpdl_mixture.h.


Member Data Documentation

template<class T, unsigned int n = 0>
vcl_vector<component*> vpdl_mixture< T, n >::components_ [private]

The vector of components.

Definition at line 86 of file vpdl_mixture.h.


The documentation for this class was generated from the following file: