35 #include <itpp/itexports.h> 79 MOG_generic(
const int &K_in,
const int &D_in,
bool full_in =
false) { init(K_in, D_in, full_in); }
120 void init(
const int &K_in,
const int &D_in,
bool full_in =
false);
129 void init(
Array<vec> &means_in,
bool full_in =
false);
151 virtual void cleanup();
160 int get_K()
const {
if (valid)
return(K);
else return(0); }
163 int get_D()
const {
if (valid)
return(D);
else return(0); }
166 vec
get_weights()
const { vec tmp;
if (valid) { tmp = weights; }
return tmp; }
195 void set_weights(vec &weights_in);
198 void set_means_zero();
201 void set_diag_covs_unity();
204 void set_full_covs_unity();
207 void set_weights_uniform();
214 void set_checks(
bool do_checks_in) { do_checks = do_checks_in; }
224 virtual void load(
const std::string &name_in);
229 virtual void save(
const std::string &name_in)
const;
256 virtual void convert_to_diag();
263 virtual void convert_to_full();
266 virtual double log_lhood_single_gaus(
const vec &x_in,
const int k);
269 virtual double log_lhood(
const vec &x_in);
272 virtual double lhood(
const vec &x_in);
275 virtual double avg_log_lhood(
const Array<vec> &X_in);
329 bool check_size(
const vec &x_in)
const;
332 bool check_size(
const Array<vec> &X_in)
const;
335 bool check_array_uniformity(
const Array<vec> & A)
const;
338 void set_means_internal(
Array<vec> &means_in);
340 void set_diag_covs_internal(
Array<vec> &diag_covs_in);
342 void set_full_covs_internal(
Array<mat> &full_covs_in);
344 void set_weights_internal(vec &_weigths);
347 void set_means_zero_internal();
349 void set_diag_covs_unity_internal();
351 void set_full_covs_unity_internal();
353 void set_weights_uniform_internal();
356 void convert_to_diag_internal();
358 void convert_to_full_internal();
361 virtual void setup_means();
364 virtual void setup_covs();
367 virtual void setup_weights();
370 virtual void setup_misc();
373 virtual double log_lhood_single_gaus_internal(
const vec &x_in,
const int k);
375 virtual double log_lhood_internal(
const vec &x_in);
377 virtual double lhood_internal(
const vec &x_in);
387 #endif // #ifndef MOG_GENERIC_H bool is_full() const
Returns true if the model has full covariance matrices.
MOG_generic(const int &K_in, const int &D_in, bool full_in=false)
construct a default model (all Gaussians have zero mean and unit variance for all dimensions) ...
Array< mat > get_full_covs() const
Obtain a copy of the array of full covariance matrices.
Array< vec > get_means() const
Obtain a copy of the array of mean vectors.
Array< vec > get_diag_covs() const
Obtain a copy of the array of diagonal covariance vectors.
MOG_generic(Array< vec > &means_in, Array< mat > &full_covs_in, vec &weights_in)
Construct a model using user supplied parameters (full covariance version)
void set_paranoid(bool paranoid_in)
Enable/disable paranoia about numerical stability.
bool is_valid() const
Returns true if the model's parameters are valid.
Array< mat > full_covs
full covariance matrices
MOG_generic(Array< vec > &means_in, Array< vec > &diag_covs_in, vec &weights_in)
Construct a model using user supplied parameters (diagonal covariance version)
Definition of Array class (container)
Import/Export definitions for some templates defined in base folder.
Matrix Class Definitions.
vec log_weights
Pre-calculated log versions of the weights.
bool full
indicates whether we are using full or diagonal covariance matrices
Generic Mixture of Gaussians (MOG) class. Used as a base for other MOG classes.
Array< vec > diag_covs_inv_etc
Pre-calcuated inverted version of each diagonal covariance vector, where the covariance elements are ...
bool do_checks
indicates whether checks on input data are done
int get_D() const
Return the dimensionality.
Mat< T > full(const Sparse_Mat< T > &s)
Convert a sparse matrix s into its dense representation.
MOG_generic(const std::string &name_in)
Construct the MOG_generic object by loading the parameters from a model file.
Array< mat > full_covs_inv
Pre-calcuated inverted version of each full covariance matrix.
void set_checks(bool do_checks_in)
Enable/disable internal checks for likelihood functions.
MOG_generic(Array< vec > &means_in, bool full_in=false)
Construct a model using user supplied mean vectors.
vec log_det_etc
Gaussian specific pre-calcualted constants.
bool paranoid
indicates whether we are paranoid about numerical stability
vec get_weights() const
Obtain a copy of the weight vector.
virtual ~MOG_generic()
Default destructor.
bool valid
indicates whether the parameters are valid
Array< vec > diag_covs
diagonal covariance matrices, stored as vectors
double log_max_K
Pre-calcualted std::log(std::numeric_limits<double>::max() / K), where K is the number of Gaussians...
int get_K() const
Return the number of Gaussians.
MOG_generic()
Default constructor.
Templated Vector Class Definitions.