[172] | 1 | \hypertarget{classMixEF}{ |
---|
| 2 | \section{MixEF Class Reference} |
---|
| 3 | \label{classMixEF}\index{MixEF@{MixEF}} |
---|
| 4 | } |
---|
| 5 | Mixture of Exponential Family Densities. |
---|
| 6 | |
---|
| 7 | |
---|
| 8 | {\tt \#include $<$mixef.h$>$} |
---|
| 9 | |
---|
| 10 | Inheritance diagram for MixEF:\nopagebreak |
---|
| 11 | \begin{figure}[H] |
---|
| 12 | \begin{center} |
---|
| 13 | \leavevmode |
---|
| 14 | \includegraphics[width=43pt]{classMixEF__inherit__graph} |
---|
| 15 | \end{center} |
---|
| 16 | \end{figure} |
---|
| 17 | Collaboration diagram for MixEF:\nopagebreak |
---|
| 18 | \begin{figure}[H] |
---|
| 19 | \begin{center} |
---|
| 20 | \leavevmode |
---|
| 21 | \includegraphics[height=400pt]{classMixEF__coll__graph} |
---|
| 22 | \end{center} |
---|
| 23 | \end{figure} |
---|
| 24 | \subsection*{Public Member Functions} |
---|
| 25 | \begin{CompactItemize} |
---|
| 26 | \item |
---|
[180] | 27 | \hypertarget{classMixEF_509ac467674c39af46aba42297528aad}{ |
---|
| 28 | \hyperlink{classMixEF_509ac467674c39af46aba42297528aad}{MixEF} (const Array$<$ \hyperlink{classBMEF}{BMEF} $\ast$ $>$ \&Coms0, const vec \&alpha0)} |
---|
| 29 | \label{classMixEF_509ac467674c39af46aba42297528aad} |
---|
[172] | 30 | |
---|
| 31 | \begin{CompactList}\small\item\em Full constructor. \item\end{CompactList}\item |
---|
[210] | 32 | \hypertarget{classMixEF_51fa3e3953c0af69f4e0162829d7929d}{ |
---|
| 33 | \hyperlink{classMixEF_51fa3e3953c0af69f4e0162829d7929d}{MixEF} ()} |
---|
| 34 | \label{classMixEF_51fa3e3953c0af69f4e0162829d7929d} |
---|
| 35 | |
---|
| 36 | \begin{CompactList}\small\item\em Constructor of empty mixture. \item\end{CompactList}\item |
---|
| 37 | \hypertarget{classMixEF_5f4880febf28803471694d87eab81ec4}{ |
---|
| 38 | \hyperlink{classMixEF_5f4880febf28803471694d87eab81ec4}{MixEF} (const \hyperlink{classMixEF}{MixEF} \&M2)} |
---|
| 39 | \label{classMixEF_5f4880febf28803471694d87eab81ec4} |
---|
| 40 | |
---|
| 41 | \begin{CompactList}\small\item\em Copy constructor. \item\end{CompactList}\item |
---|
[180] | 42 | void \hyperlink{classMixEF_73a782d2f464c830bbdbb03d34c6d63e}{init} (\hyperlink{classBMEF}{BMEF} $\ast$Com0, const mat \&Data, int c=5) |
---|
[172] | 43 | \item |
---|
| 44 | \hypertarget{classMixEF_d520fb534aa43f3084ff1568ffe7573d}{ |
---|
| 45 | void \hyperlink{classMixEF_d520fb534aa43f3084ff1568ffe7573d}{bayes} (const vec \&dt)} |
---|
| 46 | \label{classMixEF_d520fb534aa43f3084ff1568ffe7573d} |
---|
| 47 | |
---|
| 48 | \begin{CompactList}\small\item\em Recursive EM-like algorithm (QB-variant), see Karny et. al, 2006. \item\end{CompactList}\item |
---|
| 49 | \hypertarget{classMixEF_4e0ad97868e55facffb37932dd44353f}{ |
---|
| 50 | void \hyperlink{classMixEF_4e0ad97868e55facffb37932dd44353f}{bayes} (const mat \&dt)} |
---|
| 51 | \label{classMixEF_4e0ad97868e55facffb37932dd44353f} |
---|
| 52 | |
---|
| 53 | \begin{CompactList}\small\item\em EM algorithm. \item\end{CompactList}\item |
---|
[210] | 54 | \hypertarget{classMixEF_8f4672ce35c35eec6a7f9c18ce3871a3}{ |
---|
| 55 | void \textbf{bayesB} (const mat \&dt, const vec \&wData)} |
---|
| 56 | \label{classMixEF_8f4672ce35c35eec6a7f9c18ce3871a3} |
---|
[172] | 57 | |
---|
[210] | 58 | \item |
---|
[172] | 59 | double \hyperlink{classMixEF_424ca64f36d4e41de7a7e7ae921d35ea}{logpred} (const vec \&dt) const |
---|
| 60 | \item |
---|
| 61 | \hypertarget{classMixEF_efb3e20c2151d91c4fc080b7722a2069}{ |
---|
| 62 | const \hyperlink{classepdf}{epdf} \& \hyperlink{classMixEF_efb3e20c2151d91c4fc080b7722a2069}{\_\-epdf} () const } |
---|
| 63 | \label{classMixEF_efb3e20c2151d91c4fc080b7722a2069} |
---|
| 64 | |
---|
[210] | 65 | \begin{CompactList}\small\item\em Returns a reference to the \hyperlink{classepdf}{epdf} representing posterior density on parameters. \item\end{CompactList}\item |
---|
| 66 | \hypertarget{classMixEF_324c2f0f7f9a9ee123073c15aeb8d0c1}{ |
---|
| 67 | const \hyperlink{classeprod}{eprod} $\ast$ \hyperlink{classMixEF_324c2f0f7f9a9ee123073c15aeb8d0c1}{\_\-e} () const } |
---|
| 68 | \label{classMixEF_324c2f0f7f9a9ee123073c15aeb8d0c1} |
---|
| 69 | |
---|
[172] | 70 | \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 |
---|
[210] | 71 | \hypertarget{classMixEF_4d5b5c25280a50df1edfa2c03540d0ac}{ |
---|
| 72 | \hyperlink{classemix}{emix} $\ast$ \hyperlink{classMixEF_4d5b5c25280a50df1edfa2c03540d0ac}{predictor} (const \hyperlink{classRV}{RV} \&\hyperlink{classBM_af00f0612fabe66241dd507188cdbf88}{rv}) const } |
---|
| 73 | \label{classMixEF_4d5b5c25280a50df1edfa2c03540d0ac} |
---|
[181] | 74 | |
---|
| 75 | \begin{CompactList}\small\item\em Constructs a predictive density (marginal density on data). \item\end{CompactList}\item |
---|
[210] | 76 | \hypertarget{classMixEF_7d4d571688a15cc5be10f6f48bfc433d}{ |
---|
| 77 | void \hyperlink{classMixEF_7d4d571688a15cc5be10f6f48bfc433d}{flatten} (const \hyperlink{classBMEF}{BMEF} $\ast$M2)} |
---|
| 78 | \label{classMixEF_7d4d571688a15cc5be10f6f48bfc433d} |
---|
[181] | 79 | |
---|
| 80 | \begin{CompactList}\small\item\em Flatten the density as if it was not estimated from the data. \item\end{CompactList}\item |
---|
[210] | 81 | \hypertarget{classMixEF_959d9b078766e251a3089b501ed78513}{ |
---|
| 82 | \hyperlink{classBMEF}{BMEF} $\ast$ \hyperlink{classMixEF_959d9b078766e251a3089b501ed78513}{\_\-Coms} (int i)} |
---|
| 83 | \label{classMixEF_959d9b078766e251a3089b501ed78513} |
---|
| 84 | |
---|
| 85 | \begin{CompactList}\small\item\em Access function. \item\end{CompactList}\item |
---|
| 86 | \hypertarget{classMixEF_6576024e16523da5cbaaf233512c53dc}{ |
---|
| 87 | void \hyperlink{classMixEF_6576024e16523da5cbaaf233512c53dc}{set\_\-method} (MixEF\_\-METHOD M)} |
---|
| 88 | \label{classMixEF_6576024e16523da5cbaaf233512c53dc} |
---|
| 89 | |
---|
| 90 | \begin{CompactList}\small\item\em Set which method is to be used. \item\end{CompactList}\item |
---|
| 91 | \hypertarget{classBMEF_30bb40eb1fd31869b2e62e79e1ecdcb4}{ |
---|
| 92 | virtual void \hyperlink{classBMEF_30bb40eb1fd31869b2e62e79e1ecdcb4}{set\_\-statistics} (const \hyperlink{classBMEF}{BMEF} $\ast$BM0)} |
---|
| 93 | \label{classBMEF_30bb40eb1fd31869b2e62e79e1ecdcb4} |
---|
| 94 | |
---|
| 95 | \begin{CompactList}\small\item\em get statistics from another model \item\end{CompactList}\item |
---|
| 96 | \hypertarget{classBMEF_8f4ecb6e2eaf630155a1fa98f35aa6ad}{ |
---|
| 97 | virtual void \hyperlink{classBMEF_8f4ecb6e2eaf630155a1fa98f35aa6ad}{bayes} (const vec \&data, const double w)} |
---|
| 98 | \label{classBMEF_8f4ecb6e2eaf630155a1fa98f35aa6ad} |
---|
| 99 | |
---|
| 100 | \begin{CompactList}\small\item\em Weighted update of sufficient statistics (Bayes rule). \item\end{CompactList}\item |
---|
| 101 | \hypertarget{classBMEF_97f5312efe4a5bedb86d2daec59d8651}{ |
---|
| 102 | \hyperlink{classBMEF}{BMEF} $\ast$ \hyperlink{classBMEF_97f5312efe4a5bedb86d2daec59d8651}{\_\-copy\_\-} (bool changerv=false)} |
---|
| 103 | \label{classBMEF_97f5312efe4a5bedb86d2daec59d8651} |
---|
| 104 | |
---|
| 105 | \begin{CompactList}\small\item\em Flatten the posterior as if to keep nu0 data. \item\end{CompactList}\item |
---|
| 106 | \hypertarget{classBM_0186270f75189677f390fe088a9947e9}{ |
---|
| 107 | virtual void \hyperlink{classBM_0186270f75189677f390fe088a9947e9}{bayesB} (const mat \&Dt)} |
---|
| 108 | \label{classBM_0186270f75189677f390fe088a9947e9} |
---|
| 109 | |
---|
| 110 | \begin{CompactList}\small\item\em Batch Bayes rule (columns of Dt are observations). \item\end{CompactList}\item |
---|
[180] | 111 | \hypertarget{classBM_cd0660f2a1a344b56ac39802708ff165}{ |
---|
| 112 | vec \hyperlink{classBM_cd0660f2a1a344b56ac39802708ff165}{logpred\_\-m} (const mat \&dt) const } |
---|
| 113 | \label{classBM_cd0660f2a1a344b56ac39802708ff165} |
---|
| 114 | |
---|
| 115 | \begin{CompactList}\small\item\em Matrix version of logpred. \item\end{CompactList}\item |
---|
[172] | 116 | \hypertarget{classBM_126bd2595c48e311fc2a7ab72876092a}{ |
---|
| 117 | const \hyperlink{classRV}{RV} \& \hyperlink{classBM_126bd2595c48e311fc2a7ab72876092a}{\_\-rv} () const } |
---|
| 118 | \label{classBM_126bd2595c48e311fc2a7ab72876092a} |
---|
| 119 | |
---|
| 120 | \begin{CompactList}\small\item\em access function \item\end{CompactList}\item |
---|
| 121 | \hypertarget{classBM_87f4a547d2c29180be88175e5eab9c88}{ |
---|
| 122 | double \hyperlink{classBM_87f4a547d2c29180be88175e5eab9c88}{\_\-ll} () const } |
---|
| 123 | \label{classBM_87f4a547d2c29180be88175e5eab9c88} |
---|
| 124 | |
---|
| 125 | \begin{CompactList}\small\item\em access function \item\end{CompactList}\item |
---|
| 126 | \hypertarget{classBM_1ffa9f23669aabecc3760c06c6987522}{ |
---|
| 127 | void \hyperlink{classBM_1ffa9f23669aabecc3760c06c6987522}{set\_\-evalll} (bool evl0)} |
---|
| 128 | \label{classBM_1ffa9f23669aabecc3760c06c6987522} |
---|
| 129 | |
---|
[210] | 130 | \begin{CompactList}\small\item\em access function \item\end{CompactList}\end{CompactItemize} |
---|
[172] | 131 | \subsection*{Protected Member Functions} |
---|
| 132 | \begin{CompactItemize} |
---|
| 133 | \item |
---|
| 134 | \hypertarget{classMixEF_5ae381b3a7dfbe2c1e5bb579a5d9b9d1}{ |
---|
| 135 | void \hyperlink{classMixEF_5ae381b3a7dfbe2c1e5bb579a5d9b9d1}{build\_\-est} ()} |
---|
| 136 | \label{classMixEF_5ae381b3a7dfbe2c1e5bb579a5d9b9d1} |
---|
| 137 | |
---|
| 138 | \begin{CompactList}\small\item\em Auxiliary function for use in constructors. \item\end{CompactList}\end{CompactItemize} |
---|
| 139 | \subsection*{Protected Attributes} |
---|
| 140 | \begin{CompactItemize} |
---|
| 141 | \item |
---|
| 142 | \hypertarget{classMixEF_e9cc9bb3e6da801455cec99a59aea149}{ |
---|
| 143 | int \hyperlink{classMixEF_e9cc9bb3e6da801455cec99a59aea149}{n}} |
---|
| 144 | \label{classMixEF_e9cc9bb3e6da801455cec99a59aea149} |
---|
| 145 | |
---|
| 146 | \begin{CompactList}\small\item\em Number of components. \item\end{CompactList}\item |
---|
| 147 | \hypertarget{classMixEF_4c4a140ca4e6e71b00237b7bc754302e}{ |
---|
| 148 | Array$<$ \hyperlink{classBMEF}{BMEF} $\ast$ $>$ \hyperlink{classMixEF_4c4a140ca4e6e71b00237b7bc754302e}{Coms}} |
---|
| 149 | \label{classMixEF_4c4a140ca4e6e71b00237b7bc754302e} |
---|
| 150 | |
---|
| 151 | \begin{CompactList}\small\item\em Models for Components of $\theta_i$. \item\end{CompactList}\item |
---|
| 152 | \hypertarget{classMixEF_d906782a0a9558f19150dc69411f717f}{ |
---|
| 153 | \hyperlink{classmultiBM}{multiBM} \hyperlink{classMixEF_d906782a0a9558f19150dc69411f717f}{weights}} |
---|
| 154 | \label{classMixEF_d906782a0a9558f19150dc69411f717f} |
---|
| 155 | |
---|
| 156 | \begin{CompactList}\small\item\em Statistics for weights. \item\end{CompactList}\item |
---|
| 157 | \hypertarget{classMixEF_33968f1325137cc6f4431f0cf05096dc}{ |
---|
| 158 | \hyperlink{classeprod}{eprod} $\ast$ \hyperlink{classMixEF_33968f1325137cc6f4431f0cf05096dc}{est}} |
---|
| 159 | \label{classMixEF_33968f1325137cc6f4431f0cf05096dc} |
---|
| 160 | |
---|
| 161 | \begin{CompactList}\small\item\em Posterior on component parameters. \item\end{CompactList}\item |
---|
[210] | 162 | \hypertarget{classMixEF_6e630b2fd4cae8aa728ea1322708c8f0}{ |
---|
| 163 | MixEF\_\-METHOD \hyperlink{classMixEF_6e630b2fd4cae8aa728ea1322708c8f0}{method}} |
---|
| 164 | \label{classMixEF_6e630b2fd4cae8aa728ea1322708c8f0} |
---|
| 165 | |
---|
| 166 | \begin{CompactList}\small\item\em Flag for a method that is used in the inference. \item\end{CompactList}\item |
---|
| 167 | \hypertarget{classBMEF_538d632e59f9afa8daa1de74da12ce71}{ |
---|
| 168 | double \hyperlink{classBMEF_538d632e59f9afa8daa1de74da12ce71}{frg}} |
---|
| 169 | \label{classBMEF_538d632e59f9afa8daa1de74da12ce71} |
---|
| 170 | |
---|
| 171 | \begin{CompactList}\small\item\em forgetting factor \item\end{CompactList}\item |
---|
| 172 | \hypertarget{classBMEF_308cf5d4133cd471fdf1ecd5dfa09d02}{ |
---|
| 173 | double \hyperlink{classBMEF_308cf5d4133cd471fdf1ecd5dfa09d02}{last\_\-lognc}} |
---|
| 174 | \label{classBMEF_308cf5d4133cd471fdf1ecd5dfa09d02} |
---|
| 175 | |
---|
| 176 | \begin{CompactList}\small\item\em cached value of lognc() in the previous step (used in evaluation of {\tt ll} ) \item\end{CompactList}\item |
---|
[172] | 177 | \hypertarget{classBM_af00f0612fabe66241dd507188cdbf88}{ |
---|
| 178 | \hyperlink{classRV}{RV} \hyperlink{classBM_af00f0612fabe66241dd507188cdbf88}{rv}} |
---|
| 179 | \label{classBM_af00f0612fabe66241dd507188cdbf88} |
---|
| 180 | |
---|
| 181 | \begin{CompactList}\small\item\em Random variable of the posterior. \item\end{CompactList}\item |
---|
| 182 | \hypertarget{classBM_5623fef6572a08c2b53b8c87b82dc979}{ |
---|
| 183 | double \hyperlink{classBM_5623fef6572a08c2b53b8c87b82dc979}{ll}} |
---|
| 184 | \label{classBM_5623fef6572a08c2b53b8c87b82dc979} |
---|
| 185 | |
---|
| 186 | \begin{CompactList}\small\item\em Logarithm of marginalized data likelihood. \item\end{CompactList}\item |
---|
| 187 | \hypertarget{classBM_bf6fb59b30141074f8ee1e2f43d03129}{ |
---|
| 188 | bool \hyperlink{classBM_bf6fb59b30141074f8ee1e2f43d03129}{evalll}} |
---|
| 189 | \label{classBM_bf6fb59b30141074f8ee1e2f43d03129} |
---|
| 190 | |
---|
| 191 | \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} |
---|
| 192 | |
---|
| 193 | |
---|
| 194 | \subsection{Detailed Description} |
---|
| 195 | Mixture of Exponential Family Densities. |
---|
| 196 | |
---|
| 197 | 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]$. |
---|
| 198 | |
---|
| 199 | 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. |
---|
| 200 | |
---|
[181] | 201 | 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. |
---|
[172] | 202 | |
---|
| 203 | TODO: Extend \hyperlink{classBM}{BM} to use rvc. |
---|
| 204 | |
---|
[180] | 205 | \subsection{Member Function Documentation} |
---|
| 206 | \hypertarget{classMixEF_73a782d2f464c830bbdbb03d34c6d63e}{ |
---|
| 207 | \index{MixEF@{MixEF}!init@{init}} |
---|
| 208 | \index{init@{init}!MixEF@{MixEF}} |
---|
| 209 | \subsubsection[init]{\setlength{\rightskip}{0pt plus 5cm}void MixEF::init ({\bf BMEF} $\ast$ {\em Com0}, \/ const mat \& {\em Data}, \/ int {\em c} = {\tt 5})}} |
---|
| 210 | \label{classMixEF_73a782d2f464c830bbdbb03d34c6d63e} |
---|
[172] | 211 | |
---|
| 212 | |
---|
[180] | 213 | Initializing the mixture by a random pick of centroids from data \begin{Desc} |
---|
[172] | 214 | \item[Parameters:] |
---|
| 215 | \begin{description} |
---|
| 216 | \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} |
---|
| 217 | \end{Desc} |
---|
| 218 | |
---|
| 219 | |
---|
[210] | 220 | References BMEF::\_\-copy\_\-(), build\_\-est(), Coms, est, n, multiBM::set\_\-parameters(), and weights. |
---|
[172] | 221 | |
---|
[180] | 222 | Referenced by merger::merge().\hypertarget{classMixEF_424ca64f36d4e41de7a7e7ae921d35ea}{ |
---|
[172] | 223 | \index{MixEF@{MixEF}!logpred@{logpred}} |
---|
| 224 | \index{logpred@{logpred}!MixEF@{MixEF}} |
---|
| 225 | \subsubsection[logpred]{\setlength{\rightskip}{0pt plus 5cm}double MixEF::logpred (const vec \& {\em dt}) const\hspace{0.3cm}{\tt \mbox{[}virtual\mbox{]}}}} |
---|
| 226 | \label{classMixEF_424ca64f36d4e41de7a7e7ae921d35ea} |
---|
| 227 | |
---|
| 228 | |
---|
| 229 | Evaluates predictive log-likelihood of the given data record I.e. marginal likelihood of the data with the posterior integrated out. |
---|
| 230 | |
---|
| 231 | Reimplemented from \hyperlink{classBM_8a8ce6df431689964c41cc6c849cfd06}{BM}. |
---|
| 232 | |
---|
[210] | 233 | References multiBM::\_\-epdf(), Coms, epdf::mean(), and weights. |
---|
[180] | 234 | |
---|
[219] | 235 | Referenced by merger::evallog(), and merger::merge(). |
---|
[172] | 236 | |
---|
| 237 | The documentation for this class was generated from the following files:\begin{CompactItemize} |
---|
| 238 | \item |
---|
| 239 | work/git/mixpp/bdm/estim/\hyperlink{mixef_8h}{mixef.h}\item |
---|
| 240 | work/git/mixpp/bdm/estim/mixef.cpp\end{CompactItemize} |
---|