\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 
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_e6810daa121ccaff1ac18f26fbad4563}{
void \hyperlink{classMixEF_e6810daa121ccaff1ac18f26fbad4563}{bayesB} (const mat \&dt)}
\label{classMixEF_e6810daa121ccaff1ac18f26fbad4563}

\begin{CompactList}\small\item\em Batch Bayes rule (columns of Dt are observations). \item\end{CompactList}\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 pointer to the \hyperlink{classepdf}{epdf} representing posterior density on parameters. Use with care! \item\end{CompactList}\item 
\hypertarget{classMixEF_a93379cf31bb25961ea7f8d3f095513d}{
\hyperlink{classemix}{emix} $\ast$ \hyperlink{classMixEF_a93379cf31bb25961ea7f8d3f095513d}{predictor} (const \hyperlink{classRV}{RV} \&\hyperlink{classBM_af00f0612fabe66241dd507188cdbf88}{rv})}
\label{classMixEF_a93379cf31bb25961ea7f8d3f095513d}

\begin{CompactList}\small\item\em Constructs a predictive density (marginal density on data). \item\end{CompactList}\item 
\hypertarget{classMixEF_fdbd5f58778c1ecb68b71945cdff0483}{
void \hyperlink{classMixEF_fdbd5f58778c1ecb68b71945cdff0483}{flatten} (double sumw=1.0)}
\label{classMixEF_fdbd5f58778c1ecb68b71945cdff0483}

\begin{CompactList}\small\item\em Flatten the density as if it was not estimated from the data. \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}\item 
virtual \hyperlink{classBM}{BM} $\ast$ \hyperlink{classBM_eb58c81d6a7b75b05fc6f276eed78887}{\_\-copy\_\-} (bool changerv=false)
\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{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 BM::\_\-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(), n, and weights.

Referenced by merger::evalpdflog(), and merger::merge().\hypertarget{classBM_eb58c81d6a7b75b05fc6f276eed78887}{
\index{MixEF@{MixEF}!\_\-copy\_\-@{\_\-copy\_\-}}
\index{\_\-copy\_\-@{\_\-copy\_\-}!MixEF@{MixEF}}
\subsubsection[\_\-copy\_\-]{\setlength{\rightskip}{0pt plus 5cm}virtual {\bf BM}$\ast$ BM::\_\-copy\_\- (bool {\em changerv} = {\tt false})\hspace{0.3cm}{\tt  \mbox{[}inline, virtual, inherited\mbox{]}}}}
\label{classBM_eb58c81d6a7b75b05fc6f276eed78887}


Copy function required in vectors, Arrays of \hyperlink{classBM}{BM} etc. Have to be DELETED manually! Prototype: BM$\ast$ \hyperlink{classBM_eb58c81d6a7b75b05fc6f276eed78887}{\_\-copy\_\-()}\{\hyperlink{classBM}{BM} Tmp$\ast$=new Tmp(this$\ast$); return Tmp; \} 

Reimplemented in \hyperlink{classARX_5de61fbd4f97fa3216760b1f733f5af0}{ARX}.

Referenced by init().

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}
