30 #ifndef GRT_GAUSSIAN_MIXTURE_MODELS_HEADER
31 #define GRT_GAUSSIAN_MIXTURE_MODELS_HEADER
33 #include "../../CoreModules/Clusterer.h"
43 GaussianMixtureModels(
const UINT numClusters=10,
const UINT minNumEpochs=5,
const UINT maxNumEpochs=1000,
const Float minChange=1.0e-5);
123 virtual bool saveModelToFile( std::fstream &file )
const;
132 virtual bool loadModelFromFile( std::fstream &file );
161 if( k < numClusters && trained ){
168 using MLBase::saveModelToFile;
169 using MLBase::loadModelFromFile;
174 bool computeInvAndDet();
175 inline void SWAP(UINT &a,UINT &b);
176 inline Float SQR(
const Float v){
return v*v; }
183 const UINT N = (UINT)x.size();
187 y = (1.0/pow(TWO_PI,N/2.0)) * (1.0/pow(det[clusterIndex],0.5));
192 temp[i] += (x[j]-mu[clusterIndex][j]) * invSigma[clusterIndex][j][i];
194 sum += (x[i]-mu[clusterIndex][i]) * temp[i];
197 return ( y*exp( -0.5*sum ) );
216 #endif //GRT_GAUSSIAN_MIXTURE_MODELS_HEADER
virtual bool predict_(VectorFloat &inputVector)
MatrixFloat getSigma(const UINT k) const
VectorDouble lndets
A vector holding the log detminants of SIGMA'k.
Float loglike
The current loglikelihood value of the models given the data.
virtual bool deepCopyFrom(const Clusterer *clusterer)
MatrixFloat getMu() const
MatrixFloat mu
A matrix holding the estimated mean values of each Gaussian.
Vector< MatrixFloat > getSigma() const
VectorDouble frac
A vector holding the P(k)'s.
virtual bool train_(MatrixFloat &trainingData)
MatrixFloat resp
The responsibility matrix.
UINT numTrainingSamples
The number of samples in the training data.