IT++ Logo
mog_diag_kmeans.h
Go to the documentation of this file.
1
30#ifndef MOG_DIAG_KMEANS_H
31#define MOG_DIAG_KMEANS_H
32
33#include <itpp/stat/mog_diag.h>
34#include <itpp/itexports.h>
36
37namespace itpp
38{
39
44class ITPP_EXPORT MOG_diag_kmeans_sup : public MOG_diag
45{
46
47public:
49 MOG_diag_kmeans_sup() { verbose = false; }
50
53
55 void run(MOG_diag &model_in, Array<vec> &X_in, int max_iter_in = 10, double trust_in = 0.5, bool normalise_in = true, bool verbose_in = false);
56
57protected:
58
60 inline double dist(const double * x, const double * y) const;
62 void assign_to_means();
64 void recalculate_means();
66 bool dezombify_means();
68 double measure_change() const;
70 void initial_means();
72 void iterate();
74 void calc_means();
76 void calc_covs();
78 void calc_weights();
80 void normalise_vectors();
82 void unnormalise_vectors();
84 void unnormalise_means();
85
88
92 double trust;
93
95 bool verbose;
96
98 int N;
99
101 double ** c_X;
102
105
107 double ** c_means_old;
108
111
114
116 ivec count;
117
119 int * c_count;
120
121private:
122
123 vec norm_mu;
124 double * c_norm_mu;
125
126 vec norm_sd;
127 double * c_norm_sd;
128
129 vec tmpvec;
130 double * c_tmpvec;
131
132
133};
134
135//
136// convenience functions
137
171void MOG_diag_kmeans(MOG_diag &model_in, Array<vec> &X_in, int max_iter_in = 10, double trust_in = 0.5, bool normalise_in = true, bool verbose_in = false);
172
173}
174
175#endif // #ifndef MOG_DIAG_KMEANS_H
176
Import/Export definitions for some templates defined in base folder.
support class for MOG_diag_kmeans()
int * c_count
'C' pointer to the count vector
int N
number of training vectors
double ** c_X
'C' pointers to training vectors
Array< vec > means_old
means from the previous iteration, used to measure progress
~MOG_diag_kmeans_sup()
Default destructor.
int ** c_partitions
'C' pointers to partition vectors
MOG_diag_kmeans_sup()
Default constructor.
double ** c_means_old
'C' pointers to old means
int max_iter
Maximum number of iterations.
double trust
trust factor, where 0 <= trust <= 1.
ivec count
keeps a count of the number of vectors assigned to each mean
Array< ivec > partitions
contains indices of vectors assigned to each mean
bool verbose
Whether we print the progress.
Diagonal Mixture of Gaussians (MOG) class.
Definition: mog_diag.h:56
void MOG_diag_kmeans(MOG_diag &model_in, Array< vec > &X_in, int max_iter_in, double trust_in, bool normalise_in, bool verbose_in)
Diagonal Mixture of Gaussians class - header file.
itpp namespace
Definition: itmex.h:37
SourceForge Logo

Generated on Sun Jun 5 2022 21:26:42 for IT++ by Doxygen 1.9.3