\hypertarget{classMixEF}{
\section{MixEF Class Reference}
\label{classMixEF}\index{MixEF@{MixEF}}
}
Mixture of Exponential Family Densities.  


{\tt \#include $<$mixef.h$>$}

Inheritance diagram for MixEF:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=43pt]{classMixEF__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for MixEF:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=400pt]{classMixEF__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
\hypertarget{classMixEF_509ac467674c39af46aba42297528aad}{
\hyperlink{classMixEF_509ac467674c39af46aba42297528aad}{MixEF} (const Array$<$ \hyperlink{classBMEF}{BMEF} $\ast$ $>$ \&Coms0, const vec \&alpha0)}
\label{classMixEF_509ac467674c39af46aba42297528aad}

\begin{CompactList}\small\item\em Full constructor. \item\end{CompactList}\item 
\hypertarget{classMixEF_51fa3e3953c0af69f4e0162829d7929d}{
\hyperlink{classMixEF_51fa3e3953c0af69f4e0162829d7929d}{MixEF} ()}
\label{classMixEF_51fa3e3953c0af69f4e0162829d7929d}

\begin{CompactList}\small\item\em Constructor of empty mixture. \item\end{CompactList}\item 
\hypertarget{classMixEF_5f4880febf28803471694d87eab81ec4}{
\hyperlink{classMixEF_5f4880febf28803471694d87eab81ec4}{MixEF} (const \hyperlink{classMixEF}{MixEF} \&M2)}
\label{classMixEF_5f4880febf28803471694d87eab81ec4}

\begin{CompactList}\small\item\em Copy constructor. \item\end{CompactList}\item 
void \hyperlink{classMixEF_73a782d2f464c830bbdbb03d34c6d63e}{init} (\hyperlink{classBMEF}{BMEF} $\ast$Com0, const mat \&Data, int c=5)
\item 
\hypertarget{classMixEF_d520fb534aa43f3084ff1568ffe7573d}{
void \hyperlink{classMixEF_d520fb534aa43f3084ff1568ffe7573d}{bayes} (const vec \&dt)}
\label{classMixEF_d520fb534aa43f3084ff1568ffe7573d}

\begin{CompactList}\small\item\em Recursive EM-like algorithm (QB-variant), see Karny et. al, 2006. \item\end{CompactList}\item 
\hypertarget{classMixEF_4e0ad97868e55facffb37932dd44353f}{
void \hyperlink{classMixEF_4e0ad97868e55facffb37932dd44353f}{bayes} (const mat \&dt)}
\label{classMixEF_4e0ad97868e55facffb37932dd44353f}

\begin{CompactList}\small\item\em EM algorithm. \item\end{CompactList}\item 
\hypertarget{classMixEF_8f4672ce35c35eec6a7f9c18ce3871a3}{
void \textbf{bayesB} (const mat \&dt, const vec \&wData)}
\label{classMixEF_8f4672ce35c35eec6a7f9c18ce3871a3}

\item 
double \hyperlink{classMixEF_424ca64f36d4e41de7a7e7ae921d35ea}{logpred} (const vec \&dt) const 
\item 
\hypertarget{classMixEF_efb3e20c2151d91c4fc080b7722a2069}{
const \hyperlink{classepdf}{epdf} \& \hyperlink{classMixEF_efb3e20c2151d91c4fc080b7722a2069}{\_\-epdf} () const }
\label{classMixEF_efb3e20c2151d91c4fc080b7722a2069}

\begin{CompactList}\small\item\em Returns a reference to the \hyperlink{classepdf}{epdf} representing posterior density on parameters. \item\end{CompactList}\item 
\hypertarget{classMixEF_324c2f0f7f9a9ee123073c15aeb8d0c1}{
const \hyperlink{classeprod}{eprod} $\ast$ \hyperlink{classMixEF_324c2f0f7f9a9ee123073c15aeb8d0c1}{\_\-e} () const }
\label{classMixEF_324c2f0f7f9a9ee123073c15aeb8d0c1}

\begin{CompactList}\small\item\em Returns a pointer to the \hyperlink{classepdf}{epdf} representing posterior density on parameters. Use with care! \item\end{CompactList}\item 
\hypertarget{classMixEF_4d5b5c25280a50df1edfa2c03540d0ac}{
\hyperlink{classemix}{emix} $\ast$ \hyperlink{classMixEF_4d5b5c25280a50df1edfa2c03540d0ac}{predictor} (const \hyperlink{classRV}{RV} \&\hyperlink{classBM_af00f0612fabe66241dd507188cdbf88}{rv}) const }
\label{classMixEF_4d5b5c25280a50df1edfa2c03540d0ac}

\begin{CompactList}\small\item\em Constructs a predictive density (marginal density on data). \item\end{CompactList}\item 
\hypertarget{classMixEF_7d4d571688a15cc5be10f6f48bfc433d}{
void \hyperlink{classMixEF_7d4d571688a15cc5be10f6f48bfc433d}{flatten} (const \hyperlink{classBMEF}{BMEF} $\ast$M2)}
\label{classMixEF_7d4d571688a15cc5be10f6f48bfc433d}

\begin{CompactList}\small\item\em Flatten the density as if it was not estimated from the data. \item\end{CompactList}\item 
\hypertarget{classMixEF_959d9b078766e251a3089b501ed78513}{
\hyperlink{classBMEF}{BMEF} $\ast$ \hyperlink{classMixEF_959d9b078766e251a3089b501ed78513}{\_\-Coms} (int i)}
\label{classMixEF_959d9b078766e251a3089b501ed78513}

\begin{CompactList}\small\item\em Access function. \item\end{CompactList}\item 
\hypertarget{classMixEF_6576024e16523da5cbaaf233512c53dc}{
void \hyperlink{classMixEF_6576024e16523da5cbaaf233512c53dc}{set\_\-method} (MixEF\_\-METHOD M)}
\label{classMixEF_6576024e16523da5cbaaf233512c53dc}

\begin{CompactList}\small\item\em Set which method is to be used. \item\end{CompactList}\item 
\hypertarget{classBMEF_30bb40eb1fd31869b2e62e79e1ecdcb4}{
virtual void \hyperlink{classBMEF_30bb40eb1fd31869b2e62e79e1ecdcb4}{set\_\-statistics} (const \hyperlink{classBMEF}{BMEF} $\ast$BM0)}
\label{classBMEF_30bb40eb1fd31869b2e62e79e1ecdcb4}

\begin{CompactList}\small\item\em get statistics from another model \item\end{CompactList}\item 
\hypertarget{classBMEF_8f4ecb6e2eaf630155a1fa98f35aa6ad}{
virtual void \hyperlink{classBMEF_8f4ecb6e2eaf630155a1fa98f35aa6ad}{bayes} (const vec \&data, const double w)}
\label{classBMEF_8f4ecb6e2eaf630155a1fa98f35aa6ad}

\begin{CompactList}\small\item\em Weighted update of sufficient statistics (Bayes rule). \item\end{CompactList}\item 
\hypertarget{classBMEF_97f5312efe4a5bedb86d2daec59d8651}{
\hyperlink{classBMEF}{BMEF} $\ast$ \hyperlink{classBMEF_97f5312efe4a5bedb86d2daec59d8651}{\_\-copy\_\-} (bool changerv=false)}
\label{classBMEF_97f5312efe4a5bedb86d2daec59d8651}

\begin{CompactList}\small\item\em Flatten the posterior as if to keep nu0 data. \item\end{CompactList}\item 
\hypertarget{classBM_0186270f75189677f390fe088a9947e9}{
virtual void \hyperlink{classBM_0186270f75189677f390fe088a9947e9}{bayesB} (const mat \&Dt)}
\label{classBM_0186270f75189677f390fe088a9947e9}

\begin{CompactList}\small\item\em Batch Bayes rule (columns of Dt are observations). \item\end{CompactList}\item 
\hypertarget{classBM_cd0660f2a1a344b56ac39802708ff165}{
vec \hyperlink{classBM_cd0660f2a1a344b56ac39802708ff165}{logpred\_\-m} (const mat \&dt) const }
\label{classBM_cd0660f2a1a344b56ac39802708ff165}

\begin{CompactList}\small\item\em Matrix version of logpred. \item\end{CompactList}\item 
\hypertarget{classBM_126bd2595c48e311fc2a7ab72876092a}{
const \hyperlink{classRV}{RV} \& \hyperlink{classBM_126bd2595c48e311fc2a7ab72876092a}{\_\-rv} () const }
\label{classBM_126bd2595c48e311fc2a7ab72876092a}

\begin{CompactList}\small\item\em access function \item\end{CompactList}\item 
\hypertarget{classBM_87f4a547d2c29180be88175e5eab9c88}{
double \hyperlink{classBM_87f4a547d2c29180be88175e5eab9c88}{\_\-ll} () const }
\label{classBM_87f4a547d2c29180be88175e5eab9c88}

\begin{CompactList}\small\item\em access function \item\end{CompactList}\item 
\hypertarget{classBM_1ffa9f23669aabecc3760c06c6987522}{
void \hyperlink{classBM_1ffa9f23669aabecc3760c06c6987522}{set\_\-evalll} (bool evl0)}
\label{classBM_1ffa9f23669aabecc3760c06c6987522}

\begin{CompactList}\small\item\em access function \item\end{CompactList}\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
\hypertarget{classMixEF_5ae381b3a7dfbe2c1e5bb579a5d9b9d1}{
void \hyperlink{classMixEF_5ae381b3a7dfbe2c1e5bb579a5d9b9d1}{build\_\-est} ()}
\label{classMixEF_5ae381b3a7dfbe2c1e5bb579a5d9b9d1}

\begin{CompactList}\small\item\em Auxiliary function for use in constructors. \item\end{CompactList}\end{CompactItemize}
\subsection*{Protected Attributes}
\begin{CompactItemize}
\item 
\hypertarget{classMixEF_e9cc9bb3e6da801455cec99a59aea149}{
int \hyperlink{classMixEF_e9cc9bb3e6da801455cec99a59aea149}{n}}
\label{classMixEF_e9cc9bb3e6da801455cec99a59aea149}

\begin{CompactList}\small\item\em Number of components. \item\end{CompactList}\item 
\hypertarget{classMixEF_4c4a140ca4e6e71b00237b7bc754302e}{
Array$<$ \hyperlink{classBMEF}{BMEF} $\ast$ $>$ \hyperlink{classMixEF_4c4a140ca4e6e71b00237b7bc754302e}{Coms}}
\label{classMixEF_4c4a140ca4e6e71b00237b7bc754302e}

\begin{CompactList}\small\item\em Models for Components of $\theta_i$. \item\end{CompactList}\item 
\hypertarget{classMixEF_d906782a0a9558f19150dc69411f717f}{
\hyperlink{classmultiBM}{multiBM} \hyperlink{classMixEF_d906782a0a9558f19150dc69411f717f}{weights}}
\label{classMixEF_d906782a0a9558f19150dc69411f717f}

\begin{CompactList}\small\item\em Statistics for weights. \item\end{CompactList}\item 
\hypertarget{classMixEF_33968f1325137cc6f4431f0cf05096dc}{
\hyperlink{classeprod}{eprod} $\ast$ \hyperlink{classMixEF_33968f1325137cc6f4431f0cf05096dc}{est}}
\label{classMixEF_33968f1325137cc6f4431f0cf05096dc}

\begin{CompactList}\small\item\em Posterior on component parameters. \item\end{CompactList}\item 
\hypertarget{classMixEF_6e630b2fd4cae8aa728ea1322708c8f0}{
MixEF\_\-METHOD \hyperlink{classMixEF_6e630b2fd4cae8aa728ea1322708c8f0}{method}}
\label{classMixEF_6e630b2fd4cae8aa728ea1322708c8f0}

\begin{CompactList}\small\item\em Flag for a method that is used in the inference. \item\end{CompactList}\item 
\hypertarget{classBMEF_538d632e59f9afa8daa1de74da12ce71}{
double \hyperlink{classBMEF_538d632e59f9afa8daa1de74da12ce71}{frg}}
\label{classBMEF_538d632e59f9afa8daa1de74da12ce71}

\begin{CompactList}\small\item\em forgetting factor \item\end{CompactList}\item 
\hypertarget{classBMEF_308cf5d4133cd471fdf1ecd5dfa09d02}{
double \hyperlink{classBMEF_308cf5d4133cd471fdf1ecd5dfa09d02}{last\_\-lognc}}
\label{classBMEF_308cf5d4133cd471fdf1ecd5dfa09d02}

\begin{CompactList}\small\item\em cached value of lognc() in the previous step (used in evaluation of {\tt ll} ) \item\end{CompactList}\item 
\hypertarget{classBM_af00f0612fabe66241dd507188cdbf88}{
\hyperlink{classRV}{RV} \hyperlink{classBM_af00f0612fabe66241dd507188cdbf88}{rv}}
\label{classBM_af00f0612fabe66241dd507188cdbf88}

\begin{CompactList}\small\item\em Random variable of the posterior. \item\end{CompactList}\item 
\hypertarget{classBM_5623fef6572a08c2b53b8c87b82dc979}{
double \hyperlink{classBM_5623fef6572a08c2b53b8c87b82dc979}{ll}}
\label{classBM_5623fef6572a08c2b53b8c87b82dc979}

\begin{CompactList}\small\item\em Logarithm of marginalized data likelihood. \item\end{CompactList}\item 
\hypertarget{classBM_bf6fb59b30141074f8ee1e2f43d03129}{
bool \hyperlink{classBM_bf6fb59b30141074f8ee1e2f43d03129}{evalll}}
\label{classBM_bf6fb59b30141074f8ee1e2f43d03129}

\begin{CompactList}\small\item\em If true, the filter will compute likelihood of the data record and store it in {\tt ll} . Set to false if you want to save computational time. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Mixture of Exponential Family Densities. 

An approximate estimation method for models with latent discrete variable, such as mixture models of the following kind: \[ f(y_t|\psi_t, \Theta) = \sum_{i=1}^{n} w_i f(y_t|\psi_t, \theta_i) \] where $\psi$ is a known function of past outputs, $w=[w_1,\ldots,w_n]$ are component weights, and component parameters $\theta_i$ are assumed to be mutually independent. $\Theta$ is an aggregation af all component parameters and weights, i.e. $\Theta = [\theta_1,\ldots,\theta_n,w]$.

The characteristic feature of this model is that if the exact values of the latent variable were known, estimation of the parameters can be handled by a single model. For example, for the case of mixture models, posterior density for each component parameters would be a BayesianModel from Exponential Family.

This class uses EM-style type algorithms for estimation of its parameters. Under this simplification, the posterior density is a product of exponential family members, hence under EM-style approximate estimation this class itself belongs to the exponential family.

TODO: Extend \hyperlink{classBM}{BM} to use rvc. 

\subsection{Member Function Documentation}
\hypertarget{classMixEF_73a782d2f464c830bbdbb03d34c6d63e}{
\index{MixEF@{MixEF}!init@{init}}
\index{init@{init}!MixEF@{MixEF}}
\subsubsection[init]{\setlength{\rightskip}{0pt plus 5cm}void MixEF::init ({\bf BMEF} $\ast$ {\em Com0}, \/  const mat \& {\em Data}, \/  int {\em c} = {\tt 5})}}
\label{classMixEF_73a782d2f464c830bbdbb03d34c6d63e}


Initializing the mixture by a random pick of centroids from data \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em Com0}]Initial component - necessary to determine its type. \item[{\em Data}]Data on which the initialization will be done \item[{\em c}]Initial number of components, default=5 \end{description}
\end{Desc}


References BMEF::\_\-copy\_\-(), build\_\-est(), Coms, est, n, multiBM::set\_\-parameters(), and weights.

Referenced by merger::merge().\hypertarget{classMixEF_424ca64f36d4e41de7a7e7ae921d35ea}{
\index{MixEF@{MixEF}!logpred@{logpred}}
\index{logpred@{logpred}!MixEF@{MixEF}}
\subsubsection[logpred]{\setlength{\rightskip}{0pt plus 5cm}double MixEF::logpred (const vec \& {\em dt}) const\hspace{0.3cm}{\tt  \mbox{[}virtual\mbox{]}}}}
\label{classMixEF_424ca64f36d4e41de7a7e7ae921d35ea}


Evaluates predictive log-likelihood of the given data record I.e. marginal likelihood of the data with the posterior integrated out. 

Reimplemented from \hyperlink{classBM_8a8ce6df431689964c41cc6c849cfd06}{BM}.

References multiBM::\_\-epdf(), Coms, epdf::mean(), and weights.

Referenced by merger::evalpdflog(), and merger::merge().

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
work/git/mixpp/bdm/estim/\hyperlink{mixef_8h}{mixef.h}\item 
work/git/mixpp/bdm/estim/mixef.cpp\end{CompactItemize}
