IT++ Logo

mog_diag_kmeans.h

Go to the documentation of this file.
00001 
00031 #ifndef MOG_DIAG_KMEANS_H
00032 #define MOG_DIAG_KMEANS_H
00033 
00034 #include <itpp/stat/mog_diag.h>
00035 
00036 
00037 namespace itpp
00038 {
00039 
00044 class MOG_diag_kmeans_sup : public MOG_diag
00045 {
00046 
00047 public:
00049   MOG_diag_kmeans_sup() { verbose = false; }
00050 
00052   ~MOG_diag_kmeans_sup() { }
00053 
00055   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);
00056 
00057 protected:
00058 
00060   inline double dist(const double * x, const double * y) const;
00062   void assign_to_means();
00064   void recalculate_means();
00066   bool dezombify_means();
00068   double measure_change() const;
00070   void initial_means();
00072   void iterate();
00074   void calc_means();
00076   void calc_covs();
00078   void calc_weights();
00080   void normalise_vectors();
00082   void unnormalise_vectors();
00084   void unnormalise_means();
00085 
00087   int max_iter;
00088 
00092   double trust;
00093 
00095   bool verbose;
00096 
00098   int N;
00099 
00101   double ** c_X;
00102 
00104   Array<vec> means_old;
00105 
00107   double ** c_means_old;
00108 
00110   Array<ivec> partitions;
00111 
00113   int ** c_partitions;
00114 
00116   ivec count;
00117 
00119   int * c_count;
00120 
00121 private:
00122 
00123   vec norm_mu;
00124   double * c_norm_mu;
00125 
00126   vec norm_sd;
00127   double * c_norm_sd;
00128 
00129   vec tmpvec;
00130   double * c_tmpvec;
00131 
00132 
00133 };
00134 
00135 //
00136 // convenience functions
00137 
00171 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);
00172 
00173 }
00174 
00175 #endif  // #ifndef MOG_DIAG_KMEANS_H
00176 
SourceForge Logo

Generated on Fri Aug 14 15:28:29 2009 for IT++ by Doxygen 1.5.9