\hypertarget{classbdm_1_1MixEF}{
\section{bdm::MixEF Class Reference}
\label{classbdm_1_1MixEF}\index{bdm::MixEF@{bdm::MixEF}}
}
{\tt \#include $<$mixef.h$>$}

Inheritance diagram for bdm::MixEF:\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=64pt]{classbdm_1_1MixEF__inherit__graph}
\end{center}
\end{figure}


\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{classbdm_1_1BM}{BM} to use rvc. \subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
\hypertarget{classbdm_1_1MixEF_4efe67d414ff34a1e7534004fd061241}{
\hyperlink{classbdm_1_1MixEF_4efe67d414ff34a1e7534004fd061241}{MixEF} (const Array$<$ \hyperlink{classbdm_1_1BMEF}{BMEF} $\ast$ $>$ \&Coms0, const vec \&alpha0)}
\label{classbdm_1_1MixEF_4efe67d414ff34a1e7534004fd061241}

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

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

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

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

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

\item 
double \hyperlink{classbdm_1_1MixEF_da724da464a75e07521941e430929efa}{logpred} (const vec \&dt) const 
\item 
\hypertarget{classbdm_1_1MixEF_33d0b3da1d10bf149d41ee74f6284a19}{
const \hyperlink{classbdm_1_1epdf}{epdf} \& \textbf{\_\-epdf} () const }
\label{classbdm_1_1MixEF_33d0b3da1d10bf149d41ee74f6284a19}

\item 
\hypertarget{classbdm_1_1MixEF_ea8be6f0703d87b7c4c3e77fd07e28c8}{
const \hyperlink{classbdm_1_1eprod}{eprod} $\ast$ \textbf{\_\-e} () const }
\label{classbdm_1_1MixEF_ea8be6f0703d87b7c4c3e77fd07e28c8}

\item 
\hypertarget{classbdm_1_1MixEF_edc50e9640f049b846084748b18469a2}{
\hyperlink{classbdm_1_1emix}{emix} $\ast$ \hyperlink{classbdm_1_1MixEF_edc50e9640f049b846084748b18469a2}{epredictor} () const }
\label{classbdm_1_1MixEF_edc50e9640f049b846084748b18469a2}

\begin{CompactList}\small\item\em Constructs a predictive density $ f(d_{t+1} |d_{t}, \ldots d_{0}) $. \item\end{CompactList}\item 
\hypertarget{classbdm_1_1MixEF_f0dfb4375fef4e61c4cb062e5bac7c8c}{
void \hyperlink{classbdm_1_1MixEF_f0dfb4375fef4e61c4cb062e5bac7c8c}{flatten} (const \hyperlink{classbdm_1_1BMEF}{BMEF} $\ast$M2)}
\label{classbdm_1_1MixEF_f0dfb4375fef4e61c4cb062e5bac7c8c}

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

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

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

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

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

\begin{CompactList}\small\item\em Flatten the posterior as if to keep nu0 data. \item\end{CompactList}\end{CompactItemize}
\begin{Indent}{\bf Constructors}\par
\begin{CompactItemize}
\item 
virtual \hyperlink{classbdm_1_1BM}{BM} $\ast$ \hyperlink{classbdm_1_1BM_c0f027ff91d8459937c6f60ff8e553ff}{\_\-copy\_\-} ()
\end{CompactItemize}
\end{Indent}
\begin{Indent}{\bf Mathematical operations}\par
\begin{CompactItemize}
\item 
\hypertarget{classbdm_1_1BM_1dee3fddaf021e62d925289660a707dc}{
virtual void \hyperlink{classbdm_1_1BM_1dee3fddaf021e62d925289660a707dc}{bayesB} (const mat \&Dt)}
\label{classbdm_1_1BM_1dee3fddaf021e62d925289660a707dc}

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

\begin{CompactList}\small\item\em Matrix version of logpred. \item\end{CompactList}\item 
\hypertarget{classbdm_1_1BM_598b25e3f3d96a5bc00a5faeb5b3c912}{
virtual \hyperlink{classbdm_1_1mpdf}{mpdf} $\ast$ \hyperlink{classbdm_1_1BM_598b25e3f3d96a5bc00a5faeb5b3c912}{predictor} () const }
\label{classbdm_1_1BM_598b25e3f3d96a5bc00a5faeb5b3c912}

\begin{CompactList}\small\item\em Constructs a conditional density 1-step ahead predictor. \item\end{CompactList}\end{CompactItemize}
\end{Indent}
\begin{Indent}{\bf Access to attributes}\par
\begin{CompactItemize}
\item 
\hypertarget{classbdm_1_1BM_ff2d8755ba0b3def927d31305c03b09c}{
const \hyperlink{classbdm_1_1RV}{RV} \& \textbf{\_\-drv} () const }
\label{classbdm_1_1BM_ff2d8755ba0b3def927d31305c03b09c}

\item 
\hypertarget{classbdm_1_1BM_f135ae6dce7e9f30c9f88229c7930b96}{
void \textbf{set\_\-drv} (const \hyperlink{classbdm_1_1RV}{RV} \&rv)}
\label{classbdm_1_1BM_f135ae6dce7e9f30c9f88229c7930b96}

\item 
\hypertarget{classbdm_1_1BM_5be65d37dedfe33a3671e7065f523a70}{
double \textbf{\_\-ll} () const }
\label{classbdm_1_1BM_5be65d37dedfe33a3671e7065f523a70}

\item 
\hypertarget{classbdm_1_1BM_236b3abbcc93594fc97cd86d82c1a83f}{
void \textbf{set\_\-evalll} (bool evl0)}
\label{classbdm_1_1BM_236b3abbcc93594fc97cd86d82c1a83f}

\end{CompactItemize}
\end{Indent}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
\hypertarget{classbdm_1_1MixEF_d74a8d1370c63c93ec554908ae3e6006}{
void \hyperlink{classbdm_1_1MixEF_d74a8d1370c63c93ec554908ae3e6006}{build\_\-est} ()}
\label{classbdm_1_1MixEF_d74a8d1370c63c93ec554908ae3e6006}

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

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

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

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

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

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

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

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

\begin{CompactList}\small\item\em Random variable of the data (optional). \item\end{CompactList}\item 
\hypertarget{classbdm_1_1BM_4064b6559d962633e4372b12f4cd204a}{
double \hyperlink{classbdm_1_1BM_4064b6559d962633e4372b12f4cd204a}{ll}}
\label{classbdm_1_1BM_4064b6559d962633e4372b12f4cd204a}

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

\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{Member Function Documentation}
\hypertarget{classbdm_1_1MixEF_0c2a50789b30769964a909d217125ed2}{
\index{bdm::MixEF@{bdm::MixEF}!init@{init}}
\index{init@{init}!bdm::MixEF@{bdm::MixEF}}
\subsubsection[init]{\setlength{\rightskip}{0pt plus 5cm}void bdm::MixEF::init ({\bf BMEF} $\ast$ {\em Com0}, \/  const mat \& {\em Data}, \/  int {\em c} = {\tt 5})}}
\label{classbdm_1_1MixEF_0c2a50789b30769964a909d217125ed2}


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 bdm::BMEF::\_\-copy\_\-(), build\_\-est(), Coms, est, n, bdm::multiBM::set\_\-parameters(), bdm::UniRNG, and weights.

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


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

Reimplemented from \hyperlink{classbdm_1_1BM_50257e0c1e5b5c73153ea6e716ad8ae0}{bdm::BM}.

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

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


Copy function required in vectors, Arrays of \hyperlink{classbdm_1_1BM}{BM} etc. Have to be DELETED manually! Prototype: 

\begin{Code}\begin{verbatim} BM* _copy_(){return new BM(*this);} 
\end{verbatim}
\end{Code}

 

Reimplemented in \hyperlink{classbdm_1_1ARX_60c40b5c6abc4c7e464b4ccae64a5a61}{bdm::ARX}.

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