root/doc/latex/classbdm_1_1MixEF.tex @ 270

Revision 270, 14.8 kB (checked in by smidl, 16 years ago)

Changes in the very root classes!
* rv and rvc are no longer compulsory,
* samplecond does not return ll
* BM has drv

Line 
1\hypertarget{classbdm_1_1MixEF}{
2\section{bdm::MixEF Class Reference}
3\label{classbdm_1_1MixEF}\index{bdm::MixEF@{bdm::MixEF}}
4}
5{\tt \#include $<$mixef.h$>$}
6
7Inheritance diagram for bdm::MixEF:\nopagebreak
8\begin{figure}[H]
9\begin{center}
10\leavevmode
11\includegraphics[width=64pt]{classbdm_1_1MixEF__inherit__graph}
12\end{center}
13\end{figure}
14
15
16\subsection{Detailed Description}
17Mixture of Exponential Family Densities.
18
19An 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]$.
20
21The 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.
22
23This 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.
24
25TODO: Extend \hyperlink{classbdm_1_1BM}{BM} to use rvc. \subsection*{Public Member Functions}
26\begin{CompactItemize}
27\item 
28\hypertarget{classbdm_1_1MixEF_4efe67d414ff34a1e7534004fd061241}{
29\hyperlink{classbdm_1_1MixEF_4efe67d414ff34a1e7534004fd061241}{MixEF} (const Array$<$ \hyperlink{classbdm_1_1BMEF}{BMEF} $\ast$ $>$ \&Coms0, const vec \&alpha0)}
30\label{classbdm_1_1MixEF_4efe67d414ff34a1e7534004fd061241}
31
32\begin{CompactList}\small\item\em Full constructor. \item\end{CompactList}\item 
33\hypertarget{classbdm_1_1MixEF_0266854387338ba757e6192d62907984}{
34\hyperlink{classbdm_1_1MixEF_0266854387338ba757e6192d62907984}{MixEF} ()}
35\label{classbdm_1_1MixEF_0266854387338ba757e6192d62907984}
36
37\begin{CompactList}\small\item\em Constructor of empty mixture. \item\end{CompactList}\item 
38\hypertarget{classbdm_1_1MixEF_9577de85c3e3481f7c0e23cf8f87c482}{
39\hyperlink{classbdm_1_1MixEF_9577de85c3e3481f7c0e23cf8f87c482}{MixEF} (const \hyperlink{classbdm_1_1MixEF}{MixEF} \&M2)}
40\label{classbdm_1_1MixEF_9577de85c3e3481f7c0e23cf8f87c482}
41
42\begin{CompactList}\small\item\em Copy constructor. \item\end{CompactList}\item 
43void \hyperlink{classbdm_1_1MixEF_0c2a50789b30769964a909d217125ed2}{init} (\hyperlink{classbdm_1_1BMEF}{BMEF} $\ast$Com0, const mat \&Data, int c=5)
44\item 
45\hypertarget{classbdm_1_1MixEF_5bd7da667da183eed1577f11dff0c1f1}{
46void \hyperlink{classbdm_1_1MixEF_5bd7da667da183eed1577f11dff0c1f1}{bayes} (const vec \&dt)}
47\label{classbdm_1_1MixEF_5bd7da667da183eed1577f11dff0c1f1}
48
49\begin{CompactList}\small\item\em Recursive EM-like algorithm (QB-variant), see Karny et. al, 2006. \item\end{CompactList}\item 
50\hypertarget{classbdm_1_1MixEF_5c41d5a4403da6e629f6bdfc70c43d20}{
51void \hyperlink{classbdm_1_1MixEF_5c41d5a4403da6e629f6bdfc70c43d20}{bayes} (const mat \&dt)}
52\label{classbdm_1_1MixEF_5c41d5a4403da6e629f6bdfc70c43d20}
53
54\begin{CompactList}\small\item\em EM algorithm. \item\end{CompactList}\item 
55\hypertarget{classbdm_1_1MixEF_5de521c395e93478df00d881ab8dac81}{
56void \textbf{bayesB} (const mat \&dt, const vec \&wData)}
57\label{classbdm_1_1MixEF_5de521c395e93478df00d881ab8dac81}
58
59\item 
60double \hyperlink{classbdm_1_1MixEF_da724da464a75e07521941e430929efa}{logpred} (const vec \&dt) const
61\item 
62\hypertarget{classbdm_1_1MixEF_33d0b3da1d10bf149d41ee74f6284a19}{
63const \hyperlink{classbdm_1_1epdf}{epdf} \& \textbf{\_\-epdf} () const }
64\label{classbdm_1_1MixEF_33d0b3da1d10bf149d41ee74f6284a19}
65
66\item 
67\hypertarget{classbdm_1_1MixEF_ea8be6f0703d87b7c4c3e77fd07e28c8}{
68const \hyperlink{classbdm_1_1eprod}{eprod} $\ast$ \textbf{\_\-e} () const }
69\label{classbdm_1_1MixEF_ea8be6f0703d87b7c4c3e77fd07e28c8}
70
71\item 
72\hypertarget{classbdm_1_1MixEF_edc50e9640f049b846084748b18469a2}{
73\hyperlink{classbdm_1_1emix}{emix} $\ast$ \hyperlink{classbdm_1_1MixEF_edc50e9640f049b846084748b18469a2}{epredictor} () const }
74\label{classbdm_1_1MixEF_edc50e9640f049b846084748b18469a2}
75
76\begin{CompactList}\small\item\em Constructs a predictive density $ f(d_{t+1} |d_{t}, \ldots d_{0}) $. \item\end{CompactList}\item 
77\hypertarget{classbdm_1_1MixEF_f0dfb4375fef4e61c4cb062e5bac7c8c}{
78void \hyperlink{classbdm_1_1MixEF_f0dfb4375fef4e61c4cb062e5bac7c8c}{flatten} (const \hyperlink{classbdm_1_1BMEF}{BMEF} $\ast$M2)}
79\label{classbdm_1_1MixEF_f0dfb4375fef4e61c4cb062e5bac7c8c}
80
81\begin{CompactList}\small\item\em Flatten the density as if it was not estimated from the data. \item\end{CompactList}\item 
82\hypertarget{classbdm_1_1MixEF_251ef6fc51757712693da5faae5317c9}{
83\hyperlink{classbdm_1_1BMEF}{BMEF} $\ast$ \hyperlink{classbdm_1_1MixEF_251ef6fc51757712693da5faae5317c9}{\_\-Coms} (int i)}
84\label{classbdm_1_1MixEF_251ef6fc51757712693da5faae5317c9}
85
86\begin{CompactList}\small\item\em Access function. \item\end{CompactList}\item 
87\hypertarget{classbdm_1_1MixEF_664529d52cc667383b39eeb440ccd577}{
88void \hyperlink{classbdm_1_1MixEF_664529d52cc667383b39eeb440ccd577}{set\_\-method} (MixEF\_\-METHOD M)}
89\label{classbdm_1_1MixEF_664529d52cc667383b39eeb440ccd577}
90
91\begin{CompactList}\small\item\em Set which method is to be used. \item\end{CompactList}\item 
92\hypertarget{classbdm_1_1BMEF_d2b528b7a41ca67163152142f5404051}{
93virtual void \hyperlink{classbdm_1_1BMEF_d2b528b7a41ca67163152142f5404051}{set\_\-statistics} (const \hyperlink{classbdm_1_1BMEF}{BMEF} $\ast$BM0)}
94\label{classbdm_1_1BMEF_d2b528b7a41ca67163152142f5404051}
95
96\begin{CompactList}\small\item\em get statistics from another model \item\end{CompactList}\item 
97\hypertarget{classbdm_1_1BMEF_bf58deb99af2a6cc674f13ff90300de6}{
98virtual void \hyperlink{classbdm_1_1BMEF_bf58deb99af2a6cc674f13ff90300de6}{bayes} (const vec \&data, const double w)}
99\label{classbdm_1_1BMEF_bf58deb99af2a6cc674f13ff90300de6}
100
101\begin{CompactList}\small\item\em Weighted update of sufficient statistics (Bayes rule). \item\end{CompactList}\item 
102\hypertarget{classbdm_1_1BMEF_5912dbcf28ae711e30b08c2fa766a3e6}{
103\hyperlink{classbdm_1_1BMEF}{BMEF} $\ast$ \hyperlink{classbdm_1_1BMEF_5912dbcf28ae711e30b08c2fa766a3e6}{\_\-copy\_\-} (bool changerv=false)}
104\label{classbdm_1_1BMEF_5912dbcf28ae711e30b08c2fa766a3e6}
105
106\begin{CompactList}\small\item\em Flatten the posterior as if to keep nu0 data. \item\end{CompactList}\end{CompactItemize}
107\begin{Indent}{\bf Constructors}\par
108\begin{CompactItemize}
109\item 
110virtual \hyperlink{classbdm_1_1BM}{BM} $\ast$ \hyperlink{classbdm_1_1BM_c0f027ff91d8459937c6f60ff8e553ff}{\_\-copy\_\-} ()
111\end{CompactItemize}
112\end{Indent}
113\begin{Indent}{\bf Mathematical operations}\par
114\begin{CompactItemize}
115\item 
116\hypertarget{classbdm_1_1BM_1dee3fddaf021e62d925289660a707dc}{
117virtual void \hyperlink{classbdm_1_1BM_1dee3fddaf021e62d925289660a707dc}{bayesB} (const mat \&Dt)}
118\label{classbdm_1_1BM_1dee3fddaf021e62d925289660a707dc}
119
120\begin{CompactList}\small\item\em Batch Bayes rule (columns of Dt are observations). \item\end{CompactList}\item 
121\hypertarget{classbdm_1_1BM_0e8ebe61fb14990abe1254bd3dda5fae}{
122vec \hyperlink{classbdm_1_1BM_0e8ebe61fb14990abe1254bd3dda5fae}{logpred\_\-m} (const mat \&dt) const }
123\label{classbdm_1_1BM_0e8ebe61fb14990abe1254bd3dda5fae}
124
125\begin{CompactList}\small\item\em Matrix version of logpred. \item\end{CompactList}\item 
126\hypertarget{classbdm_1_1BM_598b25e3f3d96a5bc00a5faeb5b3c912}{
127virtual \hyperlink{classbdm_1_1mpdf}{mpdf} $\ast$ \hyperlink{classbdm_1_1BM_598b25e3f3d96a5bc00a5faeb5b3c912}{predictor} () const }
128\label{classbdm_1_1BM_598b25e3f3d96a5bc00a5faeb5b3c912}
129
130\begin{CompactList}\small\item\em Constructs a conditional density 1-step ahead predictor. \item\end{CompactList}\end{CompactItemize}
131\end{Indent}
132\begin{Indent}{\bf Access to attributes}\par
133\begin{CompactItemize}
134\item 
135\hypertarget{classbdm_1_1BM_ff2d8755ba0b3def927d31305c03b09c}{
136const \hyperlink{classbdm_1_1RV}{RV} \& \textbf{\_\-drv} () const }
137\label{classbdm_1_1BM_ff2d8755ba0b3def927d31305c03b09c}
138
139\item 
140\hypertarget{classbdm_1_1BM_f135ae6dce7e9f30c9f88229c7930b96}{
141void \textbf{set\_\-drv} (const \hyperlink{classbdm_1_1RV}{RV} \&rv)}
142\label{classbdm_1_1BM_f135ae6dce7e9f30c9f88229c7930b96}
143
144\item 
145\hypertarget{classbdm_1_1BM_5be65d37dedfe33a3671e7065f523a70}{
146double \textbf{\_\-ll} () const }
147\label{classbdm_1_1BM_5be65d37dedfe33a3671e7065f523a70}
148
149\item 
150\hypertarget{classbdm_1_1BM_236b3abbcc93594fc97cd86d82c1a83f}{
151void \textbf{set\_\-evalll} (bool evl0)}
152\label{classbdm_1_1BM_236b3abbcc93594fc97cd86d82c1a83f}
153
154\end{CompactItemize}
155\end{Indent}
156\subsection*{Protected Member Functions}
157\begin{CompactItemize}
158\item 
159\hypertarget{classbdm_1_1MixEF_d74a8d1370c63c93ec554908ae3e6006}{
160void \hyperlink{classbdm_1_1MixEF_d74a8d1370c63c93ec554908ae3e6006}{build\_\-est} ()}
161\label{classbdm_1_1MixEF_d74a8d1370c63c93ec554908ae3e6006}
162
163\begin{CompactList}\small\item\em Auxiliary function for use in constructors. \item\end{CompactList}\end{CompactItemize}
164\subsection*{Protected Attributes}
165\begin{CompactItemize}
166\item 
167\hypertarget{classbdm_1_1MixEF_38ca1d86e977d1c38810a3c95bf074a5}{
168int \hyperlink{classbdm_1_1MixEF_38ca1d86e977d1c38810a3c95bf074a5}{n}}
169\label{classbdm_1_1MixEF_38ca1d86e977d1c38810a3c95bf074a5}
170
171\begin{CompactList}\small\item\em Number of components. \item\end{CompactList}\item 
172\hypertarget{classbdm_1_1MixEF_90c21ab5a2af56d4b49e2eaef6eccc08}{
173Array$<$ \hyperlink{classbdm_1_1BMEF}{BMEF} $\ast$ $>$ \hyperlink{classbdm_1_1MixEF_90c21ab5a2af56d4b49e2eaef6eccc08}{Coms}}
174\label{classbdm_1_1MixEF_90c21ab5a2af56d4b49e2eaef6eccc08}
175
176\begin{CompactList}\small\item\em Models for Components of $\theta_i$. \item\end{CompactList}\item 
177\hypertarget{classbdm_1_1MixEF_e39faa70cebadc3296bd249040105e86}{
178\hyperlink{classbdm_1_1multiBM}{multiBM} \hyperlink{classbdm_1_1MixEF_e39faa70cebadc3296bd249040105e86}{weights}}
179\label{classbdm_1_1MixEF_e39faa70cebadc3296bd249040105e86}
180
181\begin{CompactList}\small\item\em Statistics for weights. \item\end{CompactList}\item 
182\hypertarget{classbdm_1_1MixEF_9413fb7f1836237aac807fb9f245e4f6}{
183\hyperlink{classbdm_1_1eprod}{eprod} $\ast$ \hyperlink{classbdm_1_1MixEF_9413fb7f1836237aac807fb9f245e4f6}{est}}
184\label{classbdm_1_1MixEF_9413fb7f1836237aac807fb9f245e4f6}
185
186\begin{CompactList}\small\item\em Posterior on component parameters. \item\end{CompactList}\item 
187\hypertarget{classbdm_1_1MixEF_a2376ddadb7573532404452d0c2dd28a}{
188MixEF\_\-METHOD \hyperlink{classbdm_1_1MixEF_a2376ddadb7573532404452d0c2dd28a}{method}}
189\label{classbdm_1_1MixEF_a2376ddadb7573532404452d0c2dd28a}
190
191\begin{CompactList}\small\item\em Flag for a method that is used in the inference. \item\end{CompactList}\item 
192\hypertarget{classbdm_1_1BMEF_1331865e10fb1ccef65bb4c47fa3be64}{
193double \hyperlink{classbdm_1_1BMEF_1331865e10fb1ccef65bb4c47fa3be64}{frg}}
194\label{classbdm_1_1BMEF_1331865e10fb1ccef65bb4c47fa3be64}
195
196\begin{CompactList}\small\item\em forgetting factor \item\end{CompactList}\item 
197\hypertarget{classbdm_1_1BMEF_06e7b3ac03e10017d4288c76888e2865}{
198double \hyperlink{classbdm_1_1BMEF_06e7b3ac03e10017d4288c76888e2865}{last\_\-lognc}}
199\label{classbdm_1_1BMEF_06e7b3ac03e10017d4288c76888e2865}
200
201\begin{CompactList}\small\item\em cached value of lognc() in the previous step (used in evaluation of {\tt ll} ) \item\end{CompactList}\item 
202\hypertarget{classbdm_1_1BM_c400357e37d27a4834b2b1d9211009ed}{
203\hyperlink{classbdm_1_1RV}{RV} \hyperlink{classbdm_1_1BM_c400357e37d27a4834b2b1d9211009ed}{drv}}
204\label{classbdm_1_1BM_c400357e37d27a4834b2b1d9211009ed}
205
206\begin{CompactList}\small\item\em Random variable of the data (optional). \item\end{CompactList}\item 
207\hypertarget{classbdm_1_1BM_4064b6559d962633e4372b12f4cd204a}{
208double \hyperlink{classbdm_1_1BM_4064b6559d962633e4372b12f4cd204a}{ll}}
209\label{classbdm_1_1BM_4064b6559d962633e4372b12f4cd204a}
210
211\begin{CompactList}\small\item\em Logarithm of marginalized data likelihood. \item\end{CompactList}\item 
212\hypertarget{classbdm_1_1BM_faff0ad12556fe7dc0e2807d4fd938ee}{
213bool \hyperlink{classbdm_1_1BM_faff0ad12556fe7dc0e2807d4fd938ee}{evalll}}
214\label{classbdm_1_1BM_faff0ad12556fe7dc0e2807d4fd938ee}
215
216\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}
217
218
219\subsection{Member Function Documentation}
220\hypertarget{classbdm_1_1MixEF_0c2a50789b30769964a909d217125ed2}{
221\index{bdm::MixEF@{bdm::MixEF}!init@{init}}
222\index{init@{init}!bdm::MixEF@{bdm::MixEF}}
223\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})}}
224\label{classbdm_1_1MixEF_0c2a50789b30769964a909d217125ed2}
225
226
227Initializing the mixture by a random pick of centroids from data \begin{Desc}
228\item[Parameters:]
229\begin{description}
230\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}
231\end{Desc}
232
233
234References bdm::BMEF::\_\-copy\_\-(), build\_\-est(), Coms, est, n, bdm::multiBM::set\_\-parameters(), bdm::UniRNG, and weights.
235
236Referenced by bdm::merger::merge().\hypertarget{classbdm_1_1MixEF_da724da464a75e07521941e430929efa}{
237\index{bdm::MixEF@{bdm::MixEF}!logpred@{logpred}}
238\index{logpred@{logpred}!bdm::MixEF@{bdm::MixEF}}
239\subsubsection[logpred]{\setlength{\rightskip}{0pt plus 5cm}double bdm::MixEF::logpred (const vec \& {\em dt}) const\hspace{0.3cm}{\tt  \mbox{[}virtual\mbox{]}}}}
240\label{classbdm_1_1MixEF_da724da464a75e07521941e430929efa}
241
242
243Evaluates predictive log-likelihood of the given data record I.e. marginal likelihood of the data with the posterior integrated out.
244
245Reimplemented from \hyperlink{classbdm_1_1BM_50257e0c1e5b5c73153ea6e716ad8ae0}{bdm::BM}.
246
247References bdm::multiBM::\_\-epdf(), Coms, bdm::epdf::mean(), and weights.
248
249Referenced by bdm::merger::evallog(), and bdm::merger::merge().\hypertarget{classbdm_1_1BM_c0f027ff91d8459937c6f60ff8e553ff}{
250\index{bdm::MixEF@{bdm::MixEF}!\_\-copy\_\-@{\_\-copy\_\-}}
251\index{\_\-copy\_\-@{\_\-copy\_\-}!bdm::MixEF@{bdm::MixEF}}
252\subsubsection[\_\-copy\_\-]{\setlength{\rightskip}{0pt plus 5cm}virtual {\bf BM}$\ast$ bdm::BM::\_\-copy\_\- ()\hspace{0.3cm}{\tt  \mbox{[}inline, virtual, inherited\mbox{]}}}}
253\label{classbdm_1_1BM_c0f027ff91d8459937c6f60ff8e553ff}
254
255
256Copy function required in vectors, Arrays of \hyperlink{classbdm_1_1BM}{BM} etc. Have to be DELETED manually! Prototype:
257
258\begin{Code}\begin{verbatim} BM* _copy_(){return new BM(*this);} 
259\end{verbatim}
260\end{Code}
261
262 
263
264Reimplemented in \hyperlink{classbdm_1_1ARX_60c40b5c6abc4c7e464b4ccae64a5a61}{bdm::ARX}.
265
266The documentation for this class was generated from the following files:\begin{CompactItemize}
267\item 
268\hyperlink{mixef_8h}{mixef.h}\item 
269mixef.cpp\end{CompactItemize}
Note: See TracBrowser for help on using the browser.