[261] | 1 | \hypertarget{classbdm_1_1MixEF}{ |
---|
| 2 | \section{bdm::MixEF Class Reference} |
---|
| 3 | \label{classbdm_1_1MixEF}\index{bdm::MixEF@{bdm::MixEF}} |
---|
| 4 | } |
---|
| 5 | Mixture of Exponential Family Densities. |
---|
| 6 | |
---|
| 7 | |
---|
| 8 | {\tt \#include $<$mixef.h$>$} |
---|
| 9 | |
---|
| 10 | Inheritance diagram for bdm::MixEF:\nopagebreak |
---|
| 11 | \begin{figure}[H] |
---|
| 12 | \begin{center} |
---|
| 13 | \leavevmode |
---|
| 14 | \includegraphics[width=64pt]{classbdm_1_1MixEF__inherit__graph} |
---|
| 15 | \end{center} |
---|
| 16 | \end{figure} |
---|
| 17 | Collaboration diagram for bdm::MixEF:\nopagebreak |
---|
| 18 | \begin{figure}[H] |
---|
| 19 | \begin{center} |
---|
| 20 | \leavevmode |
---|
| 21 | \includegraphics[height=400pt]{classbdm_1_1MixEF__coll__graph} |
---|
| 22 | \end{center} |
---|
| 23 | \end{figure} |
---|
| 24 | \subsection*{Public Member Functions} |
---|
| 25 | \begin{CompactItemize} |
---|
| 26 | \item |
---|
| 27 | \hypertarget{classbdm_1_1MixEF_4efe67d414ff34a1e7534004fd061241}{ |
---|
| 28 | \hyperlink{classbdm_1_1MixEF_4efe67d414ff34a1e7534004fd061241}{MixEF} (const Array$<$ \hyperlink{classbdm_1_1BMEF}{BMEF} $\ast$ $>$ \&Coms0, const vec \&alpha0)} |
---|
| 29 | \label{classbdm_1_1MixEF_4efe67d414ff34a1e7534004fd061241} |
---|
| 30 | |
---|
| 31 | \begin{CompactList}\small\item\em Full constructor. \item\end{CompactList}\item |
---|
| 32 | \hypertarget{classbdm_1_1MixEF_0266854387338ba757e6192d62907984}{ |
---|
| 33 | \hyperlink{classbdm_1_1MixEF_0266854387338ba757e6192d62907984}{MixEF} ()} |
---|
| 34 | \label{classbdm_1_1MixEF_0266854387338ba757e6192d62907984} |
---|
| 35 | |
---|
| 36 | \begin{CompactList}\small\item\em Constructor of empty mixture. \item\end{CompactList}\item |
---|
| 37 | \hypertarget{classbdm_1_1MixEF_9577de85c3e3481f7c0e23cf8f87c482}{ |
---|
| 38 | \hyperlink{classbdm_1_1MixEF_9577de85c3e3481f7c0e23cf8f87c482}{MixEF} (const \hyperlink{classbdm_1_1MixEF}{MixEF} \&M2)} |
---|
| 39 | \label{classbdm_1_1MixEF_9577de85c3e3481f7c0e23cf8f87c482} |
---|
| 40 | |
---|
| 41 | \begin{CompactList}\small\item\em Copy constructor. \item\end{CompactList}\item |
---|
| 42 | void \hyperlink{classbdm_1_1MixEF_0c2a50789b30769964a909d217125ed2}{init} (\hyperlink{classbdm_1_1BMEF}{BMEF} $\ast$Com0, const mat \&Data, int c=5) |
---|
| 43 | \item |
---|
| 44 | \hypertarget{classbdm_1_1MixEF_5bd7da667da183eed1577f11dff0c1f1}{ |
---|
| 45 | void \hyperlink{classbdm_1_1MixEF_5bd7da667da183eed1577f11dff0c1f1}{bayes} (const vec \&dt)} |
---|
| 46 | \label{classbdm_1_1MixEF_5bd7da667da183eed1577f11dff0c1f1} |
---|
| 47 | |
---|
| 48 | \begin{CompactList}\small\item\em Recursive EM-like algorithm (QB-variant), see Karny et. al, 2006. \item\end{CompactList}\item |
---|
| 49 | \hypertarget{classbdm_1_1MixEF_5c41d5a4403da6e629f6bdfc70c43d20}{ |
---|
| 50 | void \hyperlink{classbdm_1_1MixEF_5c41d5a4403da6e629f6bdfc70c43d20}{bayes} (const mat \&dt)} |
---|
| 51 | \label{classbdm_1_1MixEF_5c41d5a4403da6e629f6bdfc70c43d20} |
---|
| 52 | |
---|
| 53 | \begin{CompactList}\small\item\em EM algorithm. \item\end{CompactList}\item |
---|
| 54 | \hypertarget{classbdm_1_1MixEF_5de521c395e93478df00d881ab8dac81}{ |
---|
| 55 | void \textbf{bayesB} (const mat \&dt, const vec \&wData)} |
---|
| 56 | \label{classbdm_1_1MixEF_5de521c395e93478df00d881ab8dac81} |
---|
| 57 | |
---|
| 58 | \item |
---|
| 59 | double \hyperlink{classbdm_1_1MixEF_da724da464a75e07521941e430929efa}{logpred} (const vec \&dt) const |
---|
| 60 | \item |
---|
| 61 | \hypertarget{classbdm_1_1MixEF_33d0b3da1d10bf149d41ee74f6284a19}{ |
---|
| 62 | const \hyperlink{classbdm_1_1epdf}{epdf} \& \hyperlink{classbdm_1_1MixEF_33d0b3da1d10bf149d41ee74f6284a19}{\_\-epdf} () const } |
---|
| 63 | \label{classbdm_1_1MixEF_33d0b3da1d10bf149d41ee74f6284a19} |
---|
| 64 | |
---|
| 65 | \begin{CompactList}\small\item\em Returns a reference to the \hyperlink{classbdm_1_1epdf}{epdf} representing posterior density on parameters. \item\end{CompactList}\item |
---|
| 66 | \hypertarget{classbdm_1_1MixEF_ea8be6f0703d87b7c4c3e77fd07e28c8}{ |
---|
| 67 | const \hyperlink{classbdm_1_1eprod}{eprod} $\ast$ \hyperlink{classbdm_1_1MixEF_ea8be6f0703d87b7c4c3e77fd07e28c8}{\_\-e} () const } |
---|
| 68 | \label{classbdm_1_1MixEF_ea8be6f0703d87b7c4c3e77fd07e28c8} |
---|
| 69 | |
---|
| 70 | \begin{CompactList}\small\item\em Returns a pointer to the \hyperlink{classbdm_1_1epdf}{epdf} representing posterior density on parameters. Use with care! \item\end{CompactList}\item |
---|
| 71 | \hypertarget{classbdm_1_1MixEF_5105973c0f790f08d1dfb79c2a3f6e1c}{ |
---|
| 72 | \hyperlink{classbdm_1_1emix}{emix} $\ast$ \hyperlink{classbdm_1_1MixEF_5105973c0f790f08d1dfb79c2a3f6e1c}{predictor} (const \hyperlink{classbdm_1_1RV}{RV} \&\hyperlink{classbdm_1_1BM_18d6db4af8ee42077741d9e3618153ca}{rv}) const } |
---|
| 73 | \label{classbdm_1_1MixEF_5105973c0f790f08d1dfb79c2a3f6e1c} |
---|
| 74 | |
---|
| 75 | \begin{CompactList}\small\item\em Constructs a predictive density (marginal density on data). \item\end{CompactList}\item |
---|
| 76 | \hypertarget{classbdm_1_1MixEF_f0dfb4375fef4e61c4cb062e5bac7c8c}{ |
---|
| 77 | void \hyperlink{classbdm_1_1MixEF_f0dfb4375fef4e61c4cb062e5bac7c8c}{flatten} (const \hyperlink{classbdm_1_1BMEF}{BMEF} $\ast$M2)} |
---|
| 78 | \label{classbdm_1_1MixEF_f0dfb4375fef4e61c4cb062e5bac7c8c} |
---|
| 79 | |
---|
| 80 | \begin{CompactList}\small\item\em Flatten the density as if it was not estimated from the data. \item\end{CompactList}\item |
---|
| 81 | \hypertarget{classbdm_1_1MixEF_251ef6fc51757712693da5faae5317c9}{ |
---|
| 82 | \hyperlink{classbdm_1_1BMEF}{BMEF} $\ast$ \hyperlink{classbdm_1_1MixEF_251ef6fc51757712693da5faae5317c9}{\_\-Coms} (int i)} |
---|
| 83 | \label{classbdm_1_1MixEF_251ef6fc51757712693da5faae5317c9} |
---|
| 84 | |
---|
| 85 | \begin{CompactList}\small\item\em Access function. \item\end{CompactList}\item |
---|
| 86 | \hypertarget{classbdm_1_1MixEF_664529d52cc667383b39eeb440ccd577}{ |
---|
| 87 | void \hyperlink{classbdm_1_1MixEF_664529d52cc667383b39eeb440ccd577}{set\_\-method} (MixEF\_\-METHOD M)} |
---|
| 88 | \label{classbdm_1_1MixEF_664529d52cc667383b39eeb440ccd577} |
---|
| 89 | |
---|
| 90 | \begin{CompactList}\small\item\em Set which method is to be used. \item\end{CompactList}\item |
---|
| 91 | \hypertarget{classbdm_1_1BMEF_d2b528b7a41ca67163152142f5404051}{ |
---|
| 92 | virtual void \hyperlink{classbdm_1_1BMEF_d2b528b7a41ca67163152142f5404051}{set\_\-statistics} (const \hyperlink{classbdm_1_1BMEF}{BMEF} $\ast$BM0)} |
---|
| 93 | \label{classbdm_1_1BMEF_d2b528b7a41ca67163152142f5404051} |
---|
| 94 | |
---|
| 95 | \begin{CompactList}\small\item\em get statistics from another model \item\end{CompactList}\item |
---|
| 96 | \hypertarget{classbdm_1_1BMEF_bf58deb99af2a6cc674f13ff90300de6}{ |
---|
| 97 | virtual void \hyperlink{classbdm_1_1BMEF_bf58deb99af2a6cc674f13ff90300de6}{bayes} (const vec \&data, const double w)} |
---|
| 98 | \label{classbdm_1_1BMEF_bf58deb99af2a6cc674f13ff90300de6} |
---|
| 99 | |
---|
| 100 | \begin{CompactList}\small\item\em Weighted update of sufficient statistics (Bayes rule). \item\end{CompactList}\item |
---|
| 101 | \hypertarget{classbdm_1_1BMEF_5912dbcf28ae711e30b08c2fa766a3e6}{ |
---|
| 102 | \hyperlink{classbdm_1_1BMEF}{BMEF} $\ast$ \hyperlink{classbdm_1_1BMEF_5912dbcf28ae711e30b08c2fa766a3e6}{\_\-copy\_\-} (bool changerv=false)} |
---|
| 103 | \label{classbdm_1_1BMEF_5912dbcf28ae711e30b08c2fa766a3e6} |
---|
| 104 | |
---|
| 105 | \begin{CompactList}\small\item\em Flatten the posterior as if to keep nu0 data. \item\end{CompactList}\item |
---|
| 106 | \hypertarget{classbdm_1_1BM_1dee3fddaf021e62d925289660a707dc}{ |
---|
| 107 | virtual void \hyperlink{classbdm_1_1BM_1dee3fddaf021e62d925289660a707dc}{bayesB} (const mat \&Dt)} |
---|
| 108 | \label{classbdm_1_1BM_1dee3fddaf021e62d925289660a707dc} |
---|
| 109 | |
---|
| 110 | \begin{CompactList}\small\item\em Batch Bayes rule (columns of Dt are observations). \item\end{CompactList}\item |
---|
| 111 | \hypertarget{classbdm_1_1BM_0e8ebe61fb14990abe1254bd3dda5fae}{ |
---|
| 112 | vec \hyperlink{classbdm_1_1BM_0e8ebe61fb14990abe1254bd3dda5fae}{logpred\_\-m} (const mat \&dt) const } |
---|
| 113 | \label{classbdm_1_1BM_0e8ebe61fb14990abe1254bd3dda5fae} |
---|
| 114 | |
---|
| 115 | \begin{CompactList}\small\item\em Matrix version of logpred. \item\end{CompactList}\item |
---|
| 116 | \hypertarget{classbdm_1_1BM_40a3c891996391e3135518053a917793}{ |
---|
| 117 | const \hyperlink{classbdm_1_1RV}{RV} \& \hyperlink{classbdm_1_1BM_40a3c891996391e3135518053a917793}{\_\-rv} () const } |
---|
| 118 | \label{classbdm_1_1BM_40a3c891996391e3135518053a917793} |
---|
| 119 | |
---|
| 120 | \begin{CompactList}\small\item\em access function \item\end{CompactList}\item |
---|
| 121 | \hypertarget{classbdm_1_1BM_5be65d37dedfe33a3671e7065f523a70}{ |
---|
| 122 | double \hyperlink{classbdm_1_1BM_5be65d37dedfe33a3671e7065f523a70}{\_\-ll} () const } |
---|
| 123 | \label{classbdm_1_1BM_5be65d37dedfe33a3671e7065f523a70} |
---|
| 124 | |
---|
| 125 | \begin{CompactList}\small\item\em access function \item\end{CompactList}\item |
---|
| 126 | \hypertarget{classbdm_1_1BM_236b3abbcc93594fc97cd86d82c1a83f}{ |
---|
| 127 | void \hyperlink{classbdm_1_1BM_236b3abbcc93594fc97cd86d82c1a83f}{set\_\-evalll} (bool evl0)} |
---|
| 128 | \label{classbdm_1_1BM_236b3abbcc93594fc97cd86d82c1a83f} |
---|
| 129 | |
---|
| 130 | \begin{CompactList}\small\item\em access function \item\end{CompactList}\end{CompactItemize} |
---|
| 131 | \subsection*{Protected Member Functions} |
---|
| 132 | \begin{CompactItemize} |
---|
| 133 | \item |
---|
| 134 | \hypertarget{classbdm_1_1MixEF_d74a8d1370c63c93ec554908ae3e6006}{ |
---|
| 135 | void \hyperlink{classbdm_1_1MixEF_d74a8d1370c63c93ec554908ae3e6006}{build\_\-est} ()} |
---|
| 136 | \label{classbdm_1_1MixEF_d74a8d1370c63c93ec554908ae3e6006} |
---|
| 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{classbdm_1_1MixEF_38ca1d86e977d1c38810a3c95bf074a5}{ |
---|
| 143 | int \hyperlink{classbdm_1_1MixEF_38ca1d86e977d1c38810a3c95bf074a5}{n}} |
---|
| 144 | \label{classbdm_1_1MixEF_38ca1d86e977d1c38810a3c95bf074a5} |
---|
| 145 | |
---|
| 146 | \begin{CompactList}\small\item\em Number of components. \item\end{CompactList}\item |
---|
| 147 | \hypertarget{classbdm_1_1MixEF_90c21ab5a2af56d4b49e2eaef6eccc08}{ |
---|
| 148 | Array$<$ \hyperlink{classbdm_1_1BMEF}{BMEF} $\ast$ $>$ \hyperlink{classbdm_1_1MixEF_90c21ab5a2af56d4b49e2eaef6eccc08}{Coms}} |
---|
| 149 | \label{classbdm_1_1MixEF_90c21ab5a2af56d4b49e2eaef6eccc08} |
---|
| 150 | |
---|
| 151 | \begin{CompactList}\small\item\em Models for Components of $\theta_i$. \item\end{CompactList}\item |
---|
| 152 | \hypertarget{classbdm_1_1MixEF_e39faa70cebadc3296bd249040105e86}{ |
---|
| 153 | \hyperlink{classbdm_1_1multiBM}{multiBM} \hyperlink{classbdm_1_1MixEF_e39faa70cebadc3296bd249040105e86}{weights}} |
---|
| 154 | \label{classbdm_1_1MixEF_e39faa70cebadc3296bd249040105e86} |
---|
| 155 | |
---|
| 156 | \begin{CompactList}\small\item\em Statistics for weights. \item\end{CompactList}\item |
---|
| 157 | \hypertarget{classbdm_1_1MixEF_9413fb7f1836237aac807fb9f245e4f6}{ |
---|
| 158 | \hyperlink{classbdm_1_1eprod}{eprod} $\ast$ \hyperlink{classbdm_1_1MixEF_9413fb7f1836237aac807fb9f245e4f6}{est}} |
---|
| 159 | \label{classbdm_1_1MixEF_9413fb7f1836237aac807fb9f245e4f6} |
---|
| 160 | |
---|
| 161 | \begin{CompactList}\small\item\em Posterior on component parameters. \item\end{CompactList}\item |
---|
| 162 | \hypertarget{classbdm_1_1MixEF_a2376ddadb7573532404452d0c2dd28a}{ |
---|
| 163 | MixEF\_\-METHOD \hyperlink{classbdm_1_1MixEF_a2376ddadb7573532404452d0c2dd28a}{method}} |
---|
| 164 | \label{classbdm_1_1MixEF_a2376ddadb7573532404452d0c2dd28a} |
---|
| 165 | |
---|
| 166 | \begin{CompactList}\small\item\em Flag for a method that is used in the inference. \item\end{CompactList}\item |
---|
| 167 | \hypertarget{classbdm_1_1BMEF_1331865e10fb1ccef65bb4c47fa3be64}{ |
---|
| 168 | double \hyperlink{classbdm_1_1BMEF_1331865e10fb1ccef65bb4c47fa3be64}{frg}} |
---|
| 169 | \label{classbdm_1_1BMEF_1331865e10fb1ccef65bb4c47fa3be64} |
---|
| 170 | |
---|
| 171 | \begin{CompactList}\small\item\em forgetting factor \item\end{CompactList}\item |
---|
| 172 | \hypertarget{classbdm_1_1BMEF_06e7b3ac03e10017d4288c76888e2865}{ |
---|
| 173 | double \hyperlink{classbdm_1_1BMEF_06e7b3ac03e10017d4288c76888e2865}{last\_\-lognc}} |
---|
| 174 | \label{classbdm_1_1BMEF_06e7b3ac03e10017d4288c76888e2865} |
---|
| 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 |
---|
| 177 | \hypertarget{classbdm_1_1BM_18d6db4af8ee42077741d9e3618153ca}{ |
---|
| 178 | \hyperlink{classbdm_1_1RV}{RV} \hyperlink{classbdm_1_1BM_18d6db4af8ee42077741d9e3618153ca}{rv}} |
---|
| 179 | \label{classbdm_1_1BM_18d6db4af8ee42077741d9e3618153ca} |
---|
| 180 | |
---|
| 181 | \begin{CompactList}\small\item\em Random variable of the posterior. \item\end{CompactList}\item |
---|
| 182 | \hypertarget{classbdm_1_1BM_4064b6559d962633e4372b12f4cd204a}{ |
---|
| 183 | double \hyperlink{classbdm_1_1BM_4064b6559d962633e4372b12f4cd204a}{ll}} |
---|
| 184 | \label{classbdm_1_1BM_4064b6559d962633e4372b12f4cd204a} |
---|
| 185 | |
---|
| 186 | \begin{CompactList}\small\item\em Logarithm of marginalized data likelihood. \item\end{CompactList}\item |
---|
| 187 | \hypertarget{classbdm_1_1BM_faff0ad12556fe7dc0e2807d4fd938ee}{ |
---|
| 188 | bool \hyperlink{classbdm_1_1BM_faff0ad12556fe7dc0e2807d4fd938ee}{evalll}} |
---|
| 189 | \label{classbdm_1_1BM_faff0ad12556fe7dc0e2807d4fd938ee} |
---|
| 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 | |
---|
| 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. |
---|
| 202 | |
---|
| 203 | TODO: Extend \hyperlink{classbdm_1_1BM}{BM} to use rvc. |
---|
| 204 | |
---|
| 205 | \subsection{Member Function Documentation} |
---|
| 206 | \hypertarget{classbdm_1_1MixEF_0c2a50789b30769964a909d217125ed2}{ |
---|
| 207 | \index{bdm::MixEF@{bdm::MixEF}!init@{init}} |
---|
| 208 | \index{init@{init}!bdm::MixEF@{bdm::MixEF}} |
---|
| 209 | \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})}} |
---|
| 210 | \label{classbdm_1_1MixEF_0c2a50789b30769964a909d217125ed2} |
---|
| 211 | |
---|
| 212 | |
---|
| 213 | Initializing the mixture by a random pick of centroids from data \begin{Desc} |
---|
| 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 | |
---|
| 220 | References bdm::BMEF::\_\-copy\_\-(), build\_\-est(), Coms, est, n, bdm::multiBM::set\_\-parameters(), bdm::UniRNG, and weights. |
---|
| 221 | |
---|
| 222 | Referenced by bdm::merger::merge().\hypertarget{classbdm_1_1MixEF_da724da464a75e07521941e430929efa}{ |
---|
| 223 | \index{bdm::MixEF@{bdm::MixEF}!logpred@{logpred}} |
---|
| 224 | \index{logpred@{logpred}!bdm::MixEF@{bdm::MixEF}} |
---|
| 225 | \subsubsection[logpred]{\setlength{\rightskip}{0pt plus 5cm}double bdm::MixEF::logpred (const vec \& {\em dt}) const\hspace{0.3cm}{\tt \mbox{[}virtual\mbox{]}}}} |
---|
| 226 | \label{classbdm_1_1MixEF_da724da464a75e07521941e430929efa} |
---|
| 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{classbdm_1_1BM_50257e0c1e5b5c73153ea6e716ad8ae0}{bdm::BM}. |
---|
| 232 | |
---|
| 233 | References bdm::multiBM::\_\-epdf(), Coms, bdm::epdf::mean(), and weights. |
---|
| 234 | |
---|
| 235 | Referenced by bdm::merger::evallog(), and bdm::merger::merge(). |
---|
| 236 | |
---|
| 237 | The documentation for this class was generated from the following files:\begin{CompactItemize} |
---|
| 238 | \item |
---|
| 239 | \hyperlink{mixef_8h}{mixef.h}\item |
---|
| 240 | mixef.cpp\end{CompactItemize} |
---|