00001
00030 #ifndef MOG_DIAG_KMEANS_H
00031 #define MOG_DIAG_KMEANS_H
00032
00033 #include <itpp/stat/mog_diag.h>
00034
00035
00036 namespace itpp
00037 {
00038
00043 class MOG_diag_kmeans_sup : public MOG_diag
00044 {
00045
00046 public:
00048 MOG_diag_kmeans_sup() { verbose = false; }
00049
00051 ~MOG_diag_kmeans_sup() { }
00052
00054 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);
00055
00056 protected:
00057
00059 inline double dist(const double * x, const double * y) const;
00061 void assign_to_means();
00063 void recalculate_means();
00065 bool dezombify_means();
00067 double measure_change() const;
00069 void initial_means();
00071 void iterate();
00073 void calc_means();
00075 void calc_covs();
00077 void calc_weights();
00079 void normalise_vectors();
00081 void unnormalise_vectors();
00083 void unnormalise_means();
00084
00086 int max_iter;
00087
00091 double trust;
00092
00094 bool verbose;
00095
00097 int N;
00098
00100 double ** c_X;
00101
00103 Array<vec> means_old;
00104
00106 double ** c_means_old;
00107
00109 Array<ivec> partitions;
00110
00112 int ** c_partitions;
00113
00115 ivec count;
00116
00118 int * c_count;
00119
00120 private:
00121
00122 vec norm_mu;
00123 double * c_norm_mu;
00124
00125 vec norm_sd;
00126 double * c_norm_sd;
00127
00128 vec tmpvec;
00129 double * c_tmpvec;
00130
00131
00132 };
00133
00134
00135
00136
00170 void 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);
00171
00172 }
00173
00174 #endif // #ifndef MOG_DIAG_KMEANS_H
00175