IT++ Logo
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
itpp::MOG_diag_EM_sup Class Reference

support class for MOG_diag_ML() and MOG_diag_MAP() More...

#include <itpp/stat/mog_diag_em.h>

Inheritance diagram for itpp::MOG_diag_EM_sup:
itpp::MOG_diag itpp::MOG_generic

Public Member Functions

 MOG_diag_EM_sup ()
 Default constructor. More...
 
 ~MOG_diag_EM_sup ()
 Default destructor. More...
 
void ml (MOG_diag &model_in, Array< vec > &X_in, int max_iter_in=10, double var_floor_in=0.0, double weight_floor_in=0.0, bool verbose_in=false)
 ADD DOCUMENTATION HERE. More...
 
void map (MOG_diag &model_in, MOG_diag &prior_model, Array< vec > &X_in, int max_iter_in=10, double alpha_in=0.5, double var_floor_in=0.0, double weight_floor_in=0.0, bool verbose_in=false)
 ADD DOCUMENTATION HERE. More...
 
void cleanup ()
 Release memory used by the model. The model will be empty. More...
 
void load (const std::string &name_in)
 Initialise the model by loading the parameters from a model file. More...
 
void convert_to_full ()
 Do nothing. Present for compatability with the MOG_generic class. More...
 
double log_lhood_single_gaus (const double *c_x_in, const int k) const
 calculate the log likelihood of C vector c_x_in using only Gaussian k More...
 
double log_lhood_single_gaus (const vec &x_in, const int k) const
 calculate the log likelihood of IT++ vector x_in using only Gaussian k More...
 
virtual double log_lhood_single_gaus (const vec &x_in, const int k)
 calculate the log likelihood of vector x_in using only Gaussian k More...
 
double log_lhood (const double *c_x_in)
 calculate the log likelihood of C vector c_x_in More...
 
double log_lhood (const vec &x_in)
 calculate the log likelihood of IT++ vector x_in More...
 
double lhood (const double *c_x_in)
 calculate the likelihood of C vector c_x_in More...
 
double lhood (const vec &x_in)
 calculate the likelihood of IT++ vector x_in More...
 
double avg_log_lhood (const double **c_x_in, int N)
 calculate the average log likelihood of an array of C vectors ( c_x_in ) More...
 
double avg_log_lhood (const Array< vec > &X_in)
 calculate the average log likelihood of an array of IT++ vectors ( X_in ) More...
 
void init ()
 Initialise the model to be empty. More...
 
void init (const int &K_in, const int &D_in, bool full_in=false)
 initialise the model so that all Gaussians have zero mean and unit variance for all dimensions More...
 
void init (Array< vec > &means_in, bool full_in=false)
 Initialise the model using user supplied mean vectors. More...
 
void init (Array< vec > &means_in, Array< vec > &diag_covs_in, vec &weights_in)
 Initialise the model using user supplied parameters (diagonal covariance version) More...
 
void init (Array< vec > &means_in, Array< mat > &full_covs_in, vec &weights_in)
 Initialise the model using user supplied parameters (full covariance version) More...
 
bool is_valid () const
 Returns true if the model's parameters are valid. More...
 
bool is_full () const
 Returns true if the model has full covariance matrices. More...
 
int get_K () const
 Return the number of Gaussians. More...
 
int get_D () const
 Return the dimensionality. More...
 
vec get_weights () const
 Obtain a copy of the weight vector. More...
 
Array< vec > get_means () const
 Obtain a copy of the array of mean vectors. More...
 
Array< vec > get_diag_covs () const
 Obtain a copy of the array of diagonal covariance vectors. More...
 
Array< mat > get_full_covs () const
 Obtain a copy of the array of full covariance matrices. More...
 
void set_means (Array< vec > &means_in)
 Set the means of the model. More...
 
void set_diag_covs (Array< vec > &diag_covs_in)
 Set the diagonal covariance vectors of the model. More...
 
void set_full_covs (Array< mat > &full_covs_in)
 Set the full covariance matrices of the model. More...
 
void set_weights (vec &weights_in)
 Set the weight vector of the model. More...
 
void set_means_zero ()
 Set the means in the model to be zero. More...
 
void set_diag_covs_unity ()
 Set the diagonal covariance vectors to be unity. More...
 
void set_full_covs_unity ()
 Set the full covariance matrices to be unity. More...
 
void set_weights_uniform ()
 Set all the weights to 1/K, where K is the number of Gaussians. More...
 
void set_checks (bool do_checks_in)
 Enable/disable internal checks for likelihood functions. More...
 
void set_paranoid (bool paranoid_in)
 Enable/disable paranoia about numerical stability. More...
 
virtual void save (const std::string &name_in) const
 Save the model's parameters to a model file. More...
 
virtual void join (const MOG_generic &B_in)
 Mathematically join the model with a user supplied model. More...
 
virtual void convert_to_diag ()
 Convert the model to use diagonal covariances. More...
 

Protected Member Functions

void update_internals ()
 ADD DOCUMENTATION HERE. More...
 
void sanitise_params ()
 ADD DOCUMENTATION HERE. More...
 
double ml_update_params ()
 ADD DOCUMENTATION HERE. More...
 
void ml_iterate ()
 ADD DOCUMENTATION HERE. More...
 
void setup_means ()
 additional processing of mean vectors, done as the last step of mean initialisation More...
 
void setup_covs ()
 additional processing of covariance vectors/matrices, done as the last step of covariance initialisation More...
 
void setup_weights ()
 additional processing of the weight vector, done as the last step of weight initialisation More...
 
void setup_misc ()
 additional processing of miscellaneous parameters, done as the last step of overall initialisation More...
 
double log_lhood_single_gaus_internal (const double *c_x_in, const int k) const
 ADD DOCUMENTATION HERE. More...
 
double log_lhood_single_gaus_internal (const vec &x_in, const int k) const
 ADD DOCUMENTATION HERE. More...
 
virtual double log_lhood_single_gaus_internal (const vec &x_in, const int k)
 ADD DOCUMENTATION HERE. More...
 
double log_lhood_internal (const double *c_x_in)
 ADD DOCUMENTATION HERE. More...
 
double log_lhood_internal (const vec &x_in)
 ADD DOCUMENTATION HERE. More...
 
double lhood_internal (const double *c_x_in)
 ADD DOCUMENTATION HERE. More...
 
double lhood_internal (const vec &x_in)
 ADD DOCUMENTATION HERE. More...
 
double ** enable_c_access (Array< vec > &A_in)
 Enable C style access to an Array of vectors (vec) More...
 
int ** enable_c_access (Array< ivec > &A_in)
 Enable C style access to an Array of vectors (ivec) More...
 
double * enable_c_access (vec &v_in)
 Enable C style access to a vector (vec) More...
 
int * enable_c_access (ivec &v_in)
 Enable C style access to a vector (ivec) More...
 
double ** disable_c_access (double **A_in)
 Disable C style access to an Array of vectors (vec) More...
 
int ** disable_c_access (int **A_in)
 Disable C style access to an Array of vectors (ivec) More...
 
double * disable_c_access (double *v_in)
 Disable C style access to a vector (vec) More...
 
int * disable_c_access (int *v_in)
 Disable C style access to a vector (ivec) More...
 
void zero_all_ptrs ()
 ADD DOCUMENTATION HERE. More...
 
void free_all_ptrs ()
 ADD DOCUMENTATION HERE. More...
 
bool check_size (const vec &x_in) const
 Check if vector x_in has the same dimensionality as the model. More...
 
bool check_size (const Array< vec > &X_in) const
 Check if all vectors in Array X_in have the same dimensionality as the model. More...
 
bool check_array_uniformity (const Array< vec > &A) const
 Check if all vectors in Array X_in have the same dimensionality. More...
 
void set_means_internal (Array< vec > &means_in)
 ADD DOCUMENTATION HERE. More...
 
void set_diag_covs_internal (Array< vec > &diag_covs_in)
 ADD DOCUMENTATION HERE. More...
 
void set_full_covs_internal (Array< mat > &full_covs_in)
 ADD DOCUMENTATION HERE. More...
 
void set_weights_internal (vec &_weigths)
 ADD DOCUMENTATION HERE. More...
 
void set_means_zero_internal ()
 ADD DOCUMENTATION HERE. More...
 
void set_diag_covs_unity_internal ()
 ADD DOCUMENTATION HERE. More...
 
void set_full_covs_unity_internal ()
 ADD DOCUMENTATION HERE. More...
 
void set_weights_uniform_internal ()
 ADD DOCUMENTATION HERE. More...
 
void convert_to_diag_internal ()
 ADD DOCUMENTATION HERE. More...
 
void convert_to_full_internal ()
 ADD DOCUMENTATION HERE. More...
 

Protected Attributes

bool verbose
 Whether we print the progress. More...
 
int N
 number of training vectors More...
 
int max_iter
 Maximum number of iterations. More...
 
double ** c_X
 'C' pointers to training vectors More...
 
double var_floor
 ADD DOCUMENTATION HERE. More...
 
double weight_floor
 ADD DOCUMENTATION HERE. More...
 
double ** c_means
 pointers to the mean vectors More...
 
double ** c_diag_covs
 pointers to the covariance vectors More...
 
double ** c_diag_covs_inv_etc
 pointers to the inverted covariance vectors More...
 
double * c_weights
 pointer to the weight vector More...
 
double * c_log_weights
 pointer to the log version of the weight vector More...
 
double * c_log_det_etc
 pointer to the log_det_etc vector More...
 
bool do_checks
 indicates whether checks on input data are done More...
 
bool valid
 indicates whether the parameters are valid More...
 
bool full
 indicates whether we are using full or diagonal covariance matrices More...
 
bool paranoid
 indicates whether we are paranoid about numerical stability More...
 
int K
 number of gaussians More...
 
int D
 dimensionality More...
 
Array< vec > means
 means More...
 
Array< vec > diag_covs
 diagonal covariance matrices, stored as vectors More...
 
Array< mat > full_covs
 full covariance matrices More...
 
vec weights
 weights More...
 
double log_max_K
 Pre-calcualted std::log(std::numeric_limits<double>::max() / K), where K is the number of Gaussians. More...
 
vec log_det_etc
 Gaussian specific pre-calcualted constants. More...
 
vec log_weights
 Pre-calculated log versions of the weights. More...
 
Array< mat > full_covs_inv
 Pre-calcuated inverted version of each full covariance matrix. More...
 
Array< vec > diag_covs_inv_etc
 Pre-calcuated inverted version of each diagonal covariance vector, where the covariance elements are first multiplied by two. More...
 

Detailed Description

support class for MOG_diag_ML() and MOG_diag_MAP()

Author
Conrad Sanderson

Definition at line 43 of file mog_diag_em.h.

Constructor & Destructor Documentation

◆ MOG_diag_EM_sup()

itpp::MOG_diag_EM_sup::MOG_diag_EM_sup ( )
inline

Default constructor.

Definition at line 49 of file mog_diag_em.h.

◆ ~MOG_diag_EM_sup()

itpp::MOG_diag_EM_sup::~MOG_diag_EM_sup ( )
inline

Default destructor.

Definition at line 52 of file mog_diag_em.h.

Member Function Documentation

◆ ml()

void itpp::MOG_diag_EM_sup::ml ( MOG_diag model_in,
Array< vec > &  X_in,
int  max_iter_in = 10,
double  var_floor_in = 0.0,
double  weight_floor_in = 0.0,
bool  verbose_in = false 
)

◆ map()

void itpp::MOG_diag_EM_sup::map ( MOG_diag model_in,
MOG_diag prior_model,
Array< vec > &  X_in,
int  max_iter_in = 10,
double  alpha_in = 0.5,
double  var_floor_in = 0.0,
double  weight_floor_in = 0.0,
bool  verbose_in = false 
)

ADD DOCUMENTATION HERE.

Definition at line 306 of file mog_diag_em.cpp.

References it_error.

◆ update_internals()

void itpp::MOG_diag_EM_sup::update_internals ( )
inlineprotected

ADD DOCUMENTATION HERE.

update log versions of parameters and any necessary constants

Definition at line 41 of file mog_diag_em.cpp.

References itpp::MOG_diag::c_diag_covs, itpp::MOG_diag::c_diag_covs_inv_etc, itpp::MOG_diag::c_log_det_etc, itpp::MOG_diag::c_log_weights, itpp::MOG_diag::c_weights, itpp::MOG_generic::D, itpp::MOG_generic::K, itpp::log(), and itpp::m_2pi.

Referenced by ml_iterate().

◆ sanitise_params()

void itpp::MOG_diag_EM_sup::sanitise_params ( )
inlineprotected

ADD DOCUMENTATION HERE.

for helping to avoid numerical instability

Definition at line 66 of file mog_diag_em.cpp.

References itpp::MOG_diag::c_diag_covs, itpp::MOG_diag::c_weights, itpp::MOG_generic::D, itpp::MOG_generic::K, var_floor, and weight_floor.

Referenced by ml_iterate().

◆ ml_update_params()

double itpp::MOG_diag_EM_sup::ml_update_params ( )
protected

◆ ml_iterate()

void itpp::MOG_diag_EM_sup::ml_iterate ( )
protected

ADD DOCUMENTATION HERE.

Definition at line 176 of file mog_diag_em.cpp.

References itpp::flush(), itpp::max(), max_iter, ml_update_params(), sanitise_params(), itpp::Timer::tic(), itpp::Timer::toc(), update_internals(), and verbose.

Referenced by ml().

◆ cleanup()

void itpp::MOG_diag::cleanup ( )
inlinevirtualinherited

Release memory used by the model. The model will be empty.

Note
The likelihood functions are not useable until the model's parameters are re-initialised

Reimplemented from itpp::MOG_generic.

Definition at line 111 of file mog_diag.h.

References itpp::MOG_generic::cleanup().

Referenced by ml(), and itpp::MOG_diag_kmeans_sup::run().

◆ load()

void itpp::MOG_diag::load ( const std::string &  name_in)
virtualinherited

Initialise the model by loading the parameters from a model file.

Parameters
name_inThe model's filename
Note
If the model file contains a full covariance matrix model, the covariance matrices will be converted to be diagonal after loading.

Reimplemented from itpp::MOG_generic.

Definition at line 277 of file mog_diag.cpp.

References itpp::MOG_generic::convert_to_diag(), itpp::MOG_generic::full, and itpp::MOG_generic::load().

◆ convert_to_full()

void itpp::MOG_diag::convert_to_full ( )
inlinevirtualinherited

Do nothing. Present for compatability with the MOG_generic class.

Reimplemented from itpp::MOG_generic.

Definition at line 121 of file mog_diag.h.

◆ log_lhood_single_gaus() [1/3]

double itpp::MOG_diag::log_lhood_single_gaus ( const double *  c_x_in,
const int  k 
) const
inherited

calculate the log likelihood of C vector c_x_in using only Gaussian k

Definition at line 59 of file mog_diag.cpp.

References itpp::MOG_generic::do_checks, it_assert, itpp::MOG_generic::K, itpp::MOG_diag::log_lhood_single_gaus_internal(), and itpp::MOG_generic::valid.

◆ log_lhood_single_gaus() [2/3]

double itpp::MOG_diag::log_lhood_single_gaus ( const vec &  x_in,
const int  k 
) const
inherited

calculate the log likelihood of IT++ vector x_in using only Gaussian k

Definition at line 69 of file mog_diag.cpp.

References itpp::MOG_generic::check_size(), itpp::MOG_generic::do_checks, it_assert, itpp::MOG_generic::K, itpp::MOG_diag::log_lhood_single_gaus_internal(), and itpp::MOG_generic::valid.

◆ log_lhood_single_gaus() [3/3]

double itpp::MOG_generic::log_lhood_single_gaus ( const vec &  x_in,
const int  k 
)
virtualinherited

calculate the log likelihood of vector x_in using only Gaussian k

Definition at line 550 of file mog_generic.cpp.

References itpp::MOG_generic::check_size(), itpp::MOG_generic::do_checks, it_assert, itpp::MOG_generic::K, itpp::MOG_generic::log_lhood_single_gaus_internal(), and itpp::MOG_generic::valid.

◆ log_lhood() [1/2]

double itpp::MOG_diag::log_lhood ( const double *  c_x_in)
inherited

calculate the log likelihood of C vector c_x_in

Definition at line 122 of file mog_diag.cpp.

References itpp::MOG_generic::do_checks, it_assert, itpp::MOG_diag::log_lhood_internal(), and itpp::MOG_generic::valid.

◆ log_lhood() [2/2]

double itpp::MOG_diag::log_lhood ( const vec &  x_in)
virtualinherited

calculate the log likelihood of IT++ vector x_in

Reimplemented from itpp::MOG_generic.

Definition at line 112 of file mog_diag.cpp.

References itpp::MOG_generic::check_size(), itpp::MOG_generic::do_checks, it_assert, itpp::MOG_diag::log_lhood_internal(), and itpp::MOG_generic::valid.

◆ lhood() [1/2]

double itpp::MOG_diag::lhood ( const double *  c_x_in)
inherited

calculate the likelihood of C vector c_x_in

Definition at line 170 of file mog_diag.cpp.

References itpp::MOG_generic::do_checks, it_assert, itpp::MOG_diag::lhood_internal(), and itpp::MOG_generic::valid.

◆ lhood() [2/2]

double itpp::MOG_diag::lhood ( const vec &  x_in)
virtualinherited

calculate the likelihood of IT++ vector x_in

Reimplemented from itpp::MOG_generic.

Definition at line 160 of file mog_diag.cpp.

References itpp::MOG_generic::check_size(), itpp::MOG_generic::do_checks, it_assert, itpp::MOG_diag::lhood_internal(), and itpp::MOG_generic::valid.

◆ avg_log_lhood() [1/2]

double itpp::MOG_diag::avg_log_lhood ( const double **  c_x_in,
int  N 
)
inherited

calculate the average log likelihood of an array of C vectors ( c_x_in )

Definition at line 181 of file mog_diag.cpp.

References itpp::MOG_generic::do_checks, it_assert, itpp::MOG_diag::log_lhood_internal(), and itpp::MOG_generic::valid.

◆ avg_log_lhood() [2/2]

double itpp::MOG_diag::avg_log_lhood ( const Array< vec > &  X_in)
virtualinherited

calculate the average log likelihood of an array of IT++ vectors ( X_in )

Reimplemented from itpp::MOG_generic.

Definition at line 195 of file mog_diag.cpp.

References itpp::MOG_generic::check_size(), itpp::MOG_generic::do_checks, it_assert, itpp::MOG_diag::log_lhood_internal(), itpp::Array< T >::size(), and itpp::MOG_generic::valid.

◆ setup_means()

void itpp::MOG_diag::setup_means ( )
protectedvirtualinherited

additional processing of mean vectors, done as the last step of mean initialisation

Reimplemented from itpp::MOG_generic.

Definition at line 231 of file mog_diag.cpp.

References itpp::MOG_diag::c_means, itpp::MOG_diag::disable_c_access(), itpp::MOG_diag::enable_c_access(), itpp::MOG_generic::means, and itpp::MOG_generic::setup_means().

◆ setup_covs()

void itpp::MOG_diag::setup_covs ( )
protectedvirtualinherited

◆ setup_weights()

void itpp::MOG_diag::setup_weights ( )
protectedvirtualinherited

additional processing of the weight vector, done as the last step of weight initialisation

Reimplemented from itpp::MOG_generic.

Definition at line 254 of file mog_diag.cpp.

References itpp::MOG_diag::c_log_weights, itpp::MOG_diag::c_weights, itpp::MOG_diag::disable_c_access(), itpp::MOG_diag::enable_c_access(), itpp::MOG_generic::log_weights, itpp::MOG_generic::setup_weights(), and itpp::MOG_generic::weights.

◆ setup_misc()

void itpp::MOG_diag::setup_misc ( )
protectedvirtualinherited

additional processing of miscellaneous parameters, done as the last step of overall initialisation

Reimplemented from itpp::MOG_generic.

Definition at line 266 of file mog_diag.cpp.

References itpp::MOG_generic::convert_to_diag_internal(), itpp::MOG_diag::disable_c_access(), itpp::MOG_diag::enable_c_access(), itpp::MOG_generic::full, itpp::MOG_generic::K, and itpp::MOG_generic::setup_misc().

◆ log_lhood_single_gaus_internal() [1/3]

double itpp::MOG_diag::log_lhood_single_gaus_internal ( const double *  c_x_in,
const int  k 
) const
protectedinherited

◆ log_lhood_single_gaus_internal() [2/3]

double itpp::MOG_diag::log_lhood_single_gaus_internal ( const vec &  x_in,
const int  k 
) const
protectedinherited

ADD DOCUMENTATION HERE.

Definition at line 53 of file mog_diag.cpp.

References itpp::MOG_diag::log_lhood_single_gaus_internal().

◆ log_lhood_single_gaus_internal() [3/3]

double itpp::MOG_generic::log_lhood_single_gaus_internal ( const vec &  x_in,
const int  k 
)
protectedvirtualinherited

◆ log_lhood_internal() [1/2]

double itpp::MOG_diag::log_lhood_internal ( const double *  c_x_in)
protectedinherited

◆ log_lhood_internal() [2/2]

double itpp::MOG_diag::log_lhood_internal ( const vec &  x_in)
protectedvirtualinherited

ADD DOCUMENTATION HERE.

Reimplemented from itpp::MOG_generic.

Definition at line 106 of file mog_diag.cpp.

References itpp::MOG_diag::log_lhood_internal().

◆ lhood_internal() [1/2]

double itpp::MOG_diag::lhood_internal ( const double *  c_x_in)
protectedinherited

◆ lhood_internal() [2/2]

double itpp::MOG_diag::lhood_internal ( const vec &  x_in)
protectedvirtualinherited

ADD DOCUMENTATION HERE.

Reimplemented from itpp::MOG_generic.

Definition at line 158 of file mog_diag.cpp.

References itpp::MOG_diag::lhood_internal().

◆ enable_c_access() [1/4]

double ** itpp::MOG_diag::enable_c_access ( Array< vec > &  A_in)
protectedinherited

◆ enable_c_access() [2/4]

int ** itpp::MOG_diag::enable_c_access ( Array< ivec > &  A_in)
protectedinherited

Enable C style access to an Array of vectors (ivec)

Definition at line 292 of file mog_diag.cpp.

References itpp::Array< T >::size().

◆ enable_c_access() [3/4]

double * itpp::MOG_diag::enable_c_access ( vec &  v_in)
protectedinherited

Enable C style access to a vector (vec)

Definition at line 303 of file mog_diag.cpp.

◆ enable_c_access() [4/4]

int * itpp::MOG_diag::enable_c_access ( ivec &  v_in)
protectedinherited

Enable C style access to a vector (ivec)

Definition at line 304 of file mog_diag.cpp.

◆ disable_c_access() [1/4]

double ** itpp::MOG_diag::disable_c_access ( double **  A_in)
protectedinherited

◆ disable_c_access() [2/4]

int ** itpp::MOG_diag::disable_c_access ( int **  A_in)
protectedinherited

Disable C style access to an Array of vectors (ivec)

Definition at line 301 of file mog_diag.cpp.

◆ disable_c_access() [3/4]

double * itpp::MOG_diag::disable_c_access ( double *  v_in)
protectedinherited

Disable C style access to a vector (vec)

Definition at line 306 of file mog_diag.cpp.

◆ disable_c_access() [4/4]

int * itpp::MOG_diag::disable_c_access ( int *  v_in)
protectedinherited

Disable C style access to a vector (ivec)

Definition at line 307 of file mog_diag.cpp.

◆ zero_all_ptrs()

void itpp::MOG_diag::zero_all_ptrs ( )
protectedinherited

◆ free_all_ptrs()

void itpp::MOG_diag::free_all_ptrs ( )
protectedinherited

◆ init() [1/5]

void itpp::MOG_generic::init ( )
inherited

Initialise the model to be empty.

Note
The likelihood functions are not useable until the model's parameters are set

Definition at line 43 of file mog_generic.cpp.

References itpp::MOG_generic::cleanup().

Referenced by itpp::MOG_generic::join(), itpp::MOG_generic::load(), ml(), and itpp::MOG_diag_kmeans_sup::run().

◆ init() [2/5]

void itpp::MOG_generic::init ( const int &  K_in,
const int &  D_in,
bool  full_in = false 
)
inherited

initialise the model so that all Gaussians have zero mean and unit variance for all dimensions

Parameters
K_inNumber of Gaussians
D_inDimensionality
full_inIf true, use full covariance matrices; if false, use diagonal covariance matrices. Default = false.

Definition at line 46 of file mog_generic.cpp.

References itpp::MOG_generic::D, itpp::MOG_generic::do_checks, itpp::MOG_generic::full, it_assert, itpp::MOG_generic::K, itpp::MOG_generic::paranoid, itpp::MOG_generic::set_diag_covs_unity_internal(), itpp::MOG_generic::set_full_covs_unity_internal(), itpp::MOG_generic::set_means_zero_internal(), itpp::MOG_generic::set_weights_uniform_internal(), itpp::MOG_generic::setup_misc(), and itpp::MOG_generic::valid.

◆ init() [3/5]

void itpp::MOG_generic::init ( Array< vec > &  means_in,
bool  full_in = false 
)
inherited

Initialise the model using user supplied mean vectors.

Parameters
means_inArray of mean vectors
full_inIf true, use full covariance matrices; if false, use diagonal covariance matrices. Default = false.
Note
The number of mean vectors specifies the number of Gaussians. The covariance matrices are set to the identity matrix. The weights for all Gaussians are the same, equal to 1/K, where K is the number of Gaussians

Definition at line 69 of file mog_generic.cpp.

References itpp::MOG_generic::check_array_uniformity(), itpp::MOG_generic::D, itpp::MOG_generic::do_checks, itpp::MOG_generic::full, it_assert, itpp::MOG_generic::K, itpp::MOG_generic::paranoid, itpp::MOG_generic::set_diag_covs_unity_internal(), itpp::MOG_generic::set_full_covs_unity_internal(), itpp::MOG_generic::set_means(), itpp::MOG_generic::set_weights_uniform_internal(), itpp::MOG_generic::setup_misc(), itpp::Array< T >::size(), and itpp::MOG_generic::valid.

◆ init() [4/5]

void itpp::MOG_generic::init ( Array< vec > &  means_in,
Array< vec > &  diag_covs_in,
vec &  weights_in 
)
inherited

Initialise the model using user supplied parameters (diagonal covariance version)

Parameters
means_inArray of mean vectors
diag_covs_inArray of vectors representing diagonal covariances
weights_invector of weights
Note
The number of mean vectors, covariance vectors and weights must be the same

Definition at line 89 of file mog_generic.cpp.

References itpp::MOG_generic::check_array_uniformity(), itpp::MOG_generic::D, itpp::MOG_generic::do_checks, itpp::MOG_generic::full, it_assert, itpp::MOG_generic::K, itpp::MOG_generic::paranoid, itpp::MOG_generic::set_diag_covs_internal(), itpp::MOG_generic::set_means_internal(), itpp::MOG_generic::set_weights_internal(), itpp::MOG_generic::setup_misc(), itpp::Array< T >::size(), and itpp::MOG_generic::valid.

◆ init() [5/5]

void itpp::MOG_generic::init ( Array< vec > &  means_in,
Array< mat > &  full_covs_in,
vec &  weights_in 
)
inherited

Initialise the model using user supplied parameters (full covariance version)

Parameters
means_inArray of mean vectors
full_covs_inArray of covariance matrices
weights_invector of weights
Note
The number of mean vectors, covariance matrices and weights must be the same

Definition at line 110 of file mog_generic.cpp.

References itpp::MOG_generic::check_array_uniformity(), itpp::MOG_generic::D, itpp::MOG_generic::do_checks, itpp::MOG_generic::full, it_assert, itpp::MOG_generic::K, itpp::MOG_generic::paranoid, itpp::MOG_generic::set_full_covs_internal(), itpp::MOG_generic::set_means_internal(), itpp::MOG_generic::set_weights_internal(), itpp::MOG_generic::setup_misc(), itpp::Array< T >::size(), and itpp::MOG_generic::valid.

◆ is_valid()

bool itpp::MOG_generic::is_valid ( ) const
inlineinherited

Returns true if the model's parameters are valid.

Definition at line 154 of file mog_generic.h.

Referenced by itpp::MOG_generic::join(), ml(), and itpp::MOG_diag_kmeans_sup::run().

◆ is_full()

bool itpp::MOG_generic::is_full ( ) const
inlineinherited

Returns true if the model has full covariance matrices.

Definition at line 157 of file mog_generic.h.

References itpp::full().

Referenced by itpp::MOG_generic::join().

◆ get_K()

int itpp::MOG_generic::get_K ( ) const
inlineinherited

Return the number of Gaussians.

Definition at line 160 of file mog_generic.h.

Referenced by itpp::MOG_generic::join().

◆ get_D()

int itpp::MOG_generic::get_D ( ) const
inlineinherited

Return the dimensionality.

Definition at line 163 of file mog_generic.h.

Referenced by itpp::MOG_generic::join().

◆ get_weights()

vec itpp::MOG_generic::get_weights ( ) const
inlineinherited

Obtain a copy of the weight vector.

Definition at line 166 of file mog_generic.h.

Referenced by itpp::MOG_generic::join(), ml(), and itpp::MOG_diag_kmeans_sup::run().

◆ get_means()

Array< vec > itpp::MOG_generic::get_means ( ) const
inlineinherited

Obtain a copy of the array of mean vectors.

Definition at line 169 of file mog_generic.h.

Referenced by itpp::MOG_generic::join(), ml(), and itpp::MOG_diag_kmeans_sup::run().

◆ get_diag_covs()

Array< vec > itpp::MOG_generic::get_diag_covs ( ) const
inlineinherited

Obtain a copy of the array of diagonal covariance vectors.

Definition at line 172 of file mog_generic.h.

References itpp::full().

Referenced by itpp::MOG_generic::join(), ml(), and itpp::MOG_diag_kmeans_sup::run().

◆ get_full_covs()

Array< mat > itpp::MOG_generic::get_full_covs ( ) const
inlineinherited

Obtain a copy of the array of full covariance matrices.

Definition at line 175 of file mog_generic.h.

References itpp::full().

Referenced by itpp::MOG_generic::join().

◆ set_means()

void itpp::MOG_generic::set_means ( Array< vec > &  means_in)
inherited

Set the means of the model.

Note
The number of means must match the number of Gaussians in the model

Definition at line 351 of file mog_generic.cpp.

References itpp::MOG_generic::set_means_internal(), and itpp::MOG_generic::valid.

Referenced by itpp::MOG_generic::init().

◆ set_diag_covs()

void itpp::MOG_generic::set_diag_covs ( Array< vec > &  diag_covs_in)
inherited

Set the diagonal covariance vectors of the model.

Note
The number of diagonal covariance vectors must match the number of Gaussians in the model

Definition at line 365 of file mog_generic.cpp.

References itpp::MOG_generic::set_diag_covs_internal(), and itpp::MOG_generic::valid.

◆ set_full_covs()

void itpp::MOG_generic::set_full_covs ( Array< mat > &  full_covs_in)
inherited

Set the full covariance matrices of the model.

Note
The number of covariance matrices must match the number of Gaussians in the model

Definition at line 372 of file mog_generic.cpp.

References itpp::MOG_generic::set_full_covs_internal(), and itpp::MOG_generic::valid.

◆ set_weights()

void itpp::MOG_generic::set_weights ( vec &  weights_in)
inherited

Set the weight vector of the model.

Note
The number of elements in the weight vector must match the number of Gaussians in the model

Definition at line 379 of file mog_generic.cpp.

References itpp::MOG_generic::set_weights_internal(), and itpp::MOG_generic::valid.

◆ set_means_zero()

void itpp::MOG_generic::set_means_zero ( )
inherited

Set the means in the model to be zero.

Definition at line 358 of file mog_generic.cpp.

References itpp::MOG_generic::set_means_zero_internal(), and itpp::MOG_generic::valid.

◆ set_diag_covs_unity()

void itpp::MOG_generic::set_diag_covs_unity ( )
inherited

Set the diagonal covariance vectors to be unity.

Definition at line 386 of file mog_generic.cpp.

References itpp::MOG_generic::set_diag_covs_unity_internal(), and itpp::MOG_generic::valid.

◆ set_full_covs_unity()

void itpp::MOG_generic::set_full_covs_unity ( )
inherited

Set the full covariance matrices to be unity.

Definition at line 393 of file mog_generic.cpp.

References itpp::MOG_generic::set_full_covs_unity_internal(), and itpp::MOG_generic::valid.

◆ set_weights_uniform()

void itpp::MOG_generic::set_weights_uniform ( )
inherited

Set all the weights to 1/K, where K is the number of Gaussians.

Definition at line 400 of file mog_generic.cpp.

References itpp::MOG_generic::set_weights_uniform_internal(), and itpp::MOG_generic::valid.

◆ set_checks()

void itpp::MOG_generic::set_checks ( bool  do_checks_in)
inlineinherited

Enable/disable internal checks for likelihood functions.

Parameters
do_checks_inIf true, checks are enabled; if false, checks are disabled
Note
Disabling checks will provide a speedup in the likelihood functions. Disable them only when you're happy that everything is working correctly.

Definition at line 214 of file mog_generic.h.

◆ set_paranoid()

void itpp::MOG_generic::set_paranoid ( bool  paranoid_in)
inlineinherited

Enable/disable paranoia about numerical stability.

Parameters
paranoid_inIf true, calculate likelihoods using a safer, but slower method.

Definition at line 219 of file mog_generic.h.

◆ save()

void itpp::MOG_generic::save ( const std::string &  name_in) const
virtualinherited

Save the model's parameters to a model file.

Parameters
name_inThe model's filename

Definition at line 438 of file mog_generic.cpp.

References itpp::it_file::close(), itpp::MOG_generic::diag_covs, itpp::MOG_generic::full, itpp::MOG_generic::full_covs, itpp::MOG_generic::means, itpp::MOG_generic::valid, and itpp::MOG_generic::weights.

◆ join()

void itpp::MOG_generic::join ( const MOG_generic B_in)
virtualinherited

Mathematically join the model with a user supplied model.

Parameters
B_inuser supplied model
Note
The Arrays of mean vectors and covariance vectors/matrices from the two models are simply concatenated, while the weights of the resultant model are a function of the original weights and numbers of Gaussians from both models. Specifically, $ w_{new} = [ \alpha \cdot w_{A} ~~~ \beta \cdot w_{B} ]^T $, where $ w_{new} $ is the new weight vector, $ w_{A} $ and $ w_{B} $ are the weight vectors from model A and B, while $ \alpha = K_A / (K_A + KB_in) $ and $ \beta = 1-\alpha $. In turn, $ K_A $ and $ KB_in $ are the numbers of Gaussians in model A and B, respectively.

See On transforming statistical models... for more information.

Definition at line 453 of file mog_generic.cpp.

References itpp::concat(), itpp::MOG_generic::D, itpp::MOG_generic::diag_covs, itpp::MOG_generic::full, itpp::MOG_generic::full_covs, itpp::MOG_generic::get_D(), itpp::MOG_generic::get_diag_covs(), itpp::MOG_generic::get_full_covs(), itpp::MOG_generic::get_K(), itpp::MOG_generic::get_means(), itpp::MOG_generic::get_weights(), itpp::MOG_generic::init(), itpp::MOG_generic::is_full(), itpp::MOG_generic::is_valid(), it_assert, itpp::MOG_generic::K, itpp::MOG_generic::means, itpp::MOG_generic::valid, and itpp::MOG_generic::weights.

◆ convert_to_diag()

void itpp::MOG_generic::convert_to_diag ( )
virtualinherited

Convert the model to use diagonal covariances.

Note
If the model is already diagonal, nothing is done. If the model has full covariance matrices, this results in irreversible information loss (in effect the off-diagonal covariance elements are now zero)

Definition at line 499 of file mog_generic.cpp.

References itpp::MOG_generic::convert_to_diag_internal(), and itpp::MOG_generic::valid.

Referenced by itpp::MOG_diag::load().

◆ check_size() [1/2]

bool itpp::MOG_generic::check_size ( const vec &  x_in) const
protectedinherited

◆ check_size() [2/2]

bool itpp::MOG_generic::check_size ( const Array< vec > &  X_in) const
protectedinherited

Check if all vectors in Array X_in have the same dimensionality as the model.

Definition at line 137 of file mog_generic.cpp.

References itpp::MOG_generic::check_array_uniformity(), and itpp::MOG_generic::check_size().

◆ check_array_uniformity()

bool itpp::MOG_generic::check_array_uniformity ( const Array< vec > &  A) const
protectedinherited

Check if all vectors in Array X_in have the same dimensionality.

Definition at line 144 of file mog_generic.cpp.

References itpp::Array< T >::size(), and itpp::size().

Referenced by itpp::MOG_generic::check_size(), itpp::MOG_generic::init(), and ml().

◆ set_means_internal()

void itpp::MOG_generic::set_means_internal ( Array< vec > &  means_in)
protectedinherited

◆ set_diag_covs_internal()

void itpp::MOG_generic::set_diag_covs_internal ( Array< vec > &  diag_covs_in)
protectedinherited

◆ set_full_covs_internal()

void itpp::MOG_generic::set_full_covs_internal ( Array< mat > &  full_covs_in)
protectedinherited

◆ set_weights_internal()

void itpp::MOG_generic::set_weights_internal ( vec &  _weigths)
protectedinherited

◆ set_means_zero_internal()

void itpp::MOG_generic::set_means_zero_internal ( )
protectedinherited

◆ set_diag_covs_unity_internal()

void itpp::MOG_generic::set_diag_covs_unity_internal ( )
protectedinherited

◆ set_full_covs_unity_internal()

void itpp::MOG_generic::set_full_covs_unity_internal ( )
protectedinherited

◆ set_weights_uniform_internal()

void itpp::MOG_generic::set_weights_uniform_internal ( )
protectedinherited

◆ convert_to_diag_internal()

void itpp::MOG_generic::convert_to_diag_internal ( )
protectedinherited

◆ convert_to_full_internal()

void itpp::MOG_generic::convert_to_full_internal ( )
protectedinherited

Member Data Documentation

◆ verbose

bool itpp::MOG_diag_EM_sup::verbose
protected

Whether we print the progress.

Definition at line 62 of file mog_diag_em.h.

Referenced by ml(), and ml_iterate().

◆ N

int itpp::MOG_diag_EM_sup::N
protected

number of training vectors

Definition at line 65 of file mog_diag_em.h.

Referenced by ml(), and ml_update_params().

◆ max_iter

int itpp::MOG_diag_EM_sup::max_iter
protected

Maximum number of iterations.

Definition at line 68 of file mog_diag_em.h.

Referenced by ml(), and ml_iterate().

◆ c_X

double** itpp::MOG_diag_EM_sup::c_X
protected

'C' pointers to training vectors

Definition at line 71 of file mog_diag_em.h.

Referenced by ml(), and ml_update_params().

◆ var_floor

double itpp::MOG_diag_EM_sup::var_floor
protected

ADD DOCUMENTATION HERE.

Definition at line 74 of file mog_diag_em.h.

Referenced by ml(), and sanitise_params().

◆ weight_floor

double itpp::MOG_diag_EM_sup::weight_floor
protected

ADD DOCUMENTATION HERE.

Definition at line 76 of file mog_diag_em.h.

Referenced by ml(), and sanitise_params().

◆ c_means

double** itpp::MOG_diag::c_means
protectedinherited

◆ c_diag_covs

double** itpp::MOG_diag::c_diag_covs
protectedinherited

◆ c_diag_covs_inv_etc

double** itpp::MOG_diag::c_diag_covs_inv_etc
protectedinherited

◆ c_weights

double* itpp::MOG_diag::c_weights
protectedinherited

◆ c_log_weights

double* itpp::MOG_diag::c_log_weights
protectedinherited

◆ c_log_det_etc

double* itpp::MOG_diag::c_log_det_etc
protectedinherited

◆ do_checks

bool itpp::MOG_generic::do_checks
protectedinherited

◆ valid

bool itpp::MOG_generic::valid
protectedinherited

◆ full

bool itpp::MOG_generic::full
protectedinherited

◆ paranoid

bool itpp::MOG_generic::paranoid
protectedinherited

◆ K

int itpp::MOG_generic::K
protectedinherited

◆ D

int itpp::MOG_generic::D
protectedinherited

◆ means

Array<vec> itpp::MOG_generic::means
protectedinherited

◆ diag_covs

Array<vec> itpp::MOG_generic::diag_covs
protectedinherited

◆ full_covs

Array<mat> itpp::MOG_generic::full_covs
protectedinherited

◆ weights

vec itpp::MOG_generic::weights
protectedinherited

◆ log_max_K

double itpp::MOG_generic::log_max_K
protectedinherited

◆ log_det_etc

vec itpp::MOG_generic::log_det_etc
protectedinherited

Gaussian specific pre-calcualted constants.

Note
Vector of pre-calculated $ -\frac{D}{2}\log(2\pi) -\frac{1}{2}\log(|\Sigma|) $ for each Gaussian, where $ D $ is the dimensionality and $ |\Sigma| $ is the determinant for the Gaussian's covariance matrix $ \Sigma $.

Definition at line 317 of file mog_generic.h.

Referenced by itpp::MOG_generic::cleanup(), itpp::MOG_generic::log_lhood_single_gaus_internal(), itpp::MOG_diag::setup_covs(), and itpp::MOG_generic::setup_covs().

◆ log_weights

vec itpp::MOG_generic::log_weights
protectedinherited

◆ full_covs_inv

Array<mat> itpp::MOG_generic::full_covs_inv
protectedinherited

Pre-calcuated inverted version of each full covariance matrix.

Definition at line 323 of file mog_generic.h.

Referenced by itpp::MOG_generic::cleanup(), itpp::MOG_generic::log_lhood_single_gaus_internal(), and itpp::MOG_generic::setup_covs().

◆ diag_covs_inv_etc

Array<vec> itpp::MOG_generic::diag_covs_inv_etc
protectedinherited

Pre-calcuated inverted version of each diagonal covariance vector, where the covariance elements are first multiplied by two.

Definition at line 326 of file mog_generic.h.

Referenced by itpp::MOG_generic::cleanup(), itpp::MOG_generic::log_lhood_single_gaus_internal(), itpp::MOG_diag::setup_covs(), and itpp::MOG_generic::setup_covs().


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

Generated on Tue Aug 17 2021 10:59:15 for IT++ by Doxygen 1.9.4