MoGL2E Class Reference

A Gaussian mixture model class. More...

Collaboration diagram for MoGL2E:
[legend]

List of all members.

Public Member Functions

Matrix & d_omega ()
ArrayList< Matrix > & d_sigma (index_t i)
ArrayList< ArrayList< Matrix > > & d_sigma ()
index_t dimension ()
void Display ()
 This function prints the parameters of the model.
long double GoodnessOfFitTerm_ (const Matrix &, Vector *=NULL)
 Calculates the goodness-of-fit value for a Gaussian mixture and its gradient with respect to the parameters.
void Init (index_t num_gauss, index_t dimension)
long double L2Error (const Matrix &, Vector *=NULL)
 This function calculates the L2 error and the gradient of the error with respect to the parameters given the data and the parameterized mixture.
void MakeModel (datanode *mog_l2e_module, double *theta)
void MakeModel (index_t num_mods, index_t dimension, double *theta)
 This function uses the parameters used for optimization and converts it into athe parameters of a Gaussian mixture model.
void MakeModelWithGradients (index_t num_mods, index_t dimension, double *theta)
 This function uses the parameters used for optimization and converts it into athe parameters of a Gaussian mixture model.
Vectormu (index_t i)
ArrayList< Vector > & mu ()
index_t number_of_gaussians ()
double omega (index_t i)
Vectoromega ()
void OutputResults (ArrayList< double > *results)
 This function outputs the parameters of the model to an arraylist of doubles.
long double RegularizationTerm_ (Vector *=NULL)
 Calculates the regularization value for a Gaussian mixture and its gradient with respect to the parameters.
void Resize_d_sigma_ ()
void set_d_omega (Matrix &d_omega)
void set_d_sigma (index_t i, index_t j, Matrix &d_sigma_i_j)
void set_mu (index_t i, index_t length, const double *mu)
void set_mu (index_t i, Vector &mu)
void set_omega (index_t length, const double *omega)
void set_omega (Vector &omega)
void set_sigma (index_t i, Matrix &sigma)
Matrix & sigma (index_t i)
ArrayList< Matrix > & sigma ()

Static Public Member Functions

static void InitialPointGenerator (double *, const Matrix &, index_t)
 This function parameterizes the starting point obtained from the 'k_means" for optimization purposes using the Quasi Newton method.
static void KMeans_ (const Matrix &, ArrayList< Vector > *, ArrayList< Matrix > *, Vector *, index_t)
 This function computes the k-means of the data and stores the calculated means and covariances in the ArrayList of Vectors and Matrices passed to it.
static long double L2ErrorForOpt (Vector &params, const Matrix &data)
 This is the function which should be used for optimization when there is no need to compute any gradients.
static long double L2ErrorForOpt (Vector &params, const Matrix &data, Vector *gradient)
 This is the function which would be used for optimization.
static void min_element (Matrix &, index_t *)
 This function returns the indices of the minimum element in each row of a matrix.
static void MultiplePointsGenerator (double **, index_t, const Matrix &, index_t)
 This function computes multiple number of starting points required for the Nelder Mead method.

Detailed Description

A Gaussian mixture model class.

This class uses L2 loss function to estimate the parameters of a gaussian mixture model on a given data.

The parameters are converted for optimization to maintain the following facts:

Example use:

 MoGL2E mog;
 ArrayList<double> results;
 double *params;

 mog.MakeModel(number_of_gaussians, dimension, params);
 mog.L2Error(data);
 mog.OutputResults(&results);

Definition at line 90 of file mog_l2e.h.


Member Function Documentation

void MoGL2E::Display (  )  [inline]

This function prints the parameters of the model.

 mog.Display();

Definition at line 465 of file mog_l2e.h.

long double MoGL2E::GoodnessOfFitTerm_ ( const Matrix &  data,
Vector g_fit = NULL 
)

Calculates the goodness-of-fit value for a Gaussian mixture and its gradient with respect to the parameters.

Used by the 'L2Error' function to calculate the goodness-of-fit part of the error

Definition at line 217 of file mog_l2e.cc.

References linalg__private::AddTo(), GenVector< T >::Copy(), GenVector< T >::CopyValues(), GenVector< T >::get(), ArrayList< TElem >::Init(), GenVector< T >::Init(), GenVector< T >::length(), linalg__private::MulInit(), linalg__private::Scale(), and GenVector< T >::SetAll().

Referenced by L2Error().

void MoGL2E::InitialPointGenerator ( double *  theta,
const Matrix &  data,
index_t  k_comp 
) [static]

This function parameterizes the starting point obtained from the 'k_means" for optimization purposes using the Quasi Newton method.

Example use:

 double *p;
 index_t num_gauss;
 const Matrix data;
 
 MoGL2E::InitialPointGeneratot(p, data, num_gauss);

Definition at line 340 of file mog_l2e.cc.

References ArrayList< TElem >::Init(), GenVector< T >::Init(), KMeans_(), and la::TransposeInit().

void MoGL2E::KMeans_ ( const Matrix &  data,
ArrayList< Vector > *  means,
ArrayList< Matrix > *  covars,
Vector weights,
index_t  value_of_k 
) [static]

This function computes the k-means of the data and stores the calculated means and covariances in the ArrayList of Vectors and Matrices passed to it.

It sets the weights uniformly.

This function is used to obtain a starting point for the optimization

Example use:

 const Matrix data;
 ArrayList<Vector> *means;
 ArrayList<Matrix> *covars;
 Vector *weights;
 index_t num_gauss;
 
 ...
 MoGL2E::KMeans(data, means, covars, weights, num_gauss);
   *

Definition at line 385 of file mog_l2e.cc.

References linalg__private::AddTo(), GenVector< T >::CopyValues(), GenVector< T >::Init(), ArrayList< TElem >::Init(), min_element(), linalg__private::Scale(), GenVector< T >::SetAll(), and linalg__private::SubOverwrite().

Referenced by InitialPointGenerator().

long double MoGL2E::L2Error ( const Matrix &  data,
Vector gradients = NULL 
)

This function calculates the L2 error and the gradient of the error with respect to the parameters given the data and the parameterized mixture.

Example use:

 const Matrix data;
 MoGL2E mog;
 index_t num_gauss, dimension;
 double *params; // get the parameters
 
 mog.MakeModel(num_gauss, dimension, params);
 mog.L2Error(data);

Definition at line 44 of file mog_l2e.cc.

References linalg__private::AddExpert(), linalg__private::AddTo(), GoodnessOfFitTerm_(), GenVector< T >::length(), RegularizationTerm_(), and GenVector< T >::SetAll().

Referenced by L2ErrorForOpt().

static long double MoGL2E::L2ErrorForOpt ( Vector params,
const Matrix &  data 
) [inline, static]

This is the function which should be used for optimization when there is no need to compute any gradients.

Definition at line 636 of file mog_l2e.h.

References L2ErrorForOpt().

static long double MoGL2E::L2ErrorForOpt ( Vector params,
const Matrix &  data,
Vector gradient 
) [inline, static]

This is the function which would be used for optimization.

It creates its own object of class MoGL2E and returns the L2 error and the gradient which are computed by the functions of the class

Definition at line 609 of file mog_l2e.h.

References L2Error(), GenVector< T >::length(), MakeModel(), MakeModelWithGradients(), and GenVector< T >::ptr().

Referenced by L2ErrorForOpt().

void MoGL2E::MakeModel ( index_t  num_mods,
index_t  dimension,
double *  theta 
) [inline]

This function uses the parameters used for optimization and converts it into athe parameters of a Gaussian mixture model.

This is to be used when you do not want the gradient values.

Example use:

 MoGL2E mog;
 mog.MakeModel(number_of_gaussians, dimension,
               parameters_for_optimization);

Definition at line 156 of file mog_l2e.h.

References GenMatrix< T >::Init(), linalg__private::MulOverwrite(), linalg__private::Scale(), and la::TransposeOverwrite().

Referenced by L2ErrorForOpt().

void MoGL2E::MakeModelWithGradients ( index_t  num_mods,
index_t  dimension,
double *  theta 
) [inline]

This function uses the parameters used for optimization and converts it into athe parameters of a Gaussian mixture model.

This is to be used when you want the gradient values.

Example use:

 MoGL2E mog;
 mog.MakeModelWithGradients(number_of_gaussians, dimension,
                            parameters_for_optimization);

Definition at line 237 of file mog_l2e.h.

References GenMatrix< T >::Init(), linalg__private::MulInit(), linalg__private::MulOverwrite(), linalg__private::Scale(), and la::TransposeOverwrite().

Referenced by L2ErrorForOpt().

void MoGL2E::min_element ( Matrix &  element,
index_t *  indices 
) [static]

This function returns the indices of the minimum element in each row of a matrix.

Definition at line 506 of file mog_l2e.cc.

Referenced by KMeans_().

void MoGL2E::MultiplePointsGenerator ( double **  points,
index_t  number_of_points,
const Matrix &  d,
index_t  number_of_components 
) [static]

This function computes multiple number of starting points required for the Nelder Mead method.

Example use:

 double **p;
 index_t n, num_gauss;
 const Matrix data;
 
 MoGL2E::MultiplePointsGeneratot(p, n, data, num_gauss);

Definition at line 305 of file mog_l2e.cc.

References GenVector< T >::CopyValues(), GenVector< T >::get(), and GenVector< T >::Init().

void MoGL2E::OutputResults ( ArrayList< double > *  results  )  [inline]

This function outputs the parameters of the model to an arraylist of doubles.

 ArrayList<double> results;
 mog.OutputResults(&results);

Definition at line 439 of file mog_l2e.h.

long double MoGL2E::RegularizationTerm_ ( Vector g_reg = NULL  ) 

Calculates the regularization value for a Gaussian mixture and its gradient with respect to the parameters.

Used by the 'L2Error' function to calculate the regularization part of the error

Definition at line 70 of file mog_l2e.cc.

References GenVector< T >::Copy(), GenVector< T >::get(), GenVector< T >::Init(), ArrayList< TElem >::Init(), GenVector< T >::length(), linalg__private::MulInit(), GenVector< T >::ptr(), linalg__private::Scale(), and linalg__private::ScaleInit().

Referenced by L2Error().


The documentation for this class was generated from the following files:
Generated on Mon Jan 24 12:04:40 2011 for FASTlib by  doxygen 1.6.3