Classes | Public Types | Public Member Functions | Static Public Attributes | Private Attributes | Friends
vpdt_mixture_of< dist_t > Class Template Reference

A mixture of a fixed type of distributions. More...

#include <vpdt_mixture_of.h>

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 dist_t::field_type field_type
 the data type to represent a point in the field.
typedef dist_t component_type
 define the component type.
typedef dist_t::field_type F
 the data type to represent a point in the field.
typedef vpdt_field_traits
< field_type >::scalar_type 
T
 define the scalar type (normally specified by template parameter T).
typedef vpdt_field_traits
< field_type >::vector_type 
vector
 define the vector type.
typedef vpdt_field_traits
< field_type >::matrix_type 
matrix
 the data type used for matrices.

Public Member Functions

 vpdt_mixture_of ()
 vpdt_mixture_of (const vpdt_mixture_of< dist_t > &other)
 ~vpdt_mixture_of ()
vpdt_mixture_of< dist_t > & operator= (const vpdt_mixture_of< dist_t > &rhs)
 Assignment operator.
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 dist_t & distribution (unsigned int index) const
 Access (const) a component distribution of the mixture.
dist_t & distribution (unsigned int index)
 Access a component distribution of the mixture.
T 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 dist_t &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.
T density (const F &pt) const
 Compute the unnormalized density at this point.
T gradient_density (const F &pt, vector &g) const
 Compute the gradient of the unnormalized density at a point.
T cumulative_prob (const F &pt) const
 Evaluate the cumulative distribution function at a point.
void compute_mean (F &mean) const
 Compute the mean of the distribution.
void compute_covar (matrix &covar) const
 Compute the covariance of the distribution.
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.

Static Public Attributes

static const unsigned int n = vpdt_field_traits<field_type>::dimension
 define the fixed dimension (normally specified by template parameter n).

Private Attributes

vcl_vector< component * > components_
 The vector of components.

Friends

T vpdt_box_prob (const vpdt_mixture_of< dist_t > &d, const F &min_pt, const F &max_pt)

Detailed Description

template<class dist_t>
class vpdt_mixture_of< dist_t >

A mixture of a fixed type of distributions.

A mixture is a weighted linear combination of other mixtures. This class represents a mixture of a specific type of distribution. Each component in the mixture has its own weight and parameters, but each must be of the same type.

Template Parameters:
dist_tis the type of a component distribution
See also:
vpdl_mixture

Definition at line 47 of file vpdt_mixture_of.h.


Member Typedef Documentation

template<class dist_t>
typedef dist_t vpdt_mixture_of< dist_t >::component_type

define the component type.

Definition at line 53 of file vpdt_mixture_of.h.

template<class dist_t>
typedef dist_t::field_type vpdt_mixture_of< dist_t >::F

the data type to represent a point in the field.

Definition at line 58 of file vpdt_mixture_of.h.

template<class dist_t>
typedef dist_t::field_type vpdt_mixture_of< dist_t >::field_type

the data type to represent a point in the field.

Definition at line 51 of file vpdt_mixture_of.h.

template<class dist_t>
typedef vpdt_field_traits<field_type>::matrix_type vpdt_mixture_of< dist_t >::matrix

the data type used for matrices.

Definition at line 64 of file vpdt_mixture_of.h.

template<class dist_t>
typedef vpdt_field_traits<field_type>::scalar_type vpdt_mixture_of< dist_t >::T

define the scalar type (normally specified by template parameter T).

Definition at line 60 of file vpdt_mixture_of.h.

template<class dist_t>
typedef vpdt_field_traits<field_type>::vector_type vpdt_mixture_of< dist_t >::vector

define the vector type.

Definition at line 62 of file vpdt_mixture_of.h.


Constructor & Destructor Documentation

template<class dist_t>
vpdt_mixture_of< dist_t >::vpdt_mixture_of ( ) [inline]

Definition at line 114 of file vpdt_mixture_of.h.

template<class dist_t>
vpdt_mixture_of< dist_t >::vpdt_mixture_of ( const vpdt_mixture_of< dist_t > &  other) [inline]

Definition at line 117 of file vpdt_mixture_of.h.

template<class dist_t>
vpdt_mixture_of< dist_t >::~vpdt_mixture_of ( ) [inline]

Definition at line 127 of file vpdt_mixture_of.h.


Member Function Documentation

template<class dist_t>
void vpdt_mixture_of< dist_t >::compute_covar ( matrix covar) const [inline]

Compute the covariance of the distribution.

Definition at line 278 of file vpdt_mixture_of.h.

template<class dist_t>
void vpdt_mixture_of< dist_t >::compute_mean ( F mean) const [inline]

Compute the mean of the distribution.

weighted average of the component means

Definition at line 258 of file vpdt_mixture_of.h.

template<class dist_t>
T vpdt_mixture_of< dist_t >::cumulative_prob ( const F pt) const [inline]

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

Definition at line 243 of file vpdt_mixture_of.h.

template<class dist_t>
T vpdt_mixture_of< dist_t >::density ( const F pt) const [inline]

Compute the unnormalized density at this point.

Definition at line 208 of file vpdt_mixture_of.h.

template<class dist_t>
unsigned int vpdt_mixture_of< dist_t >::dimension ( ) const [inline]

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

Definition at line 150 of file vpdt_mixture_of.h.

template<class dist_t>
const dist_t& vpdt_mixture_of< dist_t >::distribution ( unsigned int  index) const [inline]

Access (const) a component distribution of the mixture.

Definition at line 161 of file vpdt_mixture_of.h.

template<class dist_t>
dist_t& vpdt_mixture_of< dist_t >::distribution ( unsigned int  index) [inline]

Access a component distribution of the mixture.

Definition at line 168 of file vpdt_mixture_of.h.

template<class dist_t>
T vpdt_mixture_of< dist_t >::gradient_density ( const F pt,
vector g 
) const [inline]

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

Definition at line 223 of file vpdt_mixture_of.h.

template<class dist_t>
bool vpdt_mixture_of< dist_t >::insert ( const dist_t &  d,
const T wght = T(0) 
) [inline]

Insert a new component at the end of the vector.

Definition at line 190 of file vpdt_mixture_of.h.

template<class dist_t>
T vpdt_mixture_of< dist_t >::norm_const ( ) const [inline]

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

Definition at line 310 of file vpdt_mixture_of.h.

template<class dist_t>
void vpdt_mixture_of< dist_t >::normalize_weights ( ) [inline]

Normalize the weights of the components to add to 1.

Definition at line 321 of file vpdt_mixture_of.h.

template<class dist_t>
unsigned int vpdt_mixture_of< dist_t >::num_components ( ) const [inline]

Return the number of components in the mixture.

Definition at line 158 of file vpdt_mixture_of.h.

template<class dist_t>
vpdt_mixture_of<dist_t>& vpdt_mixture_of< dist_t >::operator= ( const vpdt_mixture_of< dist_t > &  rhs) [inline]

Assignment operator.

Definition at line 135 of file vpdt_mixture_of.h.

template<class dist_t>
bool vpdt_mixture_of< dist_t >::remove_last ( ) [inline]

Remove the last component in the vector.

Definition at line 198 of file vpdt_mixture_of.h.

template<class dist_t>
void vpdt_mixture_of< dist_t >::set_weight ( unsigned int  index,
const T w 
) [inline]

Set the weight of a component in the mixture.

Definition at line 182 of file vpdt_mixture_of.h.

template<class dist_t>
void vpdt_mixture_of< dist_t >::sort ( ) [inline]

Sort the components in order of decreasing weight.

Definition at line 330 of file vpdt_mixture_of.h.

template<class dist_t>
void vpdt_mixture_of< dist_t >::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 333 of file vpdt_mixture_of.h.

template<class dist_t>
template<class comp_type_ >
void vpdt_mixture_of< dist_t >::sort ( comp_type_  comp) [inline]

Sort the components using any StrictWeakOrdering function.

The prototype should be

 template <class dist_t>
 bool functor(const dist_t& d1, const vpdt_dist_traits<dist_t>::scalar_type& w1,
              const dist_t& d2, const vpdt_dist_traits<dist_t>::scalar_type& w2);

Definition at line 344 of file vpdt_mixture_of.h.

template<class dist_t>
template<class comp_type_ >
void vpdt_mixture_of< dist_t >::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 349 of file vpdt_mixture_of.h.

template<class dist_t>
T vpdt_mixture_of< dist_t >::weight ( unsigned int  index) const [inline]

Return the weight of a component in the mixture.

Definition at line 175 of file vpdt_mixture_of.h.


Friends And Related Function Documentation

template<class dist_t>
T vpdt_box_prob ( const vpdt_mixture_of< dist_t > &  d,
const F min_pt,
const F max_pt 
) [friend]

Member Data Documentation

template<class dist_t>
vcl_vector<component*> vpdt_mixture_of< dist_t >::components_ [private]

The vector of components.

Definition at line 110 of file vpdt_mixture_of.h.

template<class dist_t>
const unsigned int vpdt_mixture_of< dist_t >::n = vpdt_field_traits<field_type>::dimension [static]

define the fixed dimension (normally specified by template parameter n).

Definition at line 56 of file vpdt_mixture_of.h.


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