\section{G\+MM Class Reference}
\label{classmlpack_1_1gmm_1_1GMM}\index{G\+MM@{G\+MM}}


A Gaussian Mixture Model (\doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM}).  


\subsection*{Public Member Functions}
\begin{DoxyCompactItemize}
\item 
\textbf{ G\+MM} ()
\begin{DoxyCompactList}\small\item\em Create an empty Gaussian Mixture Model, with zero gaussians. \end{DoxyCompactList}\item 
\textbf{ G\+MM} (const size\+\_\+t gaussians, const size\+\_\+t dimensionality)
\begin{DoxyCompactList}\small\item\em Create a \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM} with the given number of Gaussians, each of which have the specified dimensionality. \end{DoxyCompactList}\item 
\textbf{ G\+MM} (const std\+::vector$<$ \textbf{ distribution\+::\+Gaussian\+Distribution} $>$ \&dists, const arma\+::vec \&weights)
\begin{DoxyCompactList}\small\item\em Create a \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM} with the given dists and weights. \end{DoxyCompactList}\item 
\textbf{ G\+MM} (const \textbf{ G\+MM} \&other)
\begin{DoxyCompactList}\small\item\em Copy constructor for G\+M\+Ms. \end{DoxyCompactList}\item 
void \textbf{ Classify} (const arma\+::mat \&observations, arma\+::\+Row$<$ size\+\_\+t $>$ \&labels) const
\begin{DoxyCompactList}\small\item\em Classify the given observations as being from an individual component in this \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM}. \end{DoxyCompactList}\item 
const \textbf{ distribution\+::\+Gaussian\+Distribution} \& \textbf{ Component} (size\+\_\+t i) const
\begin{DoxyCompactList}\small\item\em Return a const reference to a component distribution. \end{DoxyCompactList}\item 
\textbf{ distribution\+::\+Gaussian\+Distribution} \& \textbf{ Component} (size\+\_\+t i)
\begin{DoxyCompactList}\small\item\em Return a reference to a component distribution. \end{DoxyCompactList}\item 
size\+\_\+t \textbf{ Dimensionality} () const
\begin{DoxyCompactList}\small\item\em Return the dimensionality of the model. \end{DoxyCompactList}\item 
size\+\_\+t \textbf{ Gaussians} () const
\begin{DoxyCompactList}\small\item\em Return the number of gaussians in the model. \end{DoxyCompactList}\item 
double \textbf{ Log\+Probability} (const arma\+::vec \&observation) const
\begin{DoxyCompactList}\small\item\em Return the log probability that the given observation came from this distribution. \end{DoxyCompactList}\item 
double \textbf{ Log\+Probability} (const arma\+::vec \&observation, const size\+\_\+t component) const
\begin{DoxyCompactList}\small\item\em Return the log probability that the given observation came from the given Gaussian component in this distribution. \end{DoxyCompactList}\item 
\textbf{ G\+MM} \& \textbf{ operator=} (const \textbf{ G\+MM} \&other)
\begin{DoxyCompactList}\small\item\em Copy operator for G\+M\+Ms. \end{DoxyCompactList}\item 
double \textbf{ Probability} (const arma\+::vec \&observation) const
\begin{DoxyCompactList}\small\item\em Return the probability that the given observation came from this distribution. \end{DoxyCompactList}\item 
double \textbf{ Probability} (const arma\+::vec \&observation, const size\+\_\+t component) const
\begin{DoxyCompactList}\small\item\em Return the probability that the given observation came from the given Gaussian component in this distribution. \end{DoxyCompactList}\item 
arma\+::vec \textbf{ Random} () const
\begin{DoxyCompactList}\small\item\em Return a randomly generated observation according to the probability distribution defined by this object. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Archive $>$ }\\void \textbf{ serialize} (Archive \&ar, const unsigned int)
\begin{DoxyCompactList}\small\item\em Serialize the \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM}. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Fitting\+Type  = E\+M\+Fit$<$$>$$>$ }\\double \textbf{ Train} (const arma\+::mat \&observations, const size\+\_\+t trials=1, const bool use\+Existing\+Model=false, Fitting\+Type fitter=Fitting\+Type())
\begin{DoxyCompactList}\small\item\em Estimate the probability distribution directly from the given observations, using the given algorithm in the Fitting\+Type class to fit the data. \end{DoxyCompactList}\item 
{\footnotesize template$<$typename Fitting\+Type  = E\+M\+Fit$<$$>$$>$ }\\double \textbf{ Train} (const arma\+::mat \&observations, const arma\+::vec \&probabilities, const size\+\_\+t trials=1, const bool use\+Existing\+Model=false, Fitting\+Type fitter=Fitting\+Type())
\begin{DoxyCompactList}\small\item\em Estimate the probability distribution directly from the given observations, taking into account the probability of each observation actually being from this distribution, and using the given algorithm in the Fitting\+Type class to fit the data. \end{DoxyCompactList}\item 
const arma\+::vec \& \textbf{ Weights} () const
\begin{DoxyCompactList}\small\item\em Return a const reference to the a priori weights of each Gaussian. \end{DoxyCompactList}\item 
arma\+::vec \& \textbf{ Weights} ()
\begin{DoxyCompactList}\small\item\em Return a reference to the a priori weights of each Gaussian. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
A Gaussian Mixture Model (\doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM}). 

This class uses maximum likelihood loss functions to estimate the parameters of the \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM} on a given dataset via the given fitting mechanism, defined by the Fitting\+Type template parameter. The \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM} can be trained using normal data, or data with probabilities of being from this \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM} (see \doxyref{G\+M\+M\+::\+Train()}{p.}{classmlpack_1_1gmm_1_1GMM_ad33ec5cf10980e0b315280ea51ef41ed} for more information).

The \doxyref{Train()}{p.}{classmlpack_1_1gmm_1_1GMM_ad33ec5cf10980e0b315280ea51ef41ed} method uses a template type \textquotesingle{}Fitting\+Type\textquotesingle{}. The Fitting\+Type template class must provide a way for the \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM} to train on data. It must provide the following two functions\+:


\begin{DoxyCode}
\textcolor{keywordtype}{void} Estimate(\textcolor{keyword}{const} arma::mat& observations,
              std::vector<distribution::GaussianDistribution>& dists,
              arma::vec& weights);

\textcolor{keywordtype}{void} Estimate(\textcolor{keyword}{const} arma::mat& observations,
              \textcolor{keyword}{const} arma::vec& probabilities,
              std::vector<distribution::GaussianDistribution>& dists,
              arma::vec& weights);
\end{DoxyCode}


These functions should produce a trained \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM} from the given observations and probabilities. These may modify the size of the model (by increasing the size of the mean and covariance vectors as well as the weight vectors), but the method should expect that these vectors are already set to the size of the \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM} as specified in the constructor.

For a sample implementation, see the \doxyref{E\+M\+Fit}{p.}{classmlpack_1_1gmm_1_1EMFit} class; this class uses the EM algorithm to train a \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM}, and is the default fitting type for the \doxyref{Train()}{p.}{classmlpack_1_1gmm_1_1GMM_ad33ec5cf10980e0b315280ea51ef41ed} method.

The \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM}, once trained, can be used to generate random points from the distribution and estimate the probability of points being from the distribution. The parameters of the \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM} can be obtained through the accessors and mutators.

Example use\+:


\begin{DoxyCode}
\textcolor{comment}{// Set up a mixture of 5 gaussians in a 4-dimensional space.}
GMM g(5, 4);

\textcolor{comment}{// Train the GMM given the data observations, using the default EM fitting}
\textcolor{comment}{// mechanism.}
g.Train(data);

\textcolor{comment}{// Get the probability of 'observation' being observed from this GMM.}
\textcolor{keywordtype}{double} probability = g.Probability(observation);

\textcolor{comment}{// Get a random observation from the GMM.}
arma::vec observation = g.Random();
\end{DoxyCode}
 

Definition at line 78 of file gmm.\+hpp.



\subsection{Constructor \& Destructor Documentation}
\mbox{\label{classmlpack_1_1gmm_1_1GMM_a0848a828790e4f2dcebd3be297c31622}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!G\+MM@{G\+MM}}
\index{G\+MM@{G\+MM}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{G\+M\+M()\hspace{0.1cm}{\footnotesize\ttfamily [1/4]}}
{\footnotesize\ttfamily \textbf{ G\+MM} (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Create an empty Gaussian Mixture Model, with zero gaussians. 



Definition at line 96 of file gmm.\+hpp.



References Log\+::\+Debug.



Referenced by G\+M\+M\+::\+G\+M\+M().

\mbox{\label{classmlpack_1_1gmm_1_1GMM_a0eab6782f1e56e70f455efd424970942}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!G\+MM@{G\+MM}}
\index{G\+MM@{G\+MM}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{G\+M\+M()\hspace{0.1cm}{\footnotesize\ttfamily [2/4]}}
{\footnotesize\ttfamily \textbf{ G\+MM} (\begin{DoxyParamCaption}\item[{const size\+\_\+t}]{gaussians,  }\item[{const size\+\_\+t}]{dimensionality }\end{DoxyParamCaption})}



Create a \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM} with the given number of Gaussians, each of which have the specified dimensionality. 

The means and covariances will be set to 0.


\begin{DoxyParams}{Parameters}
{\em gaussians} & Number of Gaussians in this \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM}. \\
\hline
{\em dimensionality} & Dimensionality of each Gaussian. \\
\hline
\end{DoxyParams}
\mbox{\label{classmlpack_1_1gmm_1_1GMM_a6c36db07dcbd3c3236596baaf55cd373}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!G\+MM@{G\+MM}}
\index{G\+MM@{G\+MM}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{G\+M\+M()\hspace{0.1cm}{\footnotesize\ttfamily [3/4]}}
{\footnotesize\ttfamily \textbf{ G\+MM} (\begin{DoxyParamCaption}\item[{const std\+::vector$<$ \textbf{ distribution\+::\+Gaussian\+Distribution} $>$ \&}]{dists,  }\item[{const arma\+::vec \&}]{weights }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Create a \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM} with the given dists and weights. 


\begin{DoxyParams}{Parameters}
{\em dists} & Distributions of the model. \\
\hline
{\em weights} & Weights of the model. \\
\hline
\end{DoxyParams}


Definition at line 122 of file gmm.\+hpp.



References G\+M\+M\+::\+G\+M\+M(), and G\+M\+M\+::operator=().

\mbox{\label{classmlpack_1_1gmm_1_1GMM_aa31455d0c337b178db5c068062a0288a}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!G\+MM@{G\+MM}}
\index{G\+MM@{G\+MM}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{G\+M\+M()\hspace{0.1cm}{\footnotesize\ttfamily [4/4]}}
{\footnotesize\ttfamily \textbf{ G\+MM} (\begin{DoxyParamCaption}\item[{const \textbf{ G\+MM} \&}]{other }\end{DoxyParamCaption})}



Copy constructor for G\+M\+Ms. 



\subsection{Member Function Documentation}
\mbox{\label{classmlpack_1_1gmm_1_1GMM_a4e6c4f4110899f4f4fd18b46d3d141c6}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!Classify@{Classify}}
\index{Classify@{Classify}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{Classify()}
{\footnotesize\ttfamily void Classify (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{observations,  }\item[{arma\+::\+Row$<$ size\+\_\+t $>$ \&}]{labels }\end{DoxyParamCaption}) const}



Classify the given observations as being from an individual component in this \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM}. 

The resultant classifications are stored in the \textquotesingle{}labels\textquotesingle{} object, and each label will be between 0 and (\doxyref{Gaussians()}{p.}{classmlpack_1_1gmm_1_1GMM_a130ce966c49ab36f847f8fac950f1e39} -\/ 1). Supposing that a point was classified with label 2, and that our \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM} object was called \textquotesingle{}gmm\textquotesingle{}, one could access the relevant Gaussian distribution as follows\+:


\begin{DoxyCode}
arma::vec mean = gmm.Means()[2];
arma::mat covariance = gmm.Covariances()[2];
\textcolor{keywordtype}{double} priorWeight = gmm.Weights()[2];
\end{DoxyCode}



\begin{DoxyParams}{Parameters}
{\em observations} & List of observations to classify. \\
\hline
{\em labels} & Object which will be filled with labels. \\
\hline
\end{DoxyParams}


Referenced by G\+M\+M\+::\+Weights().

\mbox{\label{classmlpack_1_1gmm_1_1GMM_a14b393b6da8638dcc2d27c878e2e5c35}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!Component@{Component}}
\index{Component@{Component}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{Component()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily const \textbf{ distribution\+::\+Gaussian\+Distribution}\& Component (\begin{DoxyParamCaption}\item[{size\+\_\+t}]{i }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return a const reference to a component distribution. 


\begin{DoxyParams}{Parameters}
{\em i} & Index of component. \\
\hline
\end{DoxyParams}


Definition at line 145 of file gmm.\+hpp.

\mbox{\label{classmlpack_1_1gmm_1_1GMM_a91d594ca41a307e58506ca5f57a6b0c0}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!Component@{Component}}
\index{Component@{Component}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{Component()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily \textbf{ distribution\+::\+Gaussian\+Distribution}\& Component (\begin{DoxyParamCaption}\item[{size\+\_\+t}]{i }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Return a reference to a component distribution. 


\begin{DoxyParams}{Parameters}
{\em i} & Index of component. \\
\hline
\end{DoxyParams}


Definition at line 152 of file gmm.\+hpp.

\mbox{\label{classmlpack_1_1gmm_1_1GMM_a78eda6bfb9e9462afa0fc85e32abe1af}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!Dimensionality@{Dimensionality}}
\index{Dimensionality@{Dimensionality}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{Dimensionality()}
{\footnotesize\ttfamily size\+\_\+t Dimensionality (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return the dimensionality of the model. 



Definition at line 138 of file gmm.\+hpp.

\mbox{\label{classmlpack_1_1gmm_1_1GMM_a130ce966c49ab36f847f8fac950f1e39}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!Gaussians@{Gaussians}}
\index{Gaussians@{Gaussians}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{Gaussians()}
{\footnotesize\ttfamily size\+\_\+t Gaussians (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return the number of gaussians in the model. 



Definition at line 136 of file gmm.\+hpp.

\mbox{\label{classmlpack_1_1gmm_1_1GMM_a7063c1fb92f512f32bf44542c7528739}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!Log\+Probability@{Log\+Probability}}
\index{Log\+Probability@{Log\+Probability}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{Log\+Probability()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily double Log\+Probability (\begin{DoxyParamCaption}\item[{const arma\+::vec \&}]{observation }\end{DoxyParamCaption}) const}



Return the log probability that the given observation came from this distribution. 


\begin{DoxyParams}{Parameters}
{\em observation} & Observation to evaluate the probability of. \\
\hline
\end{DoxyParams}


Referenced by G\+M\+M\+::\+Weights().

\mbox{\label{classmlpack_1_1gmm_1_1GMM_a5df8a8ba219eda2fb45a1f24e18a6320}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!Log\+Probability@{Log\+Probability}}
\index{Log\+Probability@{Log\+Probability}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{Log\+Probability()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily double Log\+Probability (\begin{DoxyParamCaption}\item[{const arma\+::vec \&}]{observation,  }\item[{const size\+\_\+t}]{component }\end{DoxyParamCaption}) const}



Return the log probability that the given observation came from the given Gaussian component in this distribution. 


\begin{DoxyParams}{Parameters}
{\em observation} & Observation to evaluate the probability of. \\
\hline
{\em component} & Index of the component of the \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM} to be considered. \\
\hline
\end{DoxyParams}
\mbox{\label{classmlpack_1_1gmm_1_1GMM_a06fc875f2c82e831a10a7c38f9919cb3}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!operator=@{operator=}}
\index{operator=@{operator=}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{operator=()}
{\footnotesize\ttfamily \textbf{ G\+MM}\& operator= (\begin{DoxyParamCaption}\item[{const \textbf{ G\+MM} \&}]{other }\end{DoxyParamCaption})}



Copy operator for G\+M\+Ms. 



Referenced by G\+M\+M\+::\+G\+M\+M().

\mbox{\label{classmlpack_1_1gmm_1_1GMM_ab72935d592516e77511d0b5e703c0d41}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!Probability@{Probability}}
\index{Probability@{Probability}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{Probability()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily double Probability (\begin{DoxyParamCaption}\item[{const arma\+::vec \&}]{observation }\end{DoxyParamCaption}) const}



Return the probability that the given observation came from this distribution. 


\begin{DoxyParams}{Parameters}
{\em observation} & Observation to evaluate the probability of. \\
\hline
\end{DoxyParams}


Referenced by G\+M\+M\+::\+Weights().

\mbox{\label{classmlpack_1_1gmm_1_1GMM_afcd98507a97e8592a6e10b2794285224}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!Probability@{Probability}}
\index{Probability@{Probability}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{Probability()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily double Probability (\begin{DoxyParamCaption}\item[{const arma\+::vec \&}]{observation,  }\item[{const size\+\_\+t}]{component }\end{DoxyParamCaption}) const}



Return the probability that the given observation came from the given Gaussian component in this distribution. 


\begin{DoxyParams}{Parameters}
{\em observation} & Observation to evaluate the probability of. \\
\hline
{\em component} & Index of the component of the \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM} to be considered. \\
\hline
\end{DoxyParams}
\mbox{\label{classmlpack_1_1gmm_1_1GMM_a2c6f8d5bb4eacf7de767d2172b320756}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!Random@{Random}}
\index{Random@{Random}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{Random()}
{\footnotesize\ttfamily arma\+::vec Random (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const}



Return a randomly generated observation according to the probability distribution defined by this object. 

\begin{DoxyReturn}{Returns}
Random observation from this \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM}. 
\end{DoxyReturn}


Referenced by G\+M\+M\+::\+Weights().

\mbox{\label{classmlpack_1_1gmm_1_1GMM_af0dd9205158ccf7bcfcd8ff81f79c927}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!serialize@{serialize}}
\index{serialize@{serialize}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{serialize()}
{\footnotesize\ttfamily void serialize (\begin{DoxyParamCaption}\item[{Archive \&}]{ar,  }\item[{const unsigned}]{int }\end{DoxyParamCaption})}



Serialize the \doxyref{G\+MM}{p.}{classmlpack_1_1gmm_1_1GMM}. 



Referenced by G\+M\+M\+::\+Weights().

\mbox{\label{classmlpack_1_1gmm_1_1GMM_ad33ec5cf10980e0b315280ea51ef41ed}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!Train@{Train}}
\index{Train@{Train}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{Train()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily double Train (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{observations,  }\item[{const size\+\_\+t}]{trials = {\ttfamily 1},  }\item[{const bool}]{use\+Existing\+Model = {\ttfamily false},  }\item[{Fitting\+Type}]{fitter = {\ttfamily FittingType()} }\end{DoxyParamCaption})}



Estimate the probability distribution directly from the given observations, using the given algorithm in the Fitting\+Type class to fit the data. 

The fitting will be performed \textquotesingle{}trials\textquotesingle{} times; from these trials, the model with the greatest log-\/likelihood will be selected. By default, only one trial is performed. The log-\/likelihood of the best fitting is returned.

Optionally, the existing model can be used as an initial model for the estimation by setting \textquotesingle{}use\+Existing\+Model\textquotesingle{} to true. If the fitting procedure is deterministic after the initial position is given, then \textquotesingle{}trials\textquotesingle{} should be set to 1.


\begin{DoxyTemplParams}{Template Parameters}
{\em Fitting\+Type} & The type of fitting method which should be used (E\+M\+Fit$<$$>$ is suggested). \\
\hline
\end{DoxyTemplParams}

\begin{DoxyParams}{Parameters}
{\em observations} & Observations of the model. \\
\hline
{\em trials} & Number of trials to perform; the model in these trials with the greatest log-\/likelihood will be selected. \\
\hline
{\em use\+Existing\+Model} & If true, the existing model is used as an initial model for the estimation. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The log-\/likelihood of the best fit. 
\end{DoxyReturn}


Referenced by G\+M\+M\+::\+Weights().

\mbox{\label{classmlpack_1_1gmm_1_1GMM_a6c28af6823c03973003fefdf026b2b53}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!Train@{Train}}
\index{Train@{Train}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{Train()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily double Train (\begin{DoxyParamCaption}\item[{const arma\+::mat \&}]{observations,  }\item[{const arma\+::vec \&}]{probabilities,  }\item[{const size\+\_\+t}]{trials = {\ttfamily 1},  }\item[{const bool}]{use\+Existing\+Model = {\ttfamily false},  }\item[{Fitting\+Type}]{fitter = {\ttfamily FittingType()} }\end{DoxyParamCaption})}



Estimate the probability distribution directly from the given observations, taking into account the probability of each observation actually being from this distribution, and using the given algorithm in the Fitting\+Type class to fit the data. 

The fitting will be performed \textquotesingle{}trials\textquotesingle{} times; from these trials, the model with the greatest log-\/likelihood will be selected. By default, only one trial is performed. The log-\/likelihood of the best fitting is returned.

Optionally, the existing model can be used as an initial model for the estimation by setting \textquotesingle{}use\+Existing\+Model\textquotesingle{} to true. If the fitting procedure is deterministic after the initial position is given, then \textquotesingle{}trials\textquotesingle{} should be set to 1.


\begin{DoxyParams}{Parameters}
{\em observations} & Observations of the model. \\
\hline
{\em probabilities} & Probability of each observation being from this distribution. \\
\hline
{\em trials} & Number of trials to perform; the model in these trials with the greatest log-\/likelihood will be selected. \\
\hline
{\em use\+Existing\+Model} & If true, the existing model is used as an initial model for the estimation. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The log-\/likelihood of the best fit. 
\end{DoxyReturn}
\mbox{\label{classmlpack_1_1gmm_1_1GMM_ab2c1e663a100784ff6753e3eec8453dd}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!Weights@{Weights}}
\index{Weights@{Weights}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{Weights()\hspace{0.1cm}{\footnotesize\ttfamily [1/2]}}
{\footnotesize\ttfamily const arma\+::vec\& Weights (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}



Return a const reference to the a priori weights of each Gaussian. 



Definition at line 155 of file gmm.\+hpp.

\mbox{\label{classmlpack_1_1gmm_1_1GMM_a8361070d4a9097e29c005dd5dc6ca54d}} 
\index{mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}!Weights@{Weights}}
\index{Weights@{Weights}!mlpack\+::gmm\+::\+G\+MM@{mlpack\+::gmm\+::\+G\+MM}}
\subsubsection{Weights()\hspace{0.1cm}{\footnotesize\ttfamily [2/2]}}
{\footnotesize\ttfamily arma\+::vec\& Weights (\begin{DoxyParamCaption}{ }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}



Return a reference to the a priori weights of each Gaussian. 



Definition at line 157 of file gmm.\+hpp.



References G\+M\+M\+::\+Classify(), G\+M\+M\+::\+Log\+Probability(), G\+M\+M\+::\+Probability(), G\+M\+M\+::\+Random(), G\+M\+M\+::serialize(), and G\+M\+M\+::\+Train().



The documentation for this class was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
/var/www/mlpack.\+ratml.\+org/mlpack.\+org/\+\_\+src/mlpack-\/3.\+3.\+1/src/mlpack/methods/gmm/\textbf{ gmm.\+hpp}\end{DoxyCompactItemize}
