Classes | Public Types | Public Member Functions | Private Types | Private Attributes
bsta_mixture< dist_ > Class Template Reference

A mixture of distributions. More...

#include <bsta_mixture.h>

Inheritance diagram for bsta_mixture< dist_ >:
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

enum  { max_components = 0 }
typedef dist_ dist_type
typedef dist_type component_type
enum  
 The dimension of the distribution. More...
typedef dist_::math_type math_type
 The type used for calculations.
typedef vnl_vector_fixed
< math_type, dimension > 
vector_type
 The type used for a n-dimensional vector of math types.
typedef vector_type field_type
 for compatibility with vpdl/vpdt.

Public Member Functions

 bsta_mixture ()
 bsta_mixture (const bsta_mixture< dist_ > &other)
 ~bsta_mixture ()
bsta_mixture< dist_ > & operator= (const bsta_mixture< dist_ > &rhs)
 Assignment operator.
unsigned int num_components () const
 Return the number of components in the mixture.
const dist_ & distribution (unsigned int index) const
 Access (const) a component distribution of the mixture.
dist_ & 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_ &d, const T &weight=T(0))
 Insert a new component at the end of the vector.
void remove_last ()
 Remove the last component in the vector.
T prob_density (const vector_ &pt) const
 Compute the probability density at this point.
T probability (const vector_ &min_pt, const vector_ &max_pt) const
 The probability integrated over a box.
void normalize_weights ()
 Normalize the weights of the components to add to 1.
void sort ()
 Sort the components 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 idx)
vector_ sample (vnl_random &rng) const
 sample from the mixture.

Private Types

typedef dist_::math_type T
typedef dist_::vector_type vector_

Private Attributes

vcl_vector< component * > components_
 The vector of components.

Detailed Description

template<class dist_>
class bsta_mixture< dist_ >

A mixture of distributions.

Definition at line 27 of file bsta_mixture.h.


Member Typedef Documentation

template<class dist_>
typedef dist_type bsta_mixture< dist_ >::component_type

Definition at line 32 of file bsta_mixture.h.

template<class dist_>
typedef dist_ bsta_mixture< dist_ >::dist_type

Definition at line 31 of file bsta_mixture.h.

typedef vector_type bsta_distribution< dist_::math_type , n >::field_type [inherited]

for compatibility with vpdl/vpdt.

Definition at line 29 of file bsta_distribution.h.

typedef dist_::math_type bsta_distribution< dist_::math_type , n >::math_type [inherited]

The type used for calculations.

Definition at line 25 of file bsta_distribution.h.

template<class dist_>
typedef dist_::math_type bsta_mixture< dist_ >::T [private]

Definition at line 37 of file bsta_mixture.h.

template<class dist_>
typedef dist_::vector_type bsta_mixture< dist_ >::vector_ [private]

Definition at line 38 of file bsta_mixture.h.

typedef vnl_vector_fixed<math_type,dimension> bsta_distribution< dist_::math_type , n >::vector_type [inherited]

The type used for a n-dimensional vector of math types.

Definition at line 27 of file bsta_distribution.h.


Member Enumeration Documentation

anonymous enum [inherited]

The dimension of the distribution.

Definition at line 23 of file bsta_distribution.h.

template<class dist_>
anonymous enum
Enumerator:
max_components 

Definition at line 34 of file bsta_mixture.h.


Constructor & Destructor Documentation

template<class dist_>
bsta_mixture< dist_ >::bsta_mixture ( ) [inline]

Definition at line 90 of file bsta_mixture.h.

template<class dist_>
bsta_mixture< dist_ >::bsta_mixture ( const bsta_mixture< dist_ > &  other) [inline]

Definition at line 93 of file bsta_mixture.h.

template<class dist_>
bsta_mixture< dist_ >::~bsta_mixture ( ) [inline]

Definition at line 103 of file bsta_mixture.h.


Member Function Documentation

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

Access (const) a component distribution of the mixture.

Definition at line 129 of file bsta_mixture.h.

template<class dist_>
dist_& bsta_mixture< dist_ >::distribution ( unsigned int  index) [inline]

Access a component distribution of the mixture.

Definition at line 133 of file bsta_mixture.h.

template<class dist_>
bool bsta_mixture< dist_ >::insert ( const dist_ &  d,
const T weight = T(0) 
) [inline]

Insert a new component at the end of the vector.

Definition at line 144 of file bsta_mixture.h.

template<class dist_>
void bsta_mixture< dist_ >::normalize_weights ( ) [inline]

Normalize the weights of the components to add to 1.

Definition at line 173 of file bsta_mixture.h.

template<class dist_>
unsigned int bsta_mixture< dist_ >::num_components ( ) const [inline]

Return the number of components in the mixture.

Definition at line 126 of file bsta_mixture.h.

template<class dist_>
bsta_mixture<dist_>& bsta_mixture< dist_ >::operator= ( const bsta_mixture< dist_ > &  rhs) [inline]

Assignment operator.

Definition at line 111 of file bsta_mixture.h.

template<class dist_>
T bsta_mixture< dist_ >::prob_density ( const vector_ pt) const [inline]

Compute the probability density at this point.

Note:
assumes weights have been normalized

Definition at line 152 of file bsta_mixture.h.

template<class dist_>
T bsta_mixture< dist_ >::probability ( const vector_ min_pt,
const vector_ max_pt 
) const [inline]

The probability integrated over a box.

Note:
assumes weights have been normalized

Definition at line 163 of file bsta_mixture.h.

template<class dist_>
void bsta_mixture< dist_ >::remove_last ( ) [inline]

Remove the last component in the vector.

Definition at line 148 of file bsta_mixture.h.

template<class dist_>
vector_ bsta_mixture< dist_ >::sample ( vnl_random &  rng) const [inline]

sample from the mixture.

randomly selects a component wrt normalized component weights, then for now returns the mean of the selected component

Todo:
write a method to sample from the distribution and use it instead of the mean

first normalize the weights (this is const methods so we cannot call the class-method normalize_weights().

Definition at line 205 of file bsta_mixture.h.

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

Set the weight of a component in the mixture.

Definition at line 140 of file bsta_mixture.h.

template<class dist_>
void bsta_mixture< dist_ >::sort ( ) [inline]

Sort the components in order of decreasing weight.

Definition at line 185 of file bsta_mixture.h.

template<class dist_>
template<class comp_type_ >
void bsta_mixture< dist_ >::sort ( comp_type_  comp) [inline]

Sort the components using any StrictWeakOrdering function.

The prototype should be

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

Definition at line 195 of file bsta_mixture.h.

template<class dist_>
template<class comp_type_ >
void bsta_mixture< dist_ >::sort ( comp_type_  comp,
unsigned int  idx 
) [inline]

Definition at line 199 of file bsta_mixture.h.

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

Return the weight of a component in the mixture.

Definition at line 137 of file bsta_mixture.h.


Member Data Documentation

template<class dist_>
vcl_vector<component*> bsta_mixture< dist_ >::components_ [private]

The vector of components.

Definition at line 86 of file bsta_mixture.h.


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