212 | | <a name="l00219"></a>00219 <span class="keywordtype">void</span> set_parameters (<span class="keywordtype">int</span> dimx0, ldmat V0, <span class="keywordtype">double</span> nu0 = -1.0) { |
213 | | <a name="l00220"></a>00220 <a class="code" href="classbdm_1_1egiw.html#a23e4d78bea7e98840f3da30e76a2b57a" title="Dimension of the output.">dimx</a> = dimx0; |
214 | | <a name="l00221"></a>00221 <a class="code" href="classbdm_1_1egiw.html#a322414c32d9a21a006a5aab0311f64fd" title="Dimension of the regressor.">nPsi</a> = V0.rows() - <a class="code" href="classbdm_1_1egiw.html#a23e4d78bea7e98840f3da30e76a2b57a" title="Dimension of the output.">dimx</a>; |
215 | | <a name="l00222"></a>00222 <a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = <a class="code" href="classbdm_1_1egiw.html#a23e4d78bea7e98840f3da30e76a2b57a" title="Dimension of the output.">dimx</a> * (<a class="code" href="classbdm_1_1egiw.html#a23e4d78bea7e98840f3da30e76a2b57a" title="Dimension of the output.">dimx</a> + <a class="code" href="classbdm_1_1egiw.html#a322414c32d9a21a006a5aab0311f64fd" title="Dimension of the regressor.">nPsi</a>); <span class="comment">// size(R) + size(Theta)</span> |
216 | | <a name="l00223"></a>00223 |
217 | | <a name="l00224"></a>00224 <a class="code" href="classbdm_1_1egiw.html#aae56852845c6af176fd9017dbebbbd52" title="Extended information matrix of sufficient statistics.">V</a> = V0; |
218 | | <a name="l00225"></a>00225 <span class="keywordflow">if</span> (nu0 < 0) { |
219 | | <a name="l00226"></a>00226 <a class="code" href="classbdm_1_1egiw.html#a447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a> = 0.1 + <a class="code" href="classbdm_1_1egiw.html#a322414c32d9a21a006a5aab0311f64fd" title="Dimension of the regressor.">nPsi</a> + 2 * <a class="code" href="classbdm_1_1egiw.html#a23e4d78bea7e98840f3da30e76a2b57a" title="Dimension of the output.">dimx</a> + 2; <span class="comment">// +2 assures finite expected value of R</span> |
220 | | <a name="l00227"></a>00227 <span class="comment">// terms before that are sufficient for finite normalization</span> |
221 | | <a name="l00228"></a>00228 } <span class="keywordflow">else</span> { |
222 | | <a name="l00229"></a>00229 <a class="code" href="classbdm_1_1egiw.html#a447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a> = nu0; |
223 | | <a name="l00230"></a>00230 } |
224 | | <a name="l00231"></a>00231 } |
225 | | <a name="l00233"></a>00233 |
226 | | <a name="l00234"></a>00234 vec <a class="code" href="classbdm_1_1egiw.html#a920f21548b7a3723923dd108fe514c61" title="Returns a sample, from density .">sample</a>() <span class="keyword">const</span>; |
227 | | <a name="l00235"></a>00235 vec <a class="code" href="classbdm_1_1egiw.html#adf70c05f918c3a6f86d60f10c1fd6ba2" title="return expected value">mean</a>() <span class="keyword">const</span>; |
228 | | <a name="l00236"></a>00236 vec <a class="code" href="classbdm_1_1egiw.html#ac1ecc406613cc2341225dc10c3d3b46a" title="return expected variance (not covariance!)">variance</a>() <span class="keyword">const</span>; |
229 | | <a name="l00237"></a>00237 |
230 | | <a name="l00239"></a>00239 vec <a class="code" href="classbdm_1_1egiw.html#a66d2ba9295c306012b309efcc9e516f0" title="LS estimate of .">est_theta</a>() <span class="keyword">const</span>; |
231 | | <a name="l00240"></a>00240 |
232 | | <a name="l00242"></a>00242 ldmat <a class="code" href="classbdm_1_1egiw.html#a88c321a2051d1afdbb31a098896a717b" title="Covariance of the LS estimate.">est_theta_cov</a>() <span class="keyword">const</span>; |
233 | | <a name="l00243"></a>00243 |
234 | | <a name="l00245"></a>00245 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egiw.html#ad2075aa2306648b3e4fe40bb86628d5c" title="expected values of the linear coefficient and the covariance matrix are written to...">mean_mat</a> (mat &M, mat&R) <span class="keyword">const</span>; |
235 | | <a name="l00247"></a>00247 <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1egiw.html#abfb8e7c619b34ad804a73bff71742b5e" title="In this instance, val= [theta, r]. For multivariate instances, it is stored columnwise...">evallog_nn</a> (<span class="keyword">const</span> vec &val) <span class="keyword">const</span>; |
236 | | <a name="l00248"></a>00248 <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1egiw.html#a41d72ba7b2abc8a9a4209ffa98ed5633" title="logarithm of the normalizing constant, ">lognc</a> () <span class="keyword">const</span>; |
237 | | <a name="l00249"></a><a class="code" href="classbdm_1_1egiw.html#a8e610e95401a11baf34f65e16ecd87be">00249</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egiw.html#a8e610e95401a11baf34f65e16ecd87be" title="Power of the density, used e.g. to flatten the density.">pow</a> (<span class="keywordtype">double</span> p) {V *= p;<a class="code" href="classbdm_1_1egiw.html#a447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a> *= p;}; |
238 | | <a name="l00250"></a>00250 |
239 | | <a name="l00253"></a>00253 |
240 | | <a name="l00254"></a>00254 <a class="code" href="classbdm_1_1ldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a>& _V() {<span class="keywordflow">return</span> V;} |
241 | | <a name="l00255"></a>00255 <span class="keyword">const</span> ldmat& _V()<span class="keyword"> const </span>{<span class="keywordflow">return</span> V;} |
242 | | <a name="l00256"></a>00256 <span class="keywordtype">double</span>& _nu() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1egiw.html#a447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a>;} |
243 | | <a name="l00257"></a>00257 <span class="keyword">const</span> <span class="keywordtype">double</span>& _nu()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1egiw.html#a447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a>;} |
244 | | <a name="l00272"></a><a class="code" href="classbdm_1_1egiw.html#a55b76ec75bd2df5ef9cab3be20a33bbb">00272</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egiw.html#a55b76ec75bd2df5ef9cab3be20a33bbb">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>) { |
245 | | <a name="l00273"></a>00273 <a class="code" href="classbdm_1_1egiw.html#a55b76ec75bd2df5ef9cab3be20a33bbb">epdf::from_setting</a>(<span class="keyword">set</span>); |
246 | | <a name="l00274"></a>00274 <span class="keywordflow">if</span> (!<a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1egiw.html#a447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a>, <span class="keyword">set</span>, <span class="stringliteral">"nu"</span>, UI::compulsory)) {<a class="code" href="classbdm_1_1egiw.html#a447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a>=-1;} |
247 | | <a name="l00275"></a>00275 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1egiw.html#a23e4d78bea7e98840f3da30e76a2b57a" title="Dimension of the output.">dimx</a>, <span class="keyword">set</span>, <span class="stringliteral">"dimx"</span>, UI::compulsory); |
248 | | <a name="l00276"></a>00276 mat V; |
249 | | <a name="l00277"></a>00277 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (V, <span class="keyword">set</span>, <span class="stringliteral">"V"</span>, UI::compulsory); |
250 | | <a name="l00278"></a>00278 set_parameters (<a class="code" href="classbdm_1_1egiw.html#a23e4d78bea7e98840f3da30e76a2b57a" title="Dimension of the output.">dimx</a>, V, <a class="code" href="classbdm_1_1egiw.html#a447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a>); |
251 | | <a name="l00279"></a>00279 } |
252 | | <a name="l00281"></a>00281 }; |
253 | | <a name="l00282"></a>00282 <a class="code" href="user__info_8h.html#a4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a> ( egiw ); |
254 | | <a name="l00283"></a>00283 SHAREDPTR ( egiw ); |
255 | | <a name="l00284"></a>00284 |
256 | | <a name="l00293"></a><a class="code" href="classbdm_1_1eDirich.html">00293</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1eDirich.html" title="Dirichlet posterior density.">eDirich</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> |
257 | | <a name="l00294"></a>00294 { |
258 | | <a name="l00295"></a>00295 <span class="keyword">protected</span>: |
259 | | <a name="l00297"></a><a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2">00297</a> vec <a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>; |
260 | | <a name="l00298"></a>00298 <span class="keyword">public</span>: |
261 | | <a name="l00301"></a>00301 |
262 | | <a name="l00302"></a>00302 <a class="code" href="classbdm_1_1eDirich.html" title="Dirichlet posterior density.">eDirich</a> () : <a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> () {}; |
263 | | <a name="l00303"></a>00303 <a class="code" href="classbdm_1_1eDirich.html" title="Dirichlet posterior density.">eDirich</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1eDirich.html" title="Dirichlet posterior density.">eDirich</a> &D0) : <a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> () {set_parameters (D0.<a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>);}; |
264 | | <a name="l00304"></a>00304 eDirich (<span class="keyword">const</span> vec &beta0) {set_parameters (beta0);}; |
265 | | <a name="l00305"></a>00305 <span class="keywordtype">void</span> set_parameters (<span class="keyword">const</span> vec &beta0) { |
266 | | <a name="l00306"></a>00306 <a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a> = beta0; |
267 | | <a name="l00307"></a>00307 <a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = <a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>.length(); |
268 | | <a name="l00308"></a>00308 } |
269 | | <a name="l00310"></a>00310 |
270 | | <a name="l00311"></a><a class="code" href="classbdm_1_1eDirich.html#a3290613d31d58daa8a45a54b003871fc">00311</a> vec <a class="code" href="classbdm_1_1eDirich.html#a3290613d31d58daa8a45a54b003871fc" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{ |
271 | | <a name="l00312"></a>00312 <a class="code" href="bdmerror_8h.html#a7c43f3a72afe68ab0c85663a1bb3521a" title="Unconditionally throw std::runtime_error.">bdm_error</a> (<span class="stringliteral">"Not implemented"</span>); |
272 | | <a name="l00313"></a>00313 <span class="keywordflow">return</span> vec(); |
273 | | <a name="l00314"></a>00314 } |
274 | | <a name="l00315"></a>00315 |
275 | | <a name="l00316"></a><a class="code" href="classbdm_1_1eDirich.html#acb343355ec791298bb5a3404cd482fb6">00316</a> vec <a class="code" href="classbdm_1_1eDirich.html#acb343355ec791298bb5a3404cd482fb6" title="return expected value">mean</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a> / sum (<a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>);}; |
276 | | <a name="l00317"></a><a class="code" href="classbdm_1_1eDirich.html#a43c547a2507e233706f92712d8c2aacc">00317</a> vec <a class="code" href="classbdm_1_1eDirich.html#a43c547a2507e233706f92712d8c2aacc" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{<span class="keywordtype">double</span> gamma = sum (<a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>); <span class="keywordflow">return</span> elem_mult (<a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>, (<a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a> + 1)) / (gamma* (gamma + 1));} |
277 | | <a name="l00319"></a><a class="code" href="classbdm_1_1eDirich.html#ae09a24938e80c3d94b0ee842d1552318">00319</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eDirich.html#ae09a24938e80c3d94b0ee842d1552318" title="In this instance, val is ...">evallog_nn</a> (<span class="keyword">const</span> vec &val)<span class="keyword"> const </span>{ |
278 | | <a name="l00320"></a>00320 <span class="keywordtype">double</span> tmp; tmp = (<a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a> - 1) * log (val); |
279 | | <a name="l00321"></a>00321 <span class="keywordflow">return</span> tmp; |
280 | | <a name="l00322"></a>00322 } |
281 | | <a name="l00323"></a>00323 |
282 | | <a name="l00324"></a><a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2">00324</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a> ()<span class="keyword"> const </span>{ |
283 | | <a name="l00325"></a>00325 <span class="keywordtype">double</span> tmp; |
284 | | <a name="l00326"></a>00326 <span class="keywordtype">double</span> gam = sum (<a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>); |
285 | | <a name="l00327"></a>00327 <span class="keywordtype">double</span> lgb = 0.0; |
286 | | <a name="l00328"></a>00328 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0;i < <a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>.length();i++) {lgb += lgamma (<a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a> (i));} |
287 | | <a name="l00329"></a>00329 tmp = lgb - lgamma (gam); |
288 | | <a name="l00330"></a>00330 <span class="keywordflow">return</span> tmp; |
289 | | <a name="l00331"></a>00331 } |
290 | | <a name="l00332"></a>00332 |
291 | | <a name="l00334"></a><a class="code" href="classbdm_1_1eDirich.html#a175e0add26d2105c28d8121eefb9e324">00334</a> vec& <a class="code" href="classbdm_1_1eDirich.html#a175e0add26d2105c28d8121eefb9e324" title="access function">_beta</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>;} |
292 | | <a name="l00336"></a>00336 }; |
293 | | <a name="l00337"></a>00337 |
294 | | <a name="l00339"></a><a class="code" href="classbdm_1_1multiBM.html">00339</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1multiBM.html" title="Estimator for Multinomial density.">multiBM</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a> |
295 | | <a name="l00340"></a>00340 { |
296 | | <a name="l00341"></a>00341 <span class="keyword">protected</span>: |
297 | | <a name="l00343"></a><a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a">00343</a> <a class="code" href="classbdm_1_1eDirich.html" title="Dirichlet posterior density.">eDirich</a> <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>; |
298 | | <a name="l00345"></a><a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25">00345</a> vec &<a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a>; |
299 | | <a name="l00346"></a>00346 <span class="keyword">public</span>: |
300 | | <a name="l00348"></a><a class="code" href="classbdm_1_1multiBM.html#ac4dd6d9522a8a605776d21bac9bd9daf">00348</a> <a class="code" href="classbdm_1_1multiBM.html#ac4dd6d9522a8a605776d21bac9bd9daf" title="Default constructor.">multiBM</a> () : <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a> (), <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a> (), <a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a> (<a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>._beta()) { |
301 | | <a name="l00349"></a>00349 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a>.length() > 0) {<a class="code" href="classbdm_1_1BMEF.html#a06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a> = <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>();} |
302 | | <a name="l00350"></a>00350 <span class="keywordflow">else</span>{<a class="code" href="classbdm_1_1BMEF.html#a06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a> = 0.0;} |
303 | | <a name="l00351"></a>00351 } |
304 | | <a name="l00353"></a><a class="code" href="classbdm_1_1multiBM.html#ac4378cf8037f6bed29c74eea63344b31">00353</a> <a class="code" href="classbdm_1_1multiBM.html#ac4378cf8037f6bed29c74eea63344b31" title="Copy constructor.">multiBM</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1multiBM.html" title="Estimator for Multinomial density.">multiBM</a> &B) : <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a> (B), <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a> (B.<a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>), <a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a> (<a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>._beta()) {} |
305 | | <a name="l00355"></a><a class="code" href="classbdm_1_1multiBM.html#adbe6b90d410dc062a233d1dc09eeba52">00355</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1multiBM.html#adbe6b90d410dc062a233d1dc09eeba52" title="Sets sufficient statistics to match that of givefrom mB0.">set_statistics</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of a system, i.e. all uncertainty is modeled by probabilities.">BM</a>* mB0) {<span class="keyword">const</span> <a class="code" href="classbdm_1_1multiBM.html" title="Estimator for Multinomial density.">multiBM</a>* mB = <span class="keyword">dynamic_cast<</span><span class="keyword">const </span><a class="code" href="classbdm_1_1multiBM.html" title="Estimator for Multinomial density.">multiBM</a>*<span class="keyword">></span> (mB0); <a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a> = mB-><a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a>;} |
306 | | <a name="l00356"></a><a class="code" href="classbdm_1_1multiBM.html#a1e4bf41b61937fd80f34049742e23f95">00356</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1multiBM.html#a1e4bf41b61937fd80f34049742e23f95" title="Incremental Bayes rule.">bayes</a> (<span class="keyword">const</span> vec &dt) { |
307 | | <a name="l00357"></a>00357 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BMEF.html#a1331865e10fb1ccef65bb4c47fa3be64" title="forgetting factor">frg</a> < 1.0) {<a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a> *= <a class="code" href="classbdm_1_1BMEF.html#a1331865e10fb1ccef65bb4c47fa3be64" title="forgetting factor">frg</a>;<a class="code" href="classbdm_1_1BMEF.html#a06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a> = <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>();} |
308 | | <a name="l00358"></a>00358 <a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a> += dt; |
309 | | <a name="l00359"></a>00359 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#afaff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>) {<a class="code" href="classbdm_1_1BM.html#a4064b6559d962633e4372b12f4cd204a" title="Logarithm of marginalized data likelihood.">ll</a> = <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>() - <a class="code" href="classbdm_1_1BMEF.html#a06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>;} |
310 | | <a name="l00360"></a>00360 } |
311 | | <a name="l00361"></a><a class="code" href="classbdm_1_1multiBM.html#ae157b607c1e3fa91d42aeea44458e2bf">00361</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1multiBM.html#ae157b607c1e3fa91d42aeea44458e2bf">logpred</a> (<span class="keyword">const</span> vec &dt)<span class="keyword"> const </span>{ |
312 | | <a name="l00362"></a>00362 <a class="code" href="classbdm_1_1eDirich.html" title="Dirichlet posterior density.">eDirich</a> pred (<a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>); |
313 | | <a name="l00363"></a>00363 vec &<a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a> = pred.<a class="code" href="classbdm_1_1eDirich.html#a175e0add26d2105c28d8121eefb9e324" title="access function">_beta</a>(); |
314 | | <a name="l00364"></a>00364 |
315 | | <a name="l00365"></a>00365 <span class="keywordtype">double</span> lll; |
316 | | <a name="l00366"></a>00366 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BMEF.html#a1331865e10fb1ccef65bb4c47fa3be64" title="forgetting factor">frg</a> < 1.0) |
317 | | <a name="l00367"></a>00367 {beta *= <a class="code" href="classbdm_1_1BMEF.html#a1331865e10fb1ccef65bb4c47fa3be64" title="forgetting factor">frg</a>;lll = pred.<a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>();} |
318 | | <a name="l00368"></a>00368 <span class="keywordflow">else</span> |
319 | | <a name="l00369"></a>00369 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#afaff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>) {lll = <a class="code" href="classbdm_1_1BMEF.html#a06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>;} |
320 | | <a name="l00370"></a>00370 <span class="keywordflow">else</span>{lll = pred.<a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>();} |
321 | | <a name="l00371"></a>00371 |
322 | | <a name="l00372"></a>00372 beta += dt; |
323 | | <a name="l00373"></a>00373 <span class="keywordflow">return</span> pred.<a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>() - lll; |
324 | | <a name="l00374"></a>00374 } |
325 | | <a name="l00375"></a>00375 <span class="keywordtype">void</span> flatten (<span class="keyword">const</span> <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a>* B) { |
326 | | <a name="l00376"></a>00376 <span class="keyword">const</span> <a class="code" href="classbdm_1_1multiBM.html" title="Estimator for Multinomial density.">multiBM</a>* E = <span class="keyword">dynamic_cast<</span><span class="keyword">const </span><a class="code" href="classbdm_1_1multiBM.html" title="Estimator for Multinomial density.">multiBM</a>*<span class="keyword">></span> (B); |
327 | | <a name="l00377"></a>00377 <span class="comment">// sum(beta) should be equal to sum(B.beta)</span> |
328 | | <a name="l00378"></a>00378 <span class="keyword">const</span> vec &Eb = E-><a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a>;<span class="comment">//const_cast<multiBM*> ( E )->_beta();</span> |
329 | | <a name="l00379"></a>00379 <a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a> *= (sum (Eb) / sum (<a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a>)); |
330 | | <a name="l00380"></a>00380 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#afaff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>) {<a class="code" href="classbdm_1_1BMEF.html#a06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a> = <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>();} |
331 | | <a name="l00381"></a>00381 } |
332 | | <a name="l00383"></a><a class="code" href="classbdm_1_1multiBM.html#a31ff93f89473f099e489b9e1dc8d9513">00383</a> <span class="keyword">const</span> <a class="code" href="classbdm_1_1eDirich.html" title="Dirichlet posterior density.">eDirich</a>& <a class="code" href="classbdm_1_1multiBM.html#a31ff93f89473f099e489b9e1dc8d9513" title="reimplemnetation of BM::posterior()">posterior</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>;}; |
333 | | <a name="l00385"></a><a class="code" href="classbdm_1_1multiBM.html#a7a480eace4446661bacca94c57499f01">00385</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1multiBM.html#a7a480eace4446661bacca94c57499f01" title="constructor function">set_parameters</a> (<span class="keyword">const</span> vec &beta0) { |
334 | | <a name="l00386"></a>00386 <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>.set_parameters (beta0); |
335 | | <a name="l00387"></a>00387 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#afaff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>) {<a class="code" href="classbdm_1_1BMEF.html#a06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a> = <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>();} |
336 | | <a name="l00388"></a>00388 } |
337 | | <a name="l00389"></a>00389 }; |
338 | | <a name="l00390"></a>00390 |
339 | | <a name="l00400"></a><a class="code" href="classbdm_1_1egamma.html">00400</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1egamma.html" title="Gamma posterior density.">egamma</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> |
340 | | <a name="l00401"></a>00401 { |
341 | | <a name="l00402"></a>00402 <span class="keyword">protected</span>: |
342 | | <a name="l00404"></a><a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa">00404</a> vec <a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>; |
343 | | <a name="l00406"></a><a class="code" href="classbdm_1_1egamma.html#a457bfb1ccb2057df85073e519a15ccc1">00406</a> vec <a class="code" href="classbdm_1_1egamma.html#a457bfb1ccb2057df85073e519a15ccc1" title="Vector .">beta</a>; |
344 | | <a name="l00407"></a>00407 <span class="keyword">public</span> : |
345 | | <a name="l00410"></a>00410 <a class="code" href="classbdm_1_1egamma.html" title="Gamma posterior density.">egamma</a> () : <a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> (), <a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a> (0), <a class="code" href="classbdm_1_1egamma.html#a457bfb1ccb2057df85073e519a15ccc1" title="Vector .">beta</a> (0) {}; |
346 | | <a name="l00411"></a>00411 <a class="code" href="classbdm_1_1egamma.html" title="Gamma posterior density.">egamma</a> (<span class="keyword">const</span> vec &a, <span class="keyword">const</span> vec &b) {set_parameters (a, b);}; |
347 | | <a name="l00412"></a>00412 <span class="keywordtype">void</span> set_parameters (<span class="keyword">const</span> vec &a, <span class="keyword">const</span> vec &b) {<a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a> = a, <a class="code" href="classbdm_1_1egamma.html#a457bfb1ccb2057df85073e519a15ccc1" title="Vector .">beta</a> = b;<a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = <a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>.length();}; |
348 | | <a name="l00414"></a>00414 |
349 | | <a name="l00415"></a>00415 vec <a class="code" href="classbdm_1_1egamma.html#a6ed82f0fd05f6002487256d8e75a0bbd" title="Returns a sample, from density .">sample</a>() <span class="keyword">const</span>; |
350 | | <a name="l00416"></a>00416 <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1egamma.html#aa8e11e5a580ff42a1b205974c60768c6" title="Evaluate normalized log-probability.">evallog</a> (<span class="keyword">const</span> vec &val) <span class="keyword">const</span>; |
351 | | <a name="l00417"></a>00417 <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1egamma.html#a9a66cbd100e8520c769ccb3c451f86f8" title="logarithm of the normalizing constant, ">lognc</a> () <span class="keyword">const</span>; |
352 | | <a name="l00419"></a><a class="code" href="classbdm_1_1egamma.html#a0865cb3d6339fdc7410806cf70a329ed">00419</a> vec& <a class="code" href="classbdm_1_1egamma.html#a0865cb3d6339fdc7410806cf70a329ed" title="Returns pointer to internal alpha. Potentially dengerous: use with care!">_alpha</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>;} |
353 | | <a name="l00421"></a><a class="code" href="classbdm_1_1egamma.html#ac42cadd9cbd344caaa69b0b433cd16ca">00421</a> vec& <a class="code" href="classbdm_1_1egamma.html#ac42cadd9cbd344caaa69b0b433cd16ca" title="Returns pointer to internal beta. Potentially dengerous: use with care!">_beta</a>() {<span class="keywordflow">return</span> beta;} |
354 | | <a name="l00422"></a><a class="code" href="classbdm_1_1egamma.html#a49d256c42cce14c6faa56ec242b57e85">00422</a> vec <a class="code" href="classbdm_1_1egamma.html#a49d256c42cce14c6faa56ec242b57e85" title="return expected value">mean</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> elem_div (<a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>, beta);} |
355 | | <a name="l00423"></a><a class="code" href="classbdm_1_1egamma.html#a36986cc01917cd0796fadc17125bdec1">00423</a> vec <a class="code" href="classbdm_1_1egamma.html#a36986cc01917cd0796fadc17125bdec1" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> elem_div (<a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>, elem_mult (beta, beta)); } |
356 | | <a name="l00424"></a>00424 |
357 | | <a name="l00435"></a><a class="code" href="classbdm_1_1egamma.html#a8a6fd1a1c0190f3e0d95a2a1f99aafc1">00435</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egamma.html#a8a6fd1a1c0190f3e0d95a2a1f99aafc1">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>) { |
358 | | <a name="l00436"></a>00436 <a class="code" href="classbdm_1_1egamma.html#a8a6fd1a1c0190f3e0d95a2a1f99aafc1">epdf::from_setting</a> (<span class="keyword">set</span>); <span class="comment">// reads rv</span> |
359 | | <a name="l00437"></a>00437 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>, <span class="keyword">set</span>, <span class="stringliteral">"alpha"</span>, UI::compulsory); |
360 | | <a name="l00438"></a>00438 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (beta, <span class="keyword">set</span>, <span class="stringliteral">"beta"</span>, UI::compulsory); |
361 | | <a name="l00439"></a>00439 <a class="code" href="classbdm_1_1egamma.html#ac3a8d8ae8ba79d0fb35036711fa7d127" title="This method TODO.">validate</a>(); |
362 | | <a name="l00440"></a>00440 } |
363 | | <a name="l00441"></a><a class="code" href="classbdm_1_1egamma.html#ac3a8d8ae8ba79d0fb35036711fa7d127">00441</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egamma.html#ac3a8d8ae8ba79d0fb35036711fa7d127" title="This method TODO.">validate</a>() { |
364 | | <a name="l00442"></a>00442 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> (<a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>.length() == beta.length(), <span class="stringliteral">"parameters do not match"</span>); |
365 | | <a name="l00443"></a>00443 <a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = <a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>.length(); |
366 | | <a name="l00444"></a>00444 } |
367 | | <a name="l00445"></a>00445 }; |
368 | | <a name="l00446"></a>00446 <a class="code" href="user__info_8h.html#a4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a> (egamma); |
369 | | <a name="l00447"></a>00447 SHAREDPTR ( egamma ); |
370 | | <a name="l00448"></a>00448 |
371 | | <a name="l00465"></a><a class="code" href="classbdm_1_1eigamma.html">00465</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1eigamma.html" title="Inverse-Gamma posterior density.">eigamma</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1egamma.html" title="Gamma posterior density.">egamma</a> |
372 | | <a name="l00466"></a>00466 { |
373 | | <a name="l00467"></a>00467 <span class="keyword">protected</span>: |
374 | | <a name="l00468"></a>00468 <span class="keyword">public</span> : |
375 | | <a name="l00473"></a>00473 |
376 | | <a name="l00474"></a><a class="code" href="classbdm_1_1eigamma.html#a3aff7bf25ddac27731c60826fcfd878f">00474</a> vec <a class="code" href="classbdm_1_1eigamma.html#a3aff7bf25ddac27731c60826fcfd878f" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> 1.0 / <a class="code" href="classbdm_1_1eigamma.html#a3aff7bf25ddac27731c60826fcfd878f" title="Returns a sample, from density .">egamma::sample</a>();}; |
377 | | <a name="l00476"></a><a class="code" href="classbdm_1_1eigamma.html#a46cecb295edbabd28120cb0f6f572bcb">00476</a> vec <a class="code" href="classbdm_1_1eigamma.html#a46cecb295edbabd28120cb0f6f572bcb" title="Returns poiter to alpha and beta. Potentially dangerous: use with care!">mean</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> elem_div (<a class="code" href="classbdm_1_1egamma.html#a457bfb1ccb2057df85073e519a15ccc1" title="Vector .">beta</a>, <a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a> - 1);} |
378 | | <a name="l00477"></a><a class="code" href="classbdm_1_1eigamma.html#ac2c696f8c668e9f65392c9449f6a5133">00477</a> vec <a class="code" href="classbdm_1_1eigamma.html#ac2c696f8c668e9f65392c9449f6a5133" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{vec mea = <a class="code" href="classbdm_1_1eigamma.html#a46cecb295edbabd28120cb0f6f572bcb" title="Returns poiter to alpha and beta. Potentially dangerous: use with care!">mean</a>(); <span class="keywordflow">return</span> elem_div (elem_mult (mea, mea), <a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a> - 2);} |
379 | | <a name="l00478"></a>00478 }; |
380 | | <a name="l00479"></a>00479 <span class="comment">/*</span> |
381 | | <a name="l00481"></a>00481 <span class="comment">class emix : public epdf {</span> |
382 | | <a name="l00482"></a>00482 <span class="comment">protected:</span> |
383 | | <a name="l00483"></a>00483 <span class="comment"> int n;</span> |
384 | | <a name="l00484"></a>00484 <span class="comment"> vec &w;</span> |
385 | | <a name="l00485"></a>00485 <span class="comment"> Array<epdf*> Coms;</span> |
386 | | <a name="l00486"></a>00486 <span class="comment">public:</span> |
387 | | <a name="l00488"></a>00488 <span class="comment"> emix ( const RV &rv, vec &w0): epdf(rv), n(w0.length()), w(w0), Coms(n) {};</span> |
388 | | <a name="l00489"></a>00489 <span class="comment"> void set_parameters( int &i, double wi, epdf* ep){w(i)=wi;Coms(i)=ep;}</span> |
389 | | <a name="l00490"></a>00490 <span class="comment"> vec mean(){vec pom; for(int i=0;i<n;i++){pom+=Coms(i)->mean()*w(i);} return pom;};</span> |
390 | | <a name="l00491"></a>00491 <span class="comment">};</span> |
391 | | <a name="l00492"></a>00492 <span class="comment">*/</span> |
392 | | <a name="l00493"></a>00493 |
393 | | <a name="l00495"></a>00495 |
394 | | <a name="l00496"></a><a class="code" href="classbdm_1_1euni.html">00496</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1euni.html" title="Uniform distributed density on a rectangular support.">euni</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> |
395 | | <a name="l00497"></a>00497 { |
396 | | <a name="l00498"></a>00498 <span class="keyword">protected</span>: |
397 | | <a name="l00500"></a><a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32">00500</a> vec <a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>; |
398 | | <a name="l00502"></a><a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1">00502</a> vec <a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>; |
399 | | <a name="l00504"></a><a class="code" href="classbdm_1_1euni.html#ad3c27e331f90c754d80228108de8ed4c">00504</a> vec <a class="code" href="classbdm_1_1euni.html#ad3c27e331f90c754d80228108de8ed4c" title="internal">distance</a>; |
400 | | <a name="l00506"></a><a class="code" href="classbdm_1_1euni.html#a31bb13e8449a8eff35246d46dae35c20">00506</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1euni.html#a31bb13e8449a8eff35246d46dae35c20" title="normalizing coefficients">nk</a>; |
401 | | <a name="l00508"></a><a class="code" href="classbdm_1_1euni.html#a3e63be48dd58659663ca60cd18700476">00508</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1euni.html#a3e63be48dd58659663ca60cd18700476" title="cache of log( nk )">lnk</a>; |
402 | | <a name="l00509"></a>00509 <span class="keyword">public</span>: |
403 | | <a name="l00512"></a>00512 <a class="code" href="classbdm_1_1euni.html" title="Uniform distributed density on a rectangular support.">euni</a> () : <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> () {} |
404 | | <a name="l00513"></a>00513 <a class="code" href="classbdm_1_1euni.html" title="Uniform distributed density on a rectangular support.">euni</a> (<span class="keyword">const</span> vec &low0, <span class="keyword">const</span> vec &high0) {set_parameters (low0, high0);} |
405 | | <a name="l00514"></a>00514 <span class="keywordtype">void</span> set_parameters (<span class="keyword">const</span> vec &low0, <span class="keyword">const</span> vec &high0) { |
406 | | <a name="l00515"></a>00515 <a class="code" href="classbdm_1_1euni.html#ad3c27e331f90c754d80228108de8ed4c" title="internal">distance</a> = high0 - low0; |
407 | | <a name="l00516"></a>00516 <a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a> = low0; |
408 | | <a name="l00517"></a>00517 <a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a> = high0; |
409 | | <a name="l00518"></a>00518 <a class="code" href="classbdm_1_1euni.html#a31bb13e8449a8eff35246d46dae35c20" title="normalizing coefficients">nk</a> = prod (1.0 / <a class="code" href="classbdm_1_1euni.html#ad3c27e331f90c754d80228108de8ed4c" title="internal">distance</a>); |
410 | | <a name="l00519"></a>00519 <a class="code" href="classbdm_1_1euni.html#a3e63be48dd58659663ca60cd18700476" title="cache of log( nk )">lnk</a> = log (<a class="code" href="classbdm_1_1euni.html#a31bb13e8449a8eff35246d46dae35c20" title="normalizing coefficients">nk</a>); |
411 | | <a name="l00520"></a>00520 <a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = <a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>.length(); |
| 212 | <a name="l00219"></a>00219 <span class="keywordtype">void</span> set_parameters (<span class="keywordtype">int</span> dimx0, ldmat V0, <span class="keywordtype">double</span> nu0 = -1.0); |
| 213 | <a name="l00221"></a>00221 |
| 214 | <a name="l00222"></a>00222 vec <a class="code" href="classbdm_1_1egiw.html#a920f21548b7a3723923dd108fe514c61" title="Returns a sample, from density .">sample</a>() <span class="keyword">const</span>; |
| 215 | <a name="l00223"></a>00223 vec <a class="code" href="classbdm_1_1egiw.html#adf70c05f918c3a6f86d60f10c1fd6ba2" title="return expected value">mean</a>() <span class="keyword">const</span>; |
| 216 | <a name="l00224"></a>00224 vec <a class="code" href="classbdm_1_1egiw.html#ac1ecc406613cc2341225dc10c3d3b46a" title="return expected variance (not covariance!)">variance</a>() <span class="keyword">const</span>; |
| 217 | <a name="l00225"></a>00225 |
| 218 | <a name="l00227"></a>00227 vec <a class="code" href="classbdm_1_1egiw.html#a66d2ba9295c306012b309efcc9e516f0" title="LS estimate of .">est_theta</a>() <span class="keyword">const</span>; |
| 219 | <a name="l00228"></a>00228 |
| 220 | <a name="l00230"></a>00230 ldmat <a class="code" href="classbdm_1_1egiw.html#a88c321a2051d1afdbb31a098896a717b" title="Covariance of the LS estimate.">est_theta_cov</a>() <span class="keyword">const</span>; |
| 221 | <a name="l00231"></a>00231 |
| 222 | <a name="l00233"></a>00233 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egiw.html#ad2075aa2306648b3e4fe40bb86628d5c" title="expected values of the linear coefficient and the covariance matrix are written to...">mean_mat</a> (mat &M, mat&R) <span class="keyword">const</span>; |
| 223 | <a name="l00235"></a>00235 <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1egiw.html#abfb8e7c619b34ad804a73bff71742b5e" title="In this instance, val= [theta, r]. For multivariate instances, it is stored columnwise...">evallog_nn</a> (<span class="keyword">const</span> vec &val) <span class="keyword">const</span>; |
| 224 | <a name="l00236"></a>00236 <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1egiw.html#a41d72ba7b2abc8a9a4209ffa98ed5633" title="logarithm of the normalizing constant, ">lognc</a> () <span class="keyword">const</span>; |
| 225 | <a name="l00237"></a><a class="code" href="classbdm_1_1egiw.html#a8e610e95401a11baf34f65e16ecd87be">00237</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egiw.html#a8e610e95401a11baf34f65e16ecd87be" title="Power of the density, used e.g. to flatten the density.">pow</a> (<span class="keywordtype">double</span> p) {<a class="code" href="classbdm_1_1egiw.html#aae56852845c6af176fd9017dbebbbd52" title="Extended information matrix of sufficient statistics.">V</a> *= p;<a class="code" href="classbdm_1_1egiw.html#a447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a> *= p;}; |
| 226 | <a name="l00238"></a>00238 |
| 227 | <a name="l00241"></a>00241 |
| 228 | <a name="l00242"></a>00242 <a class="code" href="classbdm_1_1ldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a>& _V() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1egiw.html#aae56852845c6af176fd9017dbebbbd52" title="Extended information matrix of sufficient statistics.">V</a>;} |
| 229 | <a name="l00243"></a>00243 <span class="keyword">const</span> ldmat& _V()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1egiw.html#aae56852845c6af176fd9017dbebbbd52" title="Extended information matrix of sufficient statistics.">V</a>;} |
| 230 | <a name="l00244"></a>00244 <span class="keywordtype">double</span>& _nu() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1egiw.html#a447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a>;} |
| 231 | <a name="l00245"></a>00245 <span class="keyword">const</span> <span class="keywordtype">double</span>& _nu()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1egiw.html#a447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a>;} |
| 232 | <a name="l00260"></a><a class="code" href="classbdm_1_1egiw.html#a55b76ec75bd2df5ef9cab3be20a33bbb">00260</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egiw.html#a55b76ec75bd2df5ef9cab3be20a33bbb">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>) { |
| 233 | <a name="l00261"></a>00261 <a class="code" href="classbdm_1_1egiw.html#a55b76ec75bd2df5ef9cab3be20a33bbb">epdf::from_setting</a>(<span class="keyword">set</span>); |
| 234 | <a name="l00262"></a>00262 <span class="keywordflow">if</span> (!<a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1egiw.html#a447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a>, <span class="keyword">set</span>, <span class="stringliteral">"nu"</span>, UI::compulsory)) {<a class="code" href="classbdm_1_1egiw.html#a447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a>=-1;} |
| 235 | <a name="l00263"></a>00263 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1egiw.html#a23e4d78bea7e98840f3da30e76a2b57a" title="Dimension of the output.">dimx</a>, <span class="keyword">set</span>, <span class="stringliteral">"dimx"</span>, UI::compulsory); |
| 236 | <a name="l00264"></a>00264 mat <a class="code" href="classbdm_1_1egiw.html#aae56852845c6af176fd9017dbebbbd52" title="Extended information matrix of sufficient statistics.">V</a>; |
| 237 | <a name="l00265"></a>00265 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (V, <span class="keyword">set</span>, <span class="stringliteral">"V"</span>, UI::compulsory); |
| 238 | <a name="l00266"></a>00266 set_parameters (<a class="code" href="classbdm_1_1egiw.html#a23e4d78bea7e98840f3da30e76a2b57a" title="Dimension of the output.">dimx</a>, V, <a class="code" href="classbdm_1_1egiw.html#a447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a>); |
| 239 | <a name="l00267"></a>00267 } |
| 240 | <a name="l00269"></a>00269 }; |
| 241 | <a name="l00270"></a>00270 <a class="code" href="user__info_8h.html#a4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a> ( egiw ); |
| 242 | <a name="l00271"></a>00271 SHAREDPTR ( egiw ); |
| 243 | <a name="l00272"></a>00272 |
| 244 | <a name="l00281"></a><a class="code" href="classbdm_1_1eDirich.html">00281</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1eDirich.html" title="Dirichlet posterior density.">eDirich</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> |
| 245 | <a name="l00282"></a>00282 { |
| 246 | <a name="l00283"></a>00283 <span class="keyword">protected</span>: |
| 247 | <a name="l00285"></a><a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2">00285</a> vec <a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>; |
| 248 | <a name="l00286"></a>00286 <span class="keyword">public</span>: |
| 249 | <a name="l00289"></a>00289 |
| 250 | <a name="l00290"></a>00290 <a class="code" href="classbdm_1_1eDirich.html" title="Dirichlet posterior density.">eDirich</a> () : <a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> () {}; |
| 251 | <a name="l00291"></a>00291 <a class="code" href="classbdm_1_1eDirich.html" title="Dirichlet posterior density.">eDirich</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1eDirich.html" title="Dirichlet posterior density.">eDirich</a> &D0) : <a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> () {set_parameters (D0.<a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>);}; |
| 252 | <a name="l00292"></a>00292 eDirich (<span class="keyword">const</span> vec &beta0) {set_parameters (beta0);}; |
| 253 | <a name="l00293"></a>00293 <span class="keywordtype">void</span> set_parameters (<span class="keyword">const</span> vec &beta0) { |
| 254 | <a name="l00294"></a>00294 <a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a> = beta0; |
| 255 | <a name="l00295"></a>00295 <a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = <a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>.length(); |
| 256 | <a name="l00296"></a>00296 } |
| 257 | <a name="l00298"></a>00298 |
| 258 | <a name="l00299"></a><a class="code" href="classbdm_1_1eDirich.html#a3290613d31d58daa8a45a54b003871fc">00299</a> vec <a class="code" href="classbdm_1_1eDirich.html#a3290613d31d58daa8a45a54b003871fc" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{ |
| 259 | <a name="l00300"></a>00300 <a class="code" href="bdmerror_8h.html#a7c43f3a72afe68ab0c85663a1bb3521a" title="Unconditionally throw std::runtime_error.">bdm_error</a> (<span class="stringliteral">"Not implemented"</span>); |
| 260 | <a name="l00301"></a>00301 <span class="keywordflow">return</span> vec(); |
| 261 | <a name="l00302"></a>00302 } |
| 262 | <a name="l00303"></a>00303 |
| 263 | <a name="l00304"></a><a class="code" href="classbdm_1_1eDirich.html#acb343355ec791298bb5a3404cd482fb6">00304</a> vec <a class="code" href="classbdm_1_1eDirich.html#acb343355ec791298bb5a3404cd482fb6" title="return expected value">mean</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a> / sum (<a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>);}; |
| 264 | <a name="l00305"></a><a class="code" href="classbdm_1_1eDirich.html#a43c547a2507e233706f92712d8c2aacc">00305</a> vec <a class="code" href="classbdm_1_1eDirich.html#a43c547a2507e233706f92712d8c2aacc" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{<span class="keywordtype">double</span> gamma = sum (<a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>); <span class="keywordflow">return</span> elem_mult (<a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>, (<a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a> + 1)) / (gamma* (gamma + 1));} |
| 265 | <a name="l00307"></a><a class="code" href="classbdm_1_1eDirich.html#ae09a24938e80c3d94b0ee842d1552318">00307</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eDirich.html#ae09a24938e80c3d94b0ee842d1552318" title="In this instance, val is ...">evallog_nn</a> (<span class="keyword">const</span> vec &val)<span class="keyword"> const </span>{ |
| 266 | <a name="l00308"></a>00308 <span class="keywordtype">double</span> tmp; tmp = (<a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a> - 1) * log (val); |
| 267 | <a name="l00309"></a>00309 <span class="keywordflow">return</span> tmp; |
| 268 | <a name="l00310"></a>00310 } |
| 269 | <a name="l00311"></a>00311 |
| 270 | <a name="l00312"></a><a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2">00312</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a> ()<span class="keyword"> const </span>{ |
| 271 | <a name="l00313"></a>00313 <span class="keywordtype">double</span> tmp; |
| 272 | <a name="l00314"></a>00314 <span class="keywordtype">double</span> gam = sum (<a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>); |
| 273 | <a name="l00315"></a>00315 <span class="keywordtype">double</span> lgb = 0.0; |
| 274 | <a name="l00316"></a>00316 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0;i < <a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>.length();i++) {lgb += lgamma (<a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a> (i));} |
| 275 | <a name="l00317"></a>00317 tmp = lgb - lgamma (gam); |
| 276 | <a name="l00318"></a>00318 <span class="keywordflow">return</span> tmp; |
| 277 | <a name="l00319"></a>00319 } |
| 278 | <a name="l00320"></a>00320 |
| 279 | <a name="l00322"></a><a class="code" href="classbdm_1_1eDirich.html#a175e0add26d2105c28d8121eefb9e324">00322</a> vec& <a class="code" href="classbdm_1_1eDirich.html#a175e0add26d2105c28d8121eefb9e324" title="access function">_beta</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eDirich.html#af25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>;} |
| 280 | <a name="l00324"></a>00324 }; |
| 281 | <a name="l00325"></a>00325 |
| 282 | <a name="l00327"></a><a class="code" href="classbdm_1_1multiBM.html">00327</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1multiBM.html" title="Estimator for Multinomial density.">multiBM</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a> |
| 283 | <a name="l00328"></a>00328 { |
| 284 | <a name="l00329"></a>00329 <span class="keyword">protected</span>: |
| 285 | <a name="l00331"></a><a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a">00331</a> <a class="code" href="classbdm_1_1eDirich.html" title="Dirichlet posterior density.">eDirich</a> <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>; |
| 286 | <a name="l00333"></a><a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25">00333</a> vec &<a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a>; |
| 287 | <a name="l00334"></a>00334 <span class="keyword">public</span>: |
| 288 | <a name="l00336"></a><a class="code" href="classbdm_1_1multiBM.html#ac4dd6d9522a8a605776d21bac9bd9daf">00336</a> <a class="code" href="classbdm_1_1multiBM.html#ac4dd6d9522a8a605776d21bac9bd9daf" title="Default constructor.">multiBM</a> () : <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a> (), <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a> (), <a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a> (<a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>._beta()) { |
| 289 | <a name="l00337"></a>00337 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a>.length() > 0) {<a class="code" href="classbdm_1_1BMEF.html#a06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a> = <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>();} |
| 290 | <a name="l00338"></a>00338 <span class="keywordflow">else</span>{<a class="code" href="classbdm_1_1BMEF.html#a06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a> = 0.0;} |
| 291 | <a name="l00339"></a>00339 } |
| 292 | <a name="l00341"></a><a class="code" href="classbdm_1_1multiBM.html#ac4378cf8037f6bed29c74eea63344b31">00341</a> <a class="code" href="classbdm_1_1multiBM.html#ac4378cf8037f6bed29c74eea63344b31" title="Copy constructor.">multiBM</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1multiBM.html" title="Estimator for Multinomial density.">multiBM</a> &B) : <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a> (B), <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a> (B.<a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>), <a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a> (<a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>._beta()) {} |
| 293 | <a name="l00343"></a><a class="code" href="classbdm_1_1multiBM.html#adbe6b90d410dc062a233d1dc09eeba52">00343</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1multiBM.html#adbe6b90d410dc062a233d1dc09eeba52" title="Sets sufficient statistics to match that of givefrom mB0.">set_statistics</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of a system, i.e. all uncertainty is modeled by probabilities.">BM</a>* mB0) {<span class="keyword">const</span> <a class="code" href="classbdm_1_1multiBM.html" title="Estimator for Multinomial density.">multiBM</a>* mB = <span class="keyword">dynamic_cast<</span><span class="keyword">const </span><a class="code" href="classbdm_1_1multiBM.html" title="Estimator for Multinomial density.">multiBM</a>*<span class="keyword">></span> (mB0); <a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a> = mB-><a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a>;} |
| 294 | <a name="l00344"></a><a class="code" href="classbdm_1_1multiBM.html#a1e4bf41b61937fd80f34049742e23f95">00344</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1multiBM.html#a1e4bf41b61937fd80f34049742e23f95" title="Incremental Bayes rule.">bayes</a> (<span class="keyword">const</span> vec &dt) { |
| 295 | <a name="l00345"></a>00345 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BMEF.html#a1331865e10fb1ccef65bb4c47fa3be64" title="forgetting factor">frg</a> < 1.0) {<a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a> *= <a class="code" href="classbdm_1_1BMEF.html#a1331865e10fb1ccef65bb4c47fa3be64" title="forgetting factor">frg</a>;<a class="code" href="classbdm_1_1BMEF.html#a06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a> = <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>();} |
| 296 | <a name="l00346"></a>00346 <a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a> += dt; |
| 297 | <a name="l00347"></a>00347 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#afaff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>) {<a class="code" href="classbdm_1_1BM.html#a4064b6559d962633e4372b12f4cd204a" title="Logarithm of marginalized data likelihood.">ll</a> = <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>() - <a class="code" href="classbdm_1_1BMEF.html#a06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>;} |
| 298 | <a name="l00348"></a>00348 } |
| 299 | <a name="l00349"></a><a class="code" href="classbdm_1_1multiBM.html#ae157b607c1e3fa91d42aeea44458e2bf">00349</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1multiBM.html#ae157b607c1e3fa91d42aeea44458e2bf">logpred</a> (<span class="keyword">const</span> vec &dt)<span class="keyword"> const </span>{ |
| 300 | <a name="l00350"></a>00350 <a class="code" href="classbdm_1_1eDirich.html" title="Dirichlet posterior density.">eDirich</a> pred (<a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>); |
| 301 | <a name="l00351"></a>00351 vec &<a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a> = pred.<a class="code" href="classbdm_1_1eDirich.html#a175e0add26d2105c28d8121eefb9e324" title="access function">_beta</a>(); |
| 302 | <a name="l00352"></a>00352 |
| 303 | <a name="l00353"></a>00353 <span class="keywordtype">double</span> lll; |
| 304 | <a name="l00354"></a>00354 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BMEF.html#a1331865e10fb1ccef65bb4c47fa3be64" title="forgetting factor">frg</a> < 1.0) |
| 305 | <a name="l00355"></a>00355 {beta *= <a class="code" href="classbdm_1_1BMEF.html#a1331865e10fb1ccef65bb4c47fa3be64" title="forgetting factor">frg</a>;lll = pred.<a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>();} |
| 306 | <a name="l00356"></a>00356 <span class="keywordflow">else</span> |
| 307 | <a name="l00357"></a>00357 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#afaff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>) {lll = <a class="code" href="classbdm_1_1BMEF.html#a06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>;} |
| 308 | <a name="l00358"></a>00358 <span class="keywordflow">else</span>{lll = pred.<a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>();} |
| 309 | <a name="l00359"></a>00359 |
| 310 | <a name="l00360"></a>00360 beta += dt; |
| 311 | <a name="l00361"></a>00361 <span class="keywordflow">return</span> pred.<a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>() - lll; |
| 312 | <a name="l00362"></a>00362 } |
| 313 | <a name="l00363"></a>00363 <span class="keywordtype">void</span> flatten (<span class="keyword">const</span> <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a>* B) { |
| 314 | <a name="l00364"></a>00364 <span class="keyword">const</span> <a class="code" href="classbdm_1_1multiBM.html" title="Estimator for Multinomial density.">multiBM</a>* E = <span class="keyword">dynamic_cast<</span><span class="keyword">const </span><a class="code" href="classbdm_1_1multiBM.html" title="Estimator for Multinomial density.">multiBM</a>*<span class="keyword">></span> (B); |
| 315 | <a name="l00365"></a>00365 <span class="comment">// sum(beta) should be equal to sum(B.beta)</span> |
| 316 | <a name="l00366"></a>00366 <span class="keyword">const</span> vec &Eb = E-><a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a>;<span class="comment">//const_cast<multiBM*> ( E )->_beta();</span> |
| 317 | <a name="l00367"></a>00367 <a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a> *= (sum (Eb) / sum (<a class="code" href="classbdm_1_1multiBM.html#a044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a>)); |
| 318 | <a name="l00368"></a>00368 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#afaff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>) {<a class="code" href="classbdm_1_1BMEF.html#a06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a> = <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>();} |
| 319 | <a name="l00369"></a>00369 } |
| 320 | <a name="l00371"></a><a class="code" href="classbdm_1_1multiBM.html#a31ff93f89473f099e489b9e1dc8d9513">00371</a> <span class="keyword">const</span> <a class="code" href="classbdm_1_1eDirich.html" title="Dirichlet posterior density.">eDirich</a>& <a class="code" href="classbdm_1_1multiBM.html#a31ff93f89473f099e489b9e1dc8d9513" title="reimplemnetation of BM::posterior()">posterior</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>;}; |
| 321 | <a name="l00373"></a><a class="code" href="classbdm_1_1multiBM.html#a7a480eace4446661bacca94c57499f01">00373</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1multiBM.html#a7a480eace4446661bacca94c57499f01" title="constructor function">set_parameters</a> (<span class="keyword">const</span> vec &beta0) { |
| 322 | <a name="l00374"></a>00374 <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>.set_parameters (beta0); |
| 323 | <a name="l00375"></a>00375 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#afaff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>) {<a class="code" href="classbdm_1_1BMEF.html#a06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a> = <a class="code" href="classbdm_1_1multiBM.html#a9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classbdm_1_1eDirich.html#a279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>();} |
| 324 | <a name="l00376"></a>00376 } |
| 325 | <a name="l00377"></a>00377 }; |
| 326 | <a name="l00378"></a>00378 |
| 327 | <a name="l00388"></a><a class="code" href="classbdm_1_1egamma.html">00388</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1egamma.html" title="Gamma posterior density.">egamma</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> |
| 328 | <a name="l00389"></a>00389 { |
| 329 | <a name="l00390"></a>00390 <span class="keyword">protected</span>: |
| 330 | <a name="l00392"></a><a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa">00392</a> vec <a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>; |
| 331 | <a name="l00394"></a><a class="code" href="classbdm_1_1egamma.html#a457bfb1ccb2057df85073e519a15ccc1">00394</a> vec <a class="code" href="classbdm_1_1egamma.html#a457bfb1ccb2057df85073e519a15ccc1" title="Vector .">beta</a>; |
| 332 | <a name="l00395"></a>00395 <span class="keyword">public</span> : |
| 333 | <a name="l00398"></a>00398 <a class="code" href="classbdm_1_1egamma.html" title="Gamma posterior density.">egamma</a> () : <a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> (), <a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a> (0), <a class="code" href="classbdm_1_1egamma.html#a457bfb1ccb2057df85073e519a15ccc1" title="Vector .">beta</a> (0) {}; |
| 334 | <a name="l00399"></a>00399 <a class="code" href="classbdm_1_1egamma.html" title="Gamma posterior density.">egamma</a> (<span class="keyword">const</span> vec &a, <span class="keyword">const</span> vec &b) {set_parameters (a, b);}; |
| 335 | <a name="l00400"></a>00400 <span class="keywordtype">void</span> set_parameters (<span class="keyword">const</span> vec &a, <span class="keyword">const</span> vec &b) {<a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a> = a, <a class="code" href="classbdm_1_1egamma.html#a457bfb1ccb2057df85073e519a15ccc1" title="Vector .">beta</a> = b;<a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = <a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>.length();}; |
| 336 | <a name="l00402"></a>00402 |
| 337 | <a name="l00403"></a>00403 vec <a class="code" href="classbdm_1_1egamma.html#a6ed82f0fd05f6002487256d8e75a0bbd" title="Returns a sample, from density .">sample</a>() <span class="keyword">const</span>; |
| 338 | <a name="l00404"></a>00404 <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1egamma.html#aa8e11e5a580ff42a1b205974c60768c6" title="Evaluate normalized log-probability.">evallog</a> (<span class="keyword">const</span> vec &val) <span class="keyword">const</span>; |
| 339 | <a name="l00405"></a>00405 <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1egamma.html#a9a66cbd100e8520c769ccb3c451f86f8" title="logarithm of the normalizing constant, ">lognc</a> () <span class="keyword">const</span>; |
| 340 | <a name="l00407"></a><a class="code" href="classbdm_1_1egamma.html#a0865cb3d6339fdc7410806cf70a329ed">00407</a> vec& <a class="code" href="classbdm_1_1egamma.html#a0865cb3d6339fdc7410806cf70a329ed" title="Returns pointer to internal alpha. Potentially dengerous: use with care!">_alpha</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>;} |
| 341 | <a name="l00409"></a><a class="code" href="classbdm_1_1egamma.html#ac42cadd9cbd344caaa69b0b433cd16ca">00409</a> vec& <a class="code" href="classbdm_1_1egamma.html#ac42cadd9cbd344caaa69b0b433cd16ca" title="Returns pointer to internal beta. Potentially dengerous: use with care!">_beta</a>() {<span class="keywordflow">return</span> beta;} |
| 342 | <a name="l00410"></a><a class="code" href="classbdm_1_1egamma.html#a49d256c42cce14c6faa56ec242b57e85">00410</a> vec <a class="code" href="classbdm_1_1egamma.html#a49d256c42cce14c6faa56ec242b57e85" title="return expected value">mean</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> elem_div (<a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>, beta);} |
| 343 | <a name="l00411"></a><a class="code" href="classbdm_1_1egamma.html#a36986cc01917cd0796fadc17125bdec1">00411</a> vec <a class="code" href="classbdm_1_1egamma.html#a36986cc01917cd0796fadc17125bdec1" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> elem_div (<a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>, elem_mult (beta, beta)); } |
| 344 | <a name="l00412"></a>00412 |
| 345 | <a name="l00423"></a><a class="code" href="classbdm_1_1egamma.html#a8a6fd1a1c0190f3e0d95a2a1f99aafc1">00423</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egamma.html#a8a6fd1a1c0190f3e0d95a2a1f99aafc1">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>) { |
| 346 | <a name="l00424"></a>00424 <a class="code" href="classbdm_1_1egamma.html#a8a6fd1a1c0190f3e0d95a2a1f99aafc1">epdf::from_setting</a> (<span class="keyword">set</span>); <span class="comment">// reads rv</span> |
| 347 | <a name="l00425"></a>00425 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>, <span class="keyword">set</span>, <span class="stringliteral">"alpha"</span>, UI::compulsory); |
| 348 | <a name="l00426"></a>00426 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (beta, <span class="keyword">set</span>, <span class="stringliteral">"beta"</span>, UI::compulsory); |
| 349 | <a name="l00427"></a>00427 <a class="code" href="classbdm_1_1egamma.html#ac3a8d8ae8ba79d0fb35036711fa7d127" title="This method TODO.">validate</a>(); |
| 350 | <a name="l00428"></a>00428 } |
| 351 | <a name="l00429"></a><a class="code" href="classbdm_1_1egamma.html#ac3a8d8ae8ba79d0fb35036711fa7d127">00429</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egamma.html#ac3a8d8ae8ba79d0fb35036711fa7d127" title="This method TODO.">validate</a>() { |
| 352 | <a name="l00430"></a>00430 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> (<a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>.length() == beta.length(), <span class="stringliteral">"parameters do not match"</span>); |
| 353 | <a name="l00431"></a>00431 <a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = <a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>.length(); |
| 354 | <a name="l00432"></a>00432 } |
| 355 | <a name="l00433"></a>00433 }; |
| 356 | <a name="l00434"></a>00434 <a class="code" href="user__info_8h.html#a4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a> (egamma); |
| 357 | <a name="l00435"></a>00435 SHAREDPTR ( egamma ); |
| 358 | <a name="l00436"></a>00436 |
| 359 | <a name="l00453"></a><a class="code" href="classbdm_1_1eigamma.html">00453</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1eigamma.html" title="Inverse-Gamma posterior density.">eigamma</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1egamma.html" title="Gamma posterior density.">egamma</a> |
| 360 | <a name="l00454"></a>00454 { |
| 361 | <a name="l00455"></a>00455 <span class="keyword">protected</span>: |
| 362 | <a name="l00456"></a>00456 <span class="keyword">public</span> : |
| 363 | <a name="l00461"></a>00461 |
| 364 | <a name="l00462"></a><a class="code" href="classbdm_1_1eigamma.html#a3aff7bf25ddac27731c60826fcfd878f">00462</a> vec <a class="code" href="classbdm_1_1eigamma.html#a3aff7bf25ddac27731c60826fcfd878f" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> 1.0 / <a class="code" href="classbdm_1_1eigamma.html#a3aff7bf25ddac27731c60826fcfd878f" title="Returns a sample, from density .">egamma::sample</a>();}; |
| 365 | <a name="l00464"></a><a class="code" href="classbdm_1_1eigamma.html#a46cecb295edbabd28120cb0f6f572bcb">00464</a> vec <a class="code" href="classbdm_1_1eigamma.html#a46cecb295edbabd28120cb0f6f572bcb" title="Returns poiter to alpha and beta. Potentially dangerous: use with care!">mean</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> elem_div (<a class="code" href="classbdm_1_1egamma.html#a457bfb1ccb2057df85073e519a15ccc1" title="Vector .">beta</a>, <a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a> - 1);} |
| 366 | <a name="l00465"></a><a class="code" href="classbdm_1_1eigamma.html#ac2c696f8c668e9f65392c9449f6a5133">00465</a> vec <a class="code" href="classbdm_1_1eigamma.html#ac2c696f8c668e9f65392c9449f6a5133" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{vec mea = <a class="code" href="classbdm_1_1eigamma.html#a46cecb295edbabd28120cb0f6f572bcb" title="Returns poiter to alpha and beta. Potentially dangerous: use with care!">mean</a>(); <span class="keywordflow">return</span> elem_div (elem_mult (mea, mea), <a class="code" href="classbdm_1_1egamma.html#a0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a> - 2);} |
| 367 | <a name="l00466"></a>00466 }; |
| 368 | <a name="l00467"></a>00467 <span class="comment">/*</span> |
| 369 | <a name="l00469"></a>00469 <span class="comment">class emix : public epdf {</span> |
| 370 | <a name="l00470"></a>00470 <span class="comment">protected:</span> |
| 371 | <a name="l00471"></a>00471 <span class="comment"> int n;</span> |
| 372 | <a name="l00472"></a>00472 <span class="comment"> vec &w;</span> |
| 373 | <a name="l00473"></a>00473 <span class="comment"> Array<epdf*> Coms;</span> |
| 374 | <a name="l00474"></a>00474 <span class="comment">public:</span> |
| 375 | <a name="l00476"></a>00476 <span class="comment"> emix ( const RV &rv, vec &w0): epdf(rv), n(w0.length()), w(w0), Coms(n) {};</span> |
| 376 | <a name="l00477"></a>00477 <span class="comment"> void set_parameters( int &i, double wi, epdf* ep){w(i)=wi;Coms(i)=ep;}</span> |
| 377 | <a name="l00478"></a>00478 <span class="comment"> vec mean(){vec pom; for(int i=0;i<n;i++){pom+=Coms(i)->mean()*w(i);} return pom;};</span> |
| 378 | <a name="l00479"></a>00479 <span class="comment">};</span> |
| 379 | <a name="l00480"></a>00480 <span class="comment">*/</span> |
| 380 | <a name="l00481"></a>00481 |
| 381 | <a name="l00483"></a>00483 |
| 382 | <a name="l00484"></a><a class="code" href="classbdm_1_1euni.html">00484</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1euni.html" title="Uniform distributed density on a rectangular support.">euni</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> |
| 383 | <a name="l00485"></a>00485 { |
| 384 | <a name="l00486"></a>00486 <span class="keyword">protected</span>: |
| 385 | <a name="l00488"></a><a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32">00488</a> vec <a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>; |
| 386 | <a name="l00490"></a><a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1">00490</a> vec <a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>; |
| 387 | <a name="l00492"></a><a class="code" href="classbdm_1_1euni.html#ad3c27e331f90c754d80228108de8ed4c">00492</a> vec <a class="code" href="classbdm_1_1euni.html#ad3c27e331f90c754d80228108de8ed4c" title="internal">distance</a>; |
| 388 | <a name="l00494"></a><a class="code" href="classbdm_1_1euni.html#a31bb13e8449a8eff35246d46dae35c20">00494</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1euni.html#a31bb13e8449a8eff35246d46dae35c20" title="normalizing coefficients">nk</a>; |
| 389 | <a name="l00496"></a><a class="code" href="classbdm_1_1euni.html#a3e63be48dd58659663ca60cd18700476">00496</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1euni.html#a3e63be48dd58659663ca60cd18700476" title="cache of log( nk )">lnk</a>; |
| 390 | <a name="l00497"></a>00497 <span class="keyword">public</span>: |
| 391 | <a name="l00500"></a>00500 <a class="code" href="classbdm_1_1euni.html" title="Uniform distributed density on a rectangular support.">euni</a> () : <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> () {} |
| 392 | <a name="l00501"></a>00501 <a class="code" href="classbdm_1_1euni.html" title="Uniform distributed density on a rectangular support.">euni</a> (<span class="keyword">const</span> vec &low0, <span class="keyword">const</span> vec &high0) {set_parameters (low0, high0);} |
| 393 | <a name="l00502"></a>00502 <span class="keywordtype">void</span> set_parameters (<span class="keyword">const</span> vec &low0, <span class="keyword">const</span> vec &high0) { |
| 394 | <a name="l00503"></a>00503 <a class="code" href="classbdm_1_1euni.html#ad3c27e331f90c754d80228108de8ed4c" title="internal">distance</a> = high0 - low0; |
| 395 | <a name="l00504"></a>00504 <a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a> = low0; |
| 396 | <a name="l00505"></a>00505 <a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a> = high0; |
| 397 | <a name="l00506"></a>00506 <a class="code" href="classbdm_1_1euni.html#a31bb13e8449a8eff35246d46dae35c20" title="normalizing coefficients">nk</a> = prod (1.0 / <a class="code" href="classbdm_1_1euni.html#ad3c27e331f90c754d80228108de8ed4c" title="internal">distance</a>); |
| 398 | <a name="l00507"></a>00507 <a class="code" href="classbdm_1_1euni.html#a3e63be48dd58659663ca60cd18700476" title="cache of log( nk )">lnk</a> = log (<a class="code" href="classbdm_1_1euni.html#a31bb13e8449a8eff35246d46dae35c20" title="normalizing coefficients">nk</a>); |
| 399 | <a name="l00508"></a>00508 <a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = <a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>.length(); |
| 400 | <a name="l00509"></a>00509 } |
| 401 | <a name="l00511"></a>00511 |
| 402 | <a name="l00512"></a><a class="code" href="classbdm_1_1euni.html#acaa07b8307bd793d5339d6583e0aba81">00512</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1euni.html#acaa07b8307bd793d5339d6583e0aba81" title="Compute log-probability of argument val In case the argument is out of suport return...">evallog</a> (<span class="keyword">const</span> vec &val)<span class="keyword"> const </span>{ |
| 403 | <a name="l00513"></a>00513 <span class="keywordflow">if</span> (any (val < <a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>) && any (val > <a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>)) {<span class="keywordflow">return</span> inf;} |
| 404 | <a name="l00514"></a>00514 <span class="keywordflow">else</span> <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1euni.html#a3e63be48dd58659663ca60cd18700476" title="cache of log( nk )">lnk</a>; |
| 405 | <a name="l00515"></a>00515 } |
| 406 | <a name="l00516"></a><a class="code" href="classbdm_1_1euni.html#afc5df80359ead2918384b2004ce67194">00516</a> vec <a class="code" href="classbdm_1_1euni.html#afc5df80359ead2918384b2004ce67194" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{ |
| 407 | <a name="l00517"></a>00517 vec smp (<a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>); |
| 408 | <a name="l00518"></a>00518 <span class="preprocessor">#pragma omp critical</span> |
| 409 | <a name="l00519"></a>00519 <span class="preprocessor"></span> UniRNG.sample_vector (<a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> , smp); |
| 410 | <a name="l00520"></a>00520 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a> + elem_mult (<a class="code" href="classbdm_1_1euni.html#ad3c27e331f90c754d80228108de8ed4c" title="internal">distance</a>, smp); |
413 | | <a name="l00523"></a>00523 |
414 | | <a name="l00524"></a><a class="code" href="classbdm_1_1euni.html#acaa07b8307bd793d5339d6583e0aba81">00524</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1euni.html#acaa07b8307bd793d5339d6583e0aba81" title="Compute log-probability of argument val In case the argument is out of suport return...">evallog</a> (<span class="keyword">const</span> vec &val)<span class="keyword"> const </span>{ |
415 | | <a name="l00525"></a>00525 <span class="keywordflow">if</span> (any (val < <a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>) && any (val > <a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>)) {<span class="keywordflow">return</span> inf;} |
416 | | <a name="l00526"></a>00526 <span class="keywordflow">else</span> <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1euni.html#a3e63be48dd58659663ca60cd18700476" title="cache of log( nk )">lnk</a>; |
417 | | <a name="l00527"></a>00527 } |
418 | | <a name="l00528"></a><a class="code" href="classbdm_1_1euni.html#afc5df80359ead2918384b2004ce67194">00528</a> vec <a class="code" href="classbdm_1_1euni.html#afc5df80359ead2918384b2004ce67194" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{ |
419 | | <a name="l00529"></a>00529 vec smp (<a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>); |
420 | | <a name="l00530"></a>00530 <span class="preprocessor">#pragma omp critical</span> |
421 | | <a name="l00531"></a>00531 <span class="preprocessor"></span> UniRNG.sample_vector (<a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> , smp); |
422 | | <a name="l00532"></a>00532 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a> + elem_mult (<a class="code" href="classbdm_1_1euni.html#ad3c27e331f90c754d80228108de8ed4c" title="internal">distance</a>, smp); |
423 | | <a name="l00533"></a>00533 } |
424 | | <a name="l00535"></a><a class="code" href="classbdm_1_1euni.html#a46caa8c13aba2e6228f964208918b226">00535</a> vec <a class="code" href="classbdm_1_1euni.html#a46caa8c13aba2e6228f964208918b226" title="set values of low and high ">mean</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> (<a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a> -<a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>) / 2.0;} |
425 | | <a name="l00536"></a><a class="code" href="classbdm_1_1euni.html#a951f932155111f6053c980f672b4c22c">00536</a> vec <a class="code" href="classbdm_1_1euni.html#a951f932155111f6053c980f672b4c22c" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> (pow (<a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>, 2) + pow (<a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>, 2) + elem_mult (<a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>, <a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>)) / 3.0;} |
426 | | <a name="l00547"></a><a class="code" href="classbdm_1_1euni.html#a77f5fef1f006fe056066da23b9e5f042">00547</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1euni.html#a77f5fef1f006fe056066da23b9e5f042">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>) { |
427 | | <a name="l00548"></a>00548 <a class="code" href="classbdm_1_1euni.html#a77f5fef1f006fe056066da23b9e5f042">epdf::from_setting</a> (<span class="keyword">set</span>); <span class="comment">// reads rv and rvc</span> |
428 | | <a name="l00549"></a>00549 |
429 | | <a name="l00550"></a>00550 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>, <span class="keyword">set</span>, <span class="stringliteral">"high"</span>, UI::compulsory); |
430 | | <a name="l00551"></a>00551 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>, <span class="keyword">set</span>, <span class="stringliteral">"low"</span>, UI::compulsory); |
431 | | <a name="l00552"></a>00552 set_parameters(<a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>,<a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>); |
432 | | <a name="l00553"></a>00553 <a class="code" href="classbdm_1_1euni.html#a70c5a7dcf7cb0f7ea83b9165f31868e9" title="This method TODO.">validate</a>(); |
433 | | <a name="l00554"></a>00554 } |
434 | | <a name="l00555"></a><a class="code" href="classbdm_1_1euni.html#a70c5a7dcf7cb0f7ea83b9165f31868e9">00555</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1euni.html#a70c5a7dcf7cb0f7ea83b9165f31868e9" title="This method TODO.">validate</a>() { |
435 | | <a name="l00556"></a>00556 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a>(<a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>.length()==<a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>.length(), <span class="stringliteral">"Incompatible high and low vectors"</span>); |
436 | | <a name="l00557"></a>00557 <a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = <a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>.length(); |
437 | | <a name="l00558"></a>00558 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> (min (<a class="code" href="classbdm_1_1euni.html#ad3c27e331f90c754d80228108de8ed4c" title="internal">distance</a>) > 0.0, <span class="stringliteral">"bad support"</span>); |
438 | | <a name="l00559"></a>00559 } |
439 | | <a name="l00560"></a>00560 }; |
440 | | <a name="l00561"></a>00561 <a class="code" href="user__info_8h.html#a4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a>(euni); |
441 | | <a name="l00562"></a>00562 |
442 | | <a name="l00568"></a>00568 <span class="keyword">template</span> < <span class="keyword">class</span> sq_T, <span class="keyword">template</span> <<span class="keyword">typename</span>> <span class="keyword">class </span>TEpdf = enorm > |
443 | | <a name="l00569"></a><a class="code" href="classbdm_1_1mlnorm.html">00569</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mpdf__internal.html" title="Mpdf with internal epdf that is modified by function condition.">mpdf_internal</a>< TEpdf<sq_T> > |
444 | | <a name="l00570"></a>00570 { |
445 | | <a name="l00571"></a>00571 <span class="keyword">protected</span>: |
446 | | <a name="l00573"></a><a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42">00573</a> mat <a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a>; |
447 | | <a name="l00575"></a><a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6">00575</a> vec <a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a>; |
448 | | <a name="l00576"></a>00576 <span class="comment">// vec& _mu; //cached epdf.mu; !!!!!! WHY NOT?</span> |
449 | | <a name="l00577"></a>00577 <span class="keyword">public</span>: |
450 | | <a name="l00580"></a>00580 <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm</a>() : <a class="code" href="classbdm_1_1mpdf__internal.html" title="Mpdf with internal epdf that is modified by function condition.">mpdf_internal</a>< TEpdf<sq_T> >() {}; |
451 | | <a name="l00581"></a>00581 <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm</a> (<span class="keyword">const</span> mat &<a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a>, <span class="keyword">const</span> vec &mu0, <span class="keyword">const</span> sq_T &R) : <a class="code" href="classbdm_1_1mpdf__internal.html" title="Mpdf with internal epdf that is modified by function condition.">mpdf_internal</a>< TEpdf<sq_T> >() { |
452 | | <a name="l00582"></a>00582 <a class="code" href="classbdm_1_1mlnorm.html#a04f7c6cda7b2f95161dd5fbcf15d1fd5" title="Set A and R.">set_parameters</a> (A, mu0, R); |
453 | | <a name="l00583"></a>00583 } |
454 | | <a name="l00584"></a>00584 |
455 | | <a name="l00586"></a><a class="code" href="classbdm_1_1mlnorm.html#a04f7c6cda7b2f95161dd5fbcf15d1fd5">00586</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlnorm.html#a04f7c6cda7b2f95161dd5fbcf15d1fd5" title="Set A and R.">set_parameters</a> (<span class="keyword">const</span> mat &A0, <span class="keyword">const</span> vec &mu0, <span class="keyword">const</span> sq_T &R0) { |
456 | | <a name="l00587"></a>00587 this-><a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.set_parameters (zeros (A0.rows()), R0); |
457 | | <a name="l00588"></a>00588 <a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a> = A0; |
458 | | <a name="l00589"></a>00589 <a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a> = mu0; |
459 | | <a name="l00590"></a>00590 this-><a class="code" href="classbdm_1_1mpdf.html#a7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a> = A0.cols(); |
460 | | <a name="l00591"></a>00591 } |
461 | | <a name="l00594"></a><a class="code" href="classbdm_1_1mlnorm.html#ac2895ae549ee76d961be98d7061bd110">00594</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlnorm.html#ac2895ae549ee76d961be98d7061bd110">condition</a> (<span class="keyword">const</span> vec &cond) { |
462 | | <a name="l00595"></a>00595 this-><a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>._mu() = <a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a> * cond + <a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a>; |
463 | | <a name="l00596"></a>00596 <span class="comment">//R is already assigned;</span> |
464 | | <a name="l00597"></a>00597 } |
465 | | <a name="l00598"></a>00598 |
466 | | <a name="l00600"></a><a class="code" href="classbdm_1_1mlnorm.html#af6b0b4b0b17271525ad02660a4087cf7">00600</a> <span class="keyword">const</span> vec& <a class="code" href="classbdm_1_1mlnorm.html#af6b0b4b0b17271525ad02660a4087cf7" title="access function">_mu_const</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a>;} |
467 | | <a name="l00602"></a><a class="code" href="classbdm_1_1mlnorm.html#a55e1bd7fa70b852bd7fe50ce72fb8f23">00602</a> <span class="keyword">const</span> mat& <a class="code" href="classbdm_1_1mlnorm.html#a55e1bd7fa70b852bd7fe50ce72fb8f23" title="access function">_A</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a>;} |
468 | | <a name="l00604"></a><a class="code" href="classbdm_1_1mlnorm.html#a9af0714b7b29ab1162ebc3291b7c4a43">00604</a> mat <a class="code" href="classbdm_1_1mlnorm.html#a9af0714b7b29ab1162ebc3291b7c4a43" title="access function">_R</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> this-><a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>._R().to_mat(); } |
469 | | <a name="l00605"></a>00605 |
470 | | <a name="l00607"></a>00607 <span class="keyword">template</span><<span class="keyword">typename</span> sq_M> |
471 | | <a name="l00608"></a>00608 <span class="keyword">friend</span> std::ostream &operator<< (std::ostream &os, mlnorm<sq_M, enorm> &ml); |
472 | | <a name="l00609"></a>00609 |
473 | | <a name="l00620"></a><a class="code" href="classbdm_1_1mlnorm.html#a52980f13d80162d00b30d5864343f564">00620</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlnorm.html#a52980f13d80162d00b30d5864343f564">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>) { |
474 | | <a name="l00621"></a>00621 <a class="code" href="classbdm_1_1mlnorm.html#a52980f13d80162d00b30d5864343f564">mpdf::from_setting</a> (<span class="keyword">set</span>); |
475 | | <a name="l00622"></a>00622 |
476 | | <a name="l00623"></a>00623 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a>, <span class="keyword">set</span>, <span class="stringliteral">"A"</span>, UI::compulsory); |
477 | | <a name="l00624"></a>00624 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a>, <span class="keyword">set</span>, <span class="stringliteral">"const"</span>, UI::compulsory); |
478 | | <a name="l00625"></a>00625 mat R0; |
479 | | <a name="l00626"></a>00626 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (R0, <span class="keyword">set</span>, <span class="stringliteral">"R"</span>, UI::compulsory); |
480 | | <a name="l00627"></a>00627 <a class="code" href="classbdm_1_1mlnorm.html#a04f7c6cda7b2f95161dd5fbcf15d1fd5" title="Set A and R.">set_parameters</a> (<a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a>, <a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a>, R0); |
481 | | <a name="l00628"></a>00628 <a class="code" href="classbdm_1_1mlnorm.html#acafcb3fb9bad8ff5fd51897f6eb10924" title="This method TODO.">validate</a>(); |
482 | | <a name="l00629"></a>00629 }; |
483 | | <a name="l00630"></a><a class="code" href="classbdm_1_1mlnorm.html#acafcb3fb9bad8ff5fd51897f6eb10924">00630</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlnorm.html#acafcb3fb9bad8ff5fd51897f6eb10924" title="This method TODO.">validate</a>() { |
484 | | <a name="l00631"></a>00631 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> (<a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a>.rows() == <a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a>.length(), <span class="stringliteral">"mlnorm: A vs. mu mismatch"</span>); |
485 | | <a name="l00632"></a>00632 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> (<a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a>.rows() == <a class="code" href="classbdm_1_1mlnorm.html#a9af0714b7b29ab1162ebc3291b7c4a43" title="access function">_R</a>().rows(), <span class="stringliteral">"mlnorm: A vs. R mismatch"</span>); |
486 | | <a name="l00633"></a>00633 |
487 | | <a name="l00634"></a>00634 } |
488 | | <a name="l00635"></a>00635 }; |
489 | | <a name="l00636"></a>00636 <a class="code" href="user__info_8h.html#ab06f1e7c44a8306e321f62a0099210b9" title="Variant of UIREGISTER for templated classes.">UIREGISTER2</a> (mlnorm,ldmat); |
490 | | <a name="l00637"></a>00637 SHAREDPTR2 ( mlnorm, ldmat ); |
491 | | <a name="l00638"></a>00638 <a class="code" href="user__info_8h.html#ab06f1e7c44a8306e321f62a0099210b9" title="Variant of UIREGISTER for templated classes.">UIREGISTER2</a> (mlnorm,fsqmat); |
492 | | <a name="l00639"></a>00639 SHAREDPTR2 ( mlnorm, fsqmat ); |
493 | | <a name="l00640"></a>00640 <a class="code" href="user__info_8h.html#ab06f1e7c44a8306e321f62a0099210b9" title="Variant of UIREGISTER for templated classes.">UIREGISTER2</a> (mlnorm, chmat); |
494 | | <a name="l00641"></a>00641 SHAREDPTR2 ( mlnorm, chmat ); |
495 | | <a name="l00642"></a>00642 |
496 | | <a name="l00644"></a>00644 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
497 | | <a name="l00645"></a><a class="code" href="classbdm_1_1mgnorm.html">00645</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mgnorm.html" title="Mpdf with general function for mean value.">mgnorm</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mpdf__internal.html" title="Mpdf with internal epdf that is modified by function condition.">mpdf_internal</a>< enorm< sq_T > > |
498 | | <a name="l00646"></a>00646 { |
499 | | <a name="l00647"></a>00647 <span class="keyword">private</span>: |
500 | | <a name="l00648"></a>00648 <span class="comment">// vec &mu; WHY NOT?</span> |
501 | | <a name="l00649"></a>00649 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<fnc></a> g; |
502 | | <a name="l00650"></a>00650 |
503 | | <a name="l00651"></a>00651 <span class="keyword">public</span>: |
504 | | <a name="l00653"></a><a class="code" href="classbdm_1_1mgnorm.html#a1b014915d74470d3efab74e07cacb97d">00653</a> <a class="code" href="classbdm_1_1mgnorm.html#a1b014915d74470d3efab74e07cacb97d" title="default constructor">mgnorm</a>() : <a class="code" href="classbdm_1_1mpdf__internal.html" title="Mpdf with internal epdf that is modified by function condition.">mpdf_internal</a><<a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm</a><sq_T> >() { } |
505 | | <a name="l00655"></a>00655 <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgnorm.html#ab736332d20e418bf50d45836e129f339" title="set mean function">set_parameters</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<fnc></a> &g0, <span class="keyword">const</span> sq_T &R0); |
506 | | <a name="l00656"></a>00656 <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgnorm.html#ab31d63472cf6a1030cd8dbd8094c1f6d" title="Update iepdf so that it represents this mpdf conditioned on rvc = cond This function...">condition</a> (<span class="keyword">const</span> vec &cond); |
507 | | <a name="l00657"></a>00657 |
508 | | <a name="l00658"></a>00658 |
509 | | <a name="l00677"></a><a class="code" href="classbdm_1_1mgnorm.html#ad717dacc6a9eb967f8410994dc6dc6f9">00677</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgnorm.html#ad717dacc6a9eb967f8410994dc6dc6f9">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>) { |
510 | | <a name="l00678"></a>00678 <a class="code" href="classbdm_1_1mgnorm.html#ad717dacc6a9eb967f8410994dc6dc6f9">mpdf::from_setting</a>(<span class="keyword">set</span>); |
511 | | <a name="l00679"></a>00679 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<fnc></a> g = UI::build<fnc> (<span class="keyword">set</span>, <span class="stringliteral">"g"</span>, UI::compulsory); |
512 | | <a name="l00680"></a>00680 |
513 | | <a name="l00681"></a>00681 mat R; |
514 | | <a name="l00682"></a>00682 vec dR; |
515 | | <a name="l00683"></a>00683 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (dR, <span class="keyword">set</span>, <span class="stringliteral">"dR"</span>)) |
516 | | <a name="l00684"></a>00684 R = diag (dR); |
517 | | <a name="l00685"></a>00685 <span class="keywordflow">else</span> |
518 | | <a name="l00686"></a>00686 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (R, <span class="keyword">set</span>, <span class="stringliteral">"R"</span>, UI::compulsory); |
| 412 | <a name="l00523"></a><a class="code" href="classbdm_1_1euni.html#a46caa8c13aba2e6228f964208918b226">00523</a> vec <a class="code" href="classbdm_1_1euni.html#a46caa8c13aba2e6228f964208918b226" title="set values of low and high ">mean</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> (<a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a> -<a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>) / 2.0;} |
| 413 | <a name="l00524"></a><a class="code" href="classbdm_1_1euni.html#a951f932155111f6053c980f672b4c22c">00524</a> vec <a class="code" href="classbdm_1_1euni.html#a951f932155111f6053c980f672b4c22c" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> (pow (<a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>, 2) + pow (<a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>, 2) + elem_mult (<a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>, <a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>)) / 3.0;} |
| 414 | <a name="l00535"></a><a class="code" href="classbdm_1_1euni.html#a77f5fef1f006fe056066da23b9e5f042">00535</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1euni.html#a77f5fef1f006fe056066da23b9e5f042">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>) { |
| 415 | <a name="l00536"></a>00536 <a class="code" href="classbdm_1_1euni.html#a77f5fef1f006fe056066da23b9e5f042">epdf::from_setting</a> (<span class="keyword">set</span>); <span class="comment">// reads rv and rvc</span> |
| 416 | <a name="l00537"></a>00537 |
| 417 | <a name="l00538"></a>00538 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>, <span class="keyword">set</span>, <span class="stringliteral">"high"</span>, UI::compulsory); |
| 418 | <a name="l00539"></a>00539 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>, <span class="keyword">set</span>, <span class="stringliteral">"low"</span>, UI::compulsory); |
| 419 | <a name="l00540"></a>00540 set_parameters(<a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>,<a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>); |
| 420 | <a name="l00541"></a>00541 <a class="code" href="classbdm_1_1euni.html#a70c5a7dcf7cb0f7ea83b9165f31868e9" title="This method TODO.">validate</a>(); |
| 421 | <a name="l00542"></a>00542 } |
| 422 | <a name="l00543"></a><a class="code" href="classbdm_1_1euni.html#a70c5a7dcf7cb0f7ea83b9165f31868e9">00543</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1euni.html#a70c5a7dcf7cb0f7ea83b9165f31868e9" title="This method TODO.">validate</a>() { |
| 423 | <a name="l00544"></a>00544 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a>(<a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>.length()==<a class="code" href="classbdm_1_1euni.html#aff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>.length(), <span class="stringliteral">"Incompatible high and low vectors"</span>); |
| 424 | <a name="l00545"></a>00545 <a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = <a class="code" href="classbdm_1_1euni.html#acfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>.length(); |
| 425 | <a name="l00546"></a>00546 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> (min (<a class="code" href="classbdm_1_1euni.html#ad3c27e331f90c754d80228108de8ed4c" title="internal">distance</a>) > 0.0, <span class="stringliteral">"bad support"</span>); |
| 426 | <a name="l00547"></a>00547 } |
| 427 | <a name="l00548"></a>00548 }; |
| 428 | <a name="l00549"></a>00549 <a class="code" href="user__info_8h.html#a4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a>(euni); |
| 429 | <a name="l00550"></a>00550 |
| 430 | <a name="l00556"></a>00556 <span class="keyword">template</span> < <span class="keyword">class</span> sq_T, <span class="keyword">template</span> <<span class="keyword">typename</span>> <span class="keyword">class </span>TEpdf = enorm > |
| 431 | <a name="l00557"></a><a class="code" href="classbdm_1_1mlnorm.html">00557</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mpdf__internal.html" title="Mpdf with internal epdf that is modified by function condition.">mpdf_internal</a>< TEpdf<sq_T> > |
| 432 | <a name="l00558"></a>00558 { |
| 433 | <a name="l00559"></a>00559 <span class="keyword">protected</span>: |
| 434 | <a name="l00561"></a><a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42">00561</a> mat <a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a>; |
| 435 | <a name="l00563"></a><a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6">00563</a> vec <a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a>; |
| 436 | <a name="l00564"></a>00564 <span class="comment">// vec& _mu; //cached epdf.mu; !!!!!! WHY NOT?</span> |
| 437 | <a name="l00565"></a>00565 <span class="keyword">public</span>: |
| 438 | <a name="l00568"></a>00568 <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm</a>() : <a class="code" href="classbdm_1_1mpdf__internal.html" title="Mpdf with internal epdf that is modified by function condition.">mpdf_internal</a>< TEpdf<sq_T> >() {}; |
| 439 | <a name="l00569"></a>00569 <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm</a> (<span class="keyword">const</span> mat &<a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a>, <span class="keyword">const</span> vec &mu0, <span class="keyword">const</span> sq_T &R) : <a class="code" href="classbdm_1_1mpdf__internal.html" title="Mpdf with internal epdf that is modified by function condition.">mpdf_internal</a>< TEpdf<sq_T> >() { |
| 440 | <a name="l00570"></a>00570 <a class="code" href="classbdm_1_1mlnorm.html#a04f7c6cda7b2f95161dd5fbcf15d1fd5" title="Set A and R.">set_parameters</a> (A, mu0, R); |
| 441 | <a name="l00571"></a>00571 } |
| 442 | <a name="l00572"></a>00572 |
| 443 | <a name="l00574"></a><a class="code" href="classbdm_1_1mlnorm.html#a04f7c6cda7b2f95161dd5fbcf15d1fd5">00574</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlnorm.html#a04f7c6cda7b2f95161dd5fbcf15d1fd5" title="Set A and R.">set_parameters</a> (<span class="keyword">const</span> mat &A0, <span class="keyword">const</span> vec &mu0, <span class="keyword">const</span> sq_T &R0) { |
| 444 | <a name="l00575"></a>00575 this-><a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.set_parameters (zeros (A0.rows()), R0); |
| 445 | <a name="l00576"></a>00576 <a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a> = A0; |
| 446 | <a name="l00577"></a>00577 <a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a> = mu0; |
| 447 | <a name="l00578"></a>00578 this-><a class="code" href="classbdm_1_1mpdf.html#a7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a> = A0.cols(); |
| 448 | <a name="l00579"></a>00579 } |
| 449 | <a name="l00582"></a><a class="code" href="classbdm_1_1mlnorm.html#ac2895ae549ee76d961be98d7061bd110">00582</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlnorm.html#ac2895ae549ee76d961be98d7061bd110">condition</a> (<span class="keyword">const</span> vec &cond) { |
| 450 | <a name="l00583"></a>00583 this-><a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>._mu() = <a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a> * cond + <a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a>; |
| 451 | <a name="l00584"></a>00584 <span class="comment">//R is already assigned;</span> |
| 452 | <a name="l00585"></a>00585 } |
| 453 | <a name="l00586"></a>00586 |
| 454 | <a name="l00588"></a><a class="code" href="classbdm_1_1mlnorm.html#af6b0b4b0b17271525ad02660a4087cf7">00588</a> <span class="keyword">const</span> vec& <a class="code" href="classbdm_1_1mlnorm.html#af6b0b4b0b17271525ad02660a4087cf7" title="access function">_mu_const</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a>;} |
| 455 | <a name="l00590"></a><a class="code" href="classbdm_1_1mlnorm.html#a55e1bd7fa70b852bd7fe50ce72fb8f23">00590</a> <span class="keyword">const</span> mat& <a class="code" href="classbdm_1_1mlnorm.html#a55e1bd7fa70b852bd7fe50ce72fb8f23" title="access function">_A</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a>;} |
| 456 | <a name="l00592"></a><a class="code" href="classbdm_1_1mlnorm.html#a9af0714b7b29ab1162ebc3291b7c4a43">00592</a> mat <a class="code" href="classbdm_1_1mlnorm.html#a9af0714b7b29ab1162ebc3291b7c4a43" title="access function">_R</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> this-><a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>._R().to_mat(); } |
| 457 | <a name="l00593"></a>00593 |
| 458 | <a name="l00595"></a>00595 <span class="keyword">template</span><<span class="keyword">typename</span> sq_M> |
| 459 | <a name="l00596"></a>00596 <span class="keyword">friend</span> std::ostream &operator<< (std::ostream &os, mlnorm<sq_M, enorm> &ml); |
| 460 | <a name="l00597"></a>00597 |
| 461 | <a name="l00608"></a><a class="code" href="classbdm_1_1mlnorm.html#a52980f13d80162d00b30d5864343f564">00608</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlnorm.html#a52980f13d80162d00b30d5864343f564">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>) { |
| 462 | <a name="l00609"></a>00609 <a class="code" href="classbdm_1_1mlnorm.html#a52980f13d80162d00b30d5864343f564">mpdf::from_setting</a> (<span class="keyword">set</span>); |
| 463 | <a name="l00610"></a>00610 |
| 464 | <a name="l00611"></a>00611 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a>, <span class="keyword">set</span>, <span class="stringliteral">"A"</span>, UI::compulsory); |
| 465 | <a name="l00612"></a>00612 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (<a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a>, <span class="keyword">set</span>, <span class="stringliteral">"const"</span>, UI::compulsory); |
| 466 | <a name="l00613"></a>00613 mat R0; |
| 467 | <a name="l00614"></a>00614 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (R0, <span class="keyword">set</span>, <span class="stringliteral">"R"</span>, UI::compulsory); |
| 468 | <a name="l00615"></a>00615 <a class="code" href="classbdm_1_1mlnorm.html#a04f7c6cda7b2f95161dd5fbcf15d1fd5" title="Set A and R.">set_parameters</a> (<a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a>, <a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a>, R0); |
| 469 | <a name="l00616"></a>00616 <a class="code" href="classbdm_1_1mlnorm.html#acafcb3fb9bad8ff5fd51897f6eb10924" title="This method TODO.">validate</a>(); |
| 470 | <a name="l00617"></a>00617 }; |
| 471 | <a name="l00618"></a><a class="code" href="classbdm_1_1mlnorm.html#acafcb3fb9bad8ff5fd51897f6eb10924">00618</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlnorm.html#acafcb3fb9bad8ff5fd51897f6eb10924" title="This method TODO.">validate</a>() { |
| 472 | <a name="l00619"></a>00619 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> (<a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a>.rows() == <a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a>.length(), <span class="stringliteral">"mlnorm: A vs. mu mismatch"</span>); |
| 473 | <a name="l00620"></a>00620 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> (<a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a>.rows() == <a class="code" href="classbdm_1_1mlnorm.html#a9af0714b7b29ab1162ebc3291b7c4a43" title="access function">_R</a>().rows(), <span class="stringliteral">"mlnorm: A vs. R mismatch"</span>); |
| 474 | <a name="l00621"></a>00621 |
| 475 | <a name="l00622"></a>00622 } |
| 476 | <a name="l00623"></a>00623 }; |
| 477 | <a name="l00624"></a>00624 <a class="code" href="user__info_8h.html#ab06f1e7c44a8306e321f62a0099210b9" title="Variant of UIREGISTER for templated classes.">UIREGISTER2</a> (mlnorm,ldmat); |
| 478 | <a name="l00625"></a>00625 SHAREDPTR2 ( mlnorm, ldmat ); |
| 479 | <a name="l00626"></a>00626 <a class="code" href="user__info_8h.html#ab06f1e7c44a8306e321f62a0099210b9" title="Variant of UIREGISTER for templated classes.">UIREGISTER2</a> (mlnorm,fsqmat); |
| 480 | <a name="l00627"></a>00627 SHAREDPTR2 ( mlnorm, fsqmat ); |
| 481 | <a name="l00628"></a>00628 <a class="code" href="user__info_8h.html#ab06f1e7c44a8306e321f62a0099210b9" title="Variant of UIREGISTER for templated classes.">UIREGISTER2</a> (mlnorm, chmat); |
| 482 | <a name="l00629"></a>00629 SHAREDPTR2 ( mlnorm, chmat ); |
| 483 | <a name="l00630"></a>00630 |
| 484 | <a name="l00632"></a>00632 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
| 485 | <a name="l00633"></a><a class="code" href="classbdm_1_1mgnorm.html">00633</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mgnorm.html" title="Mpdf with general function for mean value.">mgnorm</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mpdf__internal.html" title="Mpdf with internal epdf that is modified by function condition.">mpdf_internal</a>< enorm< sq_T > > |
| 486 | <a name="l00634"></a>00634 { |
| 487 | <a name="l00635"></a>00635 <span class="keyword">private</span>: |
| 488 | <a name="l00636"></a>00636 <span class="comment">// vec &mu; WHY NOT?</span> |
| 489 | <a name="l00637"></a>00637 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<fnc></a> g; |
| 490 | <a name="l00638"></a>00638 |
| 491 | <a name="l00639"></a>00639 <span class="keyword">public</span>: |
| 492 | <a name="l00641"></a><a class="code" href="classbdm_1_1mgnorm.html#a1b014915d74470d3efab74e07cacb97d">00641</a> <a class="code" href="classbdm_1_1mgnorm.html#a1b014915d74470d3efab74e07cacb97d" title="default constructor">mgnorm</a>() : <a class="code" href="classbdm_1_1mpdf__internal.html" title="Mpdf with internal epdf that is modified by function condition.">mpdf_internal</a><<a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm</a><sq_T> >() { } |
| 493 | <a name="l00643"></a>00643 <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgnorm.html#ab736332d20e418bf50d45836e129f339" title="set mean function">set_parameters</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<fnc></a> &g0, <span class="keyword">const</span> sq_T &R0); |
| 494 | <a name="l00644"></a>00644 <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgnorm.html#ab31d63472cf6a1030cd8dbd8094c1f6d" title="Update iepdf so that it represents this mpdf conditioned on rvc = cond This function...">condition</a> (<span class="keyword">const</span> vec &cond); |
| 495 | <a name="l00645"></a>00645 |
| 496 | <a name="l00646"></a>00646 |
| 497 | <a name="l00665"></a><a class="code" href="classbdm_1_1mgnorm.html#ad717dacc6a9eb967f8410994dc6dc6f9">00665</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgnorm.html#ad717dacc6a9eb967f8410994dc6dc6f9">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>) { |
| 498 | <a name="l00666"></a>00666 <a class="code" href="classbdm_1_1mgnorm.html#ad717dacc6a9eb967f8410994dc6dc6f9">mpdf::from_setting</a>(<span class="keyword">set</span>); |
| 499 | <a name="l00667"></a>00667 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<fnc></a> g = UI::build<fnc> (<span class="keyword">set</span>, <span class="stringliteral">"g"</span>, UI::compulsory); |
| 500 | <a name="l00668"></a>00668 |
| 501 | <a name="l00669"></a>00669 mat R; |
| 502 | <a name="l00670"></a>00670 vec dR; |
| 503 | <a name="l00671"></a>00671 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (dR, <span class="keyword">set</span>, <span class="stringliteral">"dR"</span>)) |
| 504 | <a name="l00672"></a>00672 R = diag (dR); |
| 505 | <a name="l00673"></a>00673 <span class="keywordflow">else</span> |
| 506 | <a name="l00674"></a>00674 <a class="code" href="classbdm_1_1UI.html#acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> (R, <span class="keyword">set</span>, <span class="stringliteral">"R"</span>, UI::compulsory); |
| 507 | <a name="l00675"></a>00675 |
| 508 | <a name="l00676"></a>00676 <a class="code" href="classbdm_1_1mgnorm.html#ab736332d20e418bf50d45836e129f339" title="set mean function">set_parameters</a> (g, R); |
| 509 | <a name="l00677"></a>00677 <a class="code" href="classbdm_1_1mgnorm.html#aa5cbae3b521d010016af26a3a3124158" title="This method TODO.">validate</a>(); |
| 510 | <a name="l00678"></a>00678 } |
| 511 | <a name="l00679"></a><a class="code" href="classbdm_1_1mgnorm.html#aa5cbae3b521d010016af26a3a3124158">00679</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgnorm.html#aa5cbae3b521d010016af26a3a3124158" title="This method TODO.">validate</a>() { |
| 512 | <a name="l00680"></a>00680 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a>(g->dimension()==this->dimension(),<span class="stringliteral">"incompatible function"</span>); |
| 513 | <a name="l00681"></a>00681 } |
| 514 | <a name="l00682"></a>00682 }; |
| 515 | <a name="l00683"></a>00683 |
| 516 | <a name="l00684"></a>00684 <a class="code" href="user__info_8h.html#ab06f1e7c44a8306e321f62a0099210b9" title="Variant of UIREGISTER for templated classes.">UIREGISTER2</a> (mgnorm, chmat); |
| 517 | <a name="l00685"></a>00685 SHAREDPTR2 ( mgnorm, chmat ); |
| 518 | <a name="l00686"></a>00686 |
520 | | <a name="l00688"></a>00688 <a class="code" href="classbdm_1_1mgnorm.html#ab736332d20e418bf50d45836e129f339" title="set mean function">set_parameters</a> (g, R); |
521 | | <a name="l00689"></a>00689 <a class="code" href="classbdm_1_1mgnorm.html#aa5cbae3b521d010016af26a3a3124158" title="This method TODO.">validate</a>(); |
522 | | <a name="l00690"></a>00690 } |
523 | | <a name="l00691"></a><a class="code" href="classbdm_1_1mgnorm.html#aa5cbae3b521d010016af26a3a3124158">00691</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgnorm.html#aa5cbae3b521d010016af26a3a3124158" title="This method TODO.">validate</a>() { |
524 | | <a name="l00692"></a>00692 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a>(g->dimension()==this->dimension(),<span class="stringliteral">"incompatible function"</span>); |
525 | | <a name="l00693"></a>00693 } |
526 | | <a name="l00694"></a>00694 }; |
527 | | <a name="l00695"></a>00695 |
528 | | <a name="l00696"></a>00696 <a class="code" href="user__info_8h.html#ab06f1e7c44a8306e321f62a0099210b9" title="Variant of UIREGISTER for templated classes.">UIREGISTER2</a> (mgnorm, chmat); |
529 | | <a name="l00697"></a>00697 SHAREDPTR2 ( mgnorm, chmat ); |
530 | | <a name="l00698"></a>00698 |
531 | | <a name="l00699"></a>00699 |
532 | | <a name="l00707"></a><a class="code" href="classbdm_1_1mlstudent.html">00707</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mlstudent.html">mlstudent</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm</a><ldmat, enorm> |
533 | | <a name="l00708"></a>00708 { |
534 | | <a name="l00709"></a>00709 <span class="keyword">protected</span>: |
535 | | <a name="l00711"></a><a class="code" href="classbdm_1_1mlstudent.html#a41595144a79594acbe288c6b59412657">00711</a> <a class="code" href="classbdm_1_1ldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a> <a class="code" href="classbdm_1_1mlstudent.html#a41595144a79594acbe288c6b59412657" title="Variable from theory.">Lambda</a>; |
536 | | <a name="l00713"></a><a class="code" href="classbdm_1_1mlstudent.html#a72e9bda4d6684e07faafc4b2192daf39">00713</a> <a class="code" href="classbdm_1_1ldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a> &<a class="code" href="classbdm_1_1mlnorm.html#a9af0714b7b29ab1162ebc3291b7c4a43" title="access function">_R</a>; |
537 | | <a name="l00715"></a><a class="code" href="classbdm_1_1mlstudent.html#a1c063ad6cb6e079ee11bc4128c2c9fe8">00715</a> <a class="code" href="classbdm_1_1ldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a> <a class="code" href="classbdm_1_1mlstudent.html#a1c063ad6cb6e079ee11bc4128c2c9fe8" title="Variable .">Re</a>; |
538 | | <a name="l00716"></a>00716 <span class="keyword">public</span>: |
539 | | <a name="l00717"></a>00717 <a class="code" href="classbdm_1_1mlstudent.html">mlstudent</a> () : <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm</a><<a class="code" href="classbdm_1_1ldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a>, <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm</a>> (), |
540 | | <a name="l00718"></a>00718 <a class="code" href="classbdm_1_1mlstudent.html#a41595144a79594acbe288c6b59412657" title="Variable from theory.">Lambda</a> (), <a class="code" href="classbdm_1_1mlnorm.html#a9af0714b7b29ab1162ebc3291b7c4a43" title="access function">_R</a> (<a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.<a class="code" href="classbdm_1_1mlnorm.html#a9af0714b7b29ab1162ebc3291b7c4a43" title="access function">_R</a>()) {} |
541 | | <a name="l00720"></a><a class="code" href="classbdm_1_1mlstudent.html#a4cdf79aac1b2165c0290e73810a0e4a3">00720</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlstudent.html#a4cdf79aac1b2165c0290e73810a0e4a3" title="constructor function">set_parameters</a> (<span class="keyword">const</span> mat &A0, <span class="keyword">const</span> vec &mu0, <span class="keyword">const</span> <a class="code" href="classbdm_1_1ldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a> &R0, <span class="keyword">const</span> <a class="code" href="classbdm_1_1ldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a>& Lambda0) { |
542 | | <a name="l00721"></a>00721 <a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.set_parameters (mu0, R0);<span class="comment">// was Lambda, why?</span> |
543 | | <a name="l00722"></a>00722 <a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a> = A0; |
544 | | <a name="l00723"></a>00723 <a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a> = mu0; |
545 | | <a name="l00724"></a>00724 <a class="code" href="classbdm_1_1mlstudent.html#a1c063ad6cb6e079ee11bc4128c2c9fe8" title="Variable .">Re</a> = R0; |
546 | | <a name="l00725"></a>00725 <a class="code" href="classbdm_1_1mlstudent.html#a41595144a79594acbe288c6b59412657" title="Variable from theory.">Lambda</a> = Lambda0; |
547 | | <a name="l00726"></a>00726 } |
548 | | <a name="l00727"></a><a class="code" href="classbdm_1_1mlstudent.html#aefd37560585c8613897f30d3c2f58d0d">00727</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlstudent.html#aefd37560585c8613897f30d3c2f58d0d">condition</a> (<span class="keyword">const</span> vec &cond) { |
549 | | <a name="l00728"></a>00728 <a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>._mu() = <a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a> * cond + <a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a>; |
550 | | <a name="l00729"></a>00729 <span class="keywordtype">double</span> zeta; |
551 | | <a name="l00730"></a>00730 <span class="comment">//ugly hack!</span> |
552 | | <a name="l00731"></a>00731 <span class="keywordflow">if</span> ( (cond.length() + 1) == <a class="code" href="classbdm_1_1mlstudent.html#a41595144a79594acbe288c6b59412657" title="Variable from theory.">Lambda</a>.<a class="code" href="classbdm_1_1sqmat.html#a73e639221343dcce76c3305524d67590" title="Reimplementing common functions of mat: rows().">rows</a>()) { |
553 | | <a name="l00732"></a>00732 zeta = <a class="code" href="classbdm_1_1mlstudent.html#a41595144a79594acbe288c6b59412657" title="Variable from theory.">Lambda</a>.<a class="code" href="classbdm_1_1ldmat.html#af743de194aadb8515cf18226fadf365f" title="Evaluates quadratic form ;.">invqform</a> (concat (cond, vec_1 (1.0))); |
554 | | <a name="l00733"></a>00733 } <span class="keywordflow">else</span> { |
555 | | <a name="l00734"></a>00734 zeta = <a class="code" href="classbdm_1_1mlstudent.html#a41595144a79594acbe288c6b59412657" title="Variable from theory.">Lambda</a>.<a class="code" href="classbdm_1_1ldmat.html#af743de194aadb8515cf18226fadf365f" title="Evaluates quadratic form ;.">invqform</a> (cond); |
556 | | <a name="l00735"></a>00735 } |
557 | | <a name="l00736"></a>00736 <a class="code" href="classbdm_1_1mlnorm.html#a9af0714b7b29ab1162ebc3291b7c4a43" title="access function">_R</a> = <a class="code" href="classbdm_1_1mlstudent.html#a1c063ad6cb6e079ee11bc4128c2c9fe8" title="Variable .">Re</a>; |
558 | | <a name="l00737"></a>00737 <a class="code" href="classbdm_1_1mlnorm.html#a9af0714b7b29ab1162ebc3291b7c4a43" title="access function">_R</a> *= (1 + zeta);<span class="comment">// / ( nu ); << nu is in Re!!!!!!</span> |
559 | | <a name="l00738"></a>00738 }; |
560 | | <a name="l00739"></a>00739 |
561 | | <a name="l00740"></a><a class="code" href="classbdm_1_1mlstudent.html#a55869e091bca0e2af1c3667c05ba6261">00740</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlstudent.html#a55869e091bca0e2af1c3667c05ba6261" title="This method TODO.">validate</a>() { |
562 | | <a name="l00741"></a>00741 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> (<a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a>.rows() == <a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a>.length(), <span class="stringliteral">"mlstudent: A vs. mu mismatch"</span>); |
563 | | <a name="l00742"></a>00742 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> (<a class="code" href="classbdm_1_1mlnorm.html#a9af0714b7b29ab1162ebc3291b7c4a43" title="access function">_R</a>.rows() == <a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a>.rows(), <span class="stringliteral">"mlstudent: A vs. R mismatch"</span>); |
564 | | <a name="l00743"></a>00743 |
565 | | <a name="l00744"></a>00744 } |
566 | | <a name="l00745"></a>00745 }; |
567 | | <a name="l00755"></a><a class="code" href="classbdm_1_1mgamma.html">00755</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mgamma.html" title="Gamma random walk.">mgamma</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mpdf__internal.html" title="Mpdf with internal epdf that is modified by function condition.">mpdf_internal</a><egamma> |
568 | | <a name="l00756"></a>00756 { |
569 | | <a name="l00757"></a>00757 <span class="keyword">protected</span>: |
| 520 | <a name="l00695"></a><a class="code" href="classbdm_1_1mlstudent.html">00695</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mlstudent.html">mlstudent</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm</a><ldmat, enorm> |
| 521 | <a name="l00696"></a>00696 { |
| 522 | <a name="l00697"></a>00697 <span class="keyword">protected</span>: |
| 523 | <a name="l00699"></a><a class="code" href="classbdm_1_1mlstudent.html#a41595144a79594acbe288c6b59412657">00699</a> <a class="code" href="classbdm_1_1ldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a> <a class="code" href="classbdm_1_1mlstudent.html#a41595144a79594acbe288c6b59412657" title="Variable from theory.">Lambda</a>; |
| 524 | <a name="l00701"></a><a class="code" href="classbdm_1_1mlstudent.html#a72e9bda4d6684e07faafc4b2192daf39">00701</a> <a class="code" href="classbdm_1_1ldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a> &<a class="code" href="classbdm_1_1mlnorm.html#a9af0714b7b29ab1162ebc3291b7c4a43" title="access function">_R</a>; |
| 525 | <a name="l00703"></a><a class="code" href="classbdm_1_1mlstudent.html#a1c063ad6cb6e079ee11bc4128c2c9fe8">00703</a> <a class="code" href="classbdm_1_1ldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a> <a class="code" href="classbdm_1_1mlstudent.html#a1c063ad6cb6e079ee11bc4128c2c9fe8" title="Variable .">Re</a>; |
| 526 | <a name="l00704"></a>00704 <span class="keyword">public</span>: |
| 527 | <a name="l00705"></a>00705 <a class="code" href="classbdm_1_1mlstudent.html">mlstudent</a> () : <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm</a><<a class="code" href="classbdm_1_1ldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a>, <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm</a>> (), |
| 528 | <a name="l00706"></a>00706 <a class="code" href="classbdm_1_1mlstudent.html#a41595144a79594acbe288c6b59412657" title="Variable from theory.">Lambda</a> (), <a class="code" href="classbdm_1_1mlnorm.html#a9af0714b7b29ab1162ebc3291b7c4a43" title="access function">_R</a> (<a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.<a class="code" href="classbdm_1_1mlnorm.html#a9af0714b7b29ab1162ebc3291b7c4a43" title="access function">_R</a>()) {} |
| 529 | <a name="l00708"></a><a class="code" href="classbdm_1_1mlstudent.html#a4cdf79aac1b2165c0290e73810a0e4a3">00708</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlstudent.html#a4cdf79aac1b2165c0290e73810a0e4a3" title="constructor function">set_parameters</a> (<span class="keyword">const</span> mat &A0, <span class="keyword">const</span> vec &mu0, <span class="keyword">const</span> <a class="code" href="classbdm_1_1ldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a> &R0, <span class="keyword">const</span> <a class="code" href="classbdm_1_1ldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a>& Lambda0) { |
| 530 | <a name="l00709"></a>00709 <a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.set_parameters (mu0, R0);<span class="comment">// was Lambda, why?</span> |
| 531 | <a name="l00710"></a>00710 <a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a> = A0; |
| 532 | <a name="l00711"></a>00711 <a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a> = mu0; |
| 533 | <a name="l00712"></a>00712 <a class="code" href="classbdm_1_1mlstudent.html#a1c063ad6cb6e079ee11bc4128c2c9fe8" title="Variable .">Re</a> = R0; |
| 534 | <a name="l00713"></a>00713 <a class="code" href="classbdm_1_1mlstudent.html#a41595144a79594acbe288c6b59412657" title="Variable from theory.">Lambda</a> = Lambda0; |
| 535 | <a name="l00714"></a>00714 } |
| 536 | <a name="l00715"></a><a class="code" href="classbdm_1_1mlstudent.html#aefd37560585c8613897f30d3c2f58d0d">00715</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlstudent.html#aefd37560585c8613897f30d3c2f58d0d">condition</a> (<span class="keyword">const</span> vec &cond) { |
| 537 | <a name="l00716"></a>00716 <a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>._mu() = <a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a> * cond + <a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a>; |
| 538 | <a name="l00717"></a>00717 <span class="keywordtype">double</span> zeta; |
| 539 | <a name="l00718"></a>00718 <span class="comment">//ugly hack!</span> |
| 540 | <a name="l00719"></a>00719 <span class="keywordflow">if</span> ( (cond.length() + 1) == <a class="code" href="classbdm_1_1mlstudent.html#a41595144a79594acbe288c6b59412657" title="Variable from theory.">Lambda</a>.<a class="code" href="classbdm_1_1sqmat.html#a73e639221343dcce76c3305524d67590" title="Reimplementing common functions of mat: rows().">rows</a>()) { |
| 541 | <a name="l00720"></a>00720 zeta = <a class="code" href="classbdm_1_1mlstudent.html#a41595144a79594acbe288c6b59412657" title="Variable from theory.">Lambda</a>.<a class="code" href="classbdm_1_1ldmat.html#af743de194aadb8515cf18226fadf365f" title="Evaluates quadratic form ;.">invqform</a> (concat (cond, vec_1 (1.0))); |
| 542 | <a name="l00721"></a>00721 } <span class="keywordflow">else</span> { |
| 543 | <a name="l00722"></a>00722 zeta = <a class="code" href="classbdm_1_1mlstudent.html#a41595144a79594acbe288c6b59412657" title="Variable from theory.">Lambda</a>.<a class="code" href="classbdm_1_1ldmat.html#af743de194aadb8515cf18226fadf365f" title="Evaluates quadratic form ;.">invqform</a> (cond); |
| 544 | <a name="l00723"></a>00723 } |
| 545 | <a name="l00724"></a>00724 <a class="code" href="classbdm_1_1mlnorm.html#a9af0714b7b29ab1162ebc3291b7c4a43" title="access function">_R</a> = <a class="code" href="classbdm_1_1mlstudent.html#a1c063ad6cb6e079ee11bc4128c2c9fe8" title="Variable .">Re</a>; |
| 546 | <a name="l00725"></a>00725 <a class="code" href="classbdm_1_1mlnorm.html#a9af0714b7b29ab1162ebc3291b7c4a43" title="access function">_R</a> *= (1 + zeta);<span class="comment">// / ( nu ); << nu is in Re!!!!!!</span> |
| 547 | <a name="l00726"></a>00726 }; |
| 548 | <a name="l00727"></a>00727 |
| 549 | <a name="l00728"></a><a class="code" href="classbdm_1_1mlstudent.html#a55869e091bca0e2af1c3667c05ba6261">00728</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlstudent.html#a55869e091bca0e2af1c3667c05ba6261" title="This method TODO.">validate</a>() { |
| 550 | <a name="l00729"></a>00729 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> (<a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a>.rows() == <a class="code" href="classbdm_1_1mlnorm.html#a831b50121cad10aa03a16682bd0c3ed6" title="Constant additive term.">mu_const</a>.length(), <span class="stringliteral">"mlstudent: A vs. mu mismatch"</span>); |
| 551 | <a name="l00730"></a>00730 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> (<a class="code" href="classbdm_1_1mlnorm.html#a9af0714b7b29ab1162ebc3291b7c4a43" title="access function">_R</a>.rows() == <a class="code" href="classbdm_1_1mlnorm.html#ac71bbf59fc732beb2b459d7117bd6e42" title="Internal epdf that arise by conditioning on rvc.">A</a>.rows(), <span class="stringliteral">"mlstudent: A vs. R mismatch"</span>); |
| 552 | <a name="l00731"></a>00731 |
| 553 | <a name="l00732"></a>00732 } |
| 554 | <a name="l00733"></a>00733 }; |
| 555 | <a name="l00743"></a><a class="code" href="classbdm_1_1mgamma.html">00743</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mgamma.html" title="Gamma random walk.">mgamma</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mpdf__internal.html" title="Mpdf with internal epdf that is modified by function condition.">mpdf_internal</a><egamma> |
| 556 | <a name="l00744"></a>00744 { |
| 557 | <a name="l00745"></a>00745 <span class="keyword">protected</span>: |
| 558 | <a name="l00746"></a>00746 |
| 559 | <a name="l00748"></a><a class="code" href="classbdm_1_1mgamma.html#ab20cf88cca1fe9b0b8f2a412608bfd09">00748</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mgamma.html#ab20cf88cca1fe9b0b8f2a412608bfd09" title="Constant .">k</a>; |
| 560 | <a name="l00749"></a>00749 |
| 561 | <a name="l00751"></a><a class="code" href="classbdm_1_1mgamma.html#a3d95f4dde9214ff6dba265e18af60312">00751</a> vec &<a class="code" href="classbdm_1_1mgamma.html#a3d95f4dde9214ff6dba265e18af60312" title="cache of iepdf.beta">_beta</a>; |
| 562 | <a name="l00752"></a>00752 |
| 563 | <a name="l00753"></a>00753 <span class="keyword">public</span>: |
| 564 | <a name="l00755"></a><a class="code" href="classbdm_1_1mgamma.html#a1a9dc8661e5b214a8185d6e6b9956eb1">00755</a> <a class="code" href="classbdm_1_1mgamma.html#a1a9dc8661e5b214a8185d6e6b9956eb1" title="Constructor.">mgamma</a>() : <a class="code" href="classbdm_1_1mpdf__internal.html" title="Mpdf with internal epdf that is modified by function condition.">mpdf_internal</a><<a class="code" href="classbdm_1_1egamma.html" title="Gamma posterior density.">egamma</a>>(), <a class="code" href="classbdm_1_1mgamma.html#ab20cf88cca1fe9b0b8f2a412608bfd09" title="Constant .">k</a> (0), |
| 565 | <a name="l00756"></a>00756 <a class="code" href="classbdm_1_1mgamma.html#a3d95f4dde9214ff6dba265e18af60312" title="cache of iepdf.beta">_beta</a> (<a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.<a class="code" href="classbdm_1_1mgamma.html#a3d95f4dde9214ff6dba265e18af60312" title="cache of iepdf.beta">_beta</a>()) { |
| 566 | <a name="l00757"></a>00757 } |
616 | | <a name="l00835"></a><a class="code" href="classbdm_1_1migamma.html#a8b10ab922e2a7bae2fb6bb3efc7b6151">00835</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1migamma.html#a8b10ab922e2a7bae2fb6bb3efc7b6151" title="Set value of k.">set_parameters</a> (<span class="keywordtype">int</span> len, <span class="keywordtype">double</span> k0) { |
617 | | <a name="l00836"></a>00836 <a class="code" href="classbdm_1_1migamma.html#adc56bc9da542e0103ec16b9be8e5e38c" title="Constant .">k</a> = k0; |
618 | | <a name="l00837"></a>00837 <a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.set_parameters ( (1.0 / (<a class="code" href="classbdm_1_1migamma.html#adc56bc9da542e0103ec16b9be8e5e38c" title="Constant .">k</a>*<a class="code" href="classbdm_1_1migamma.html#adc56bc9da542e0103ec16b9be8e5e38c" title="Constant .">k</a>) + 2.0) *ones (len) <span class="comment">/*alpha*/</span>, ones (len) <span class="comment">/*beta*/</span>); |
619 | | <a name="l00838"></a>00838 <a class="code" href="classbdm_1_1mpdf.html#a7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a> = dimension(); |
620 | | <a name="l00839"></a>00839 }; |
621 | | <a name="l00840"></a><a class="code" href="classbdm_1_1migamma.html#a7a34b1e2e3aa2250d7c0ed7df1665b8c">00840</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1migamma.html#a7a34b1e2e3aa2250d7c0ed7df1665b8c" title="Update iepdf so that it represents this mpdf conditioned on rvc = cond This function...">condition</a> (<span class="keyword">const</span> vec &val) { |
622 | | <a name="l00841"></a>00841 <a class="code" href="classbdm_1_1migamma.html#a0d854c047001b5465cf1ba21f52904b5" title="cache of iepdf.beta">_beta</a> = elem_mult (val, (<a class="code" href="classbdm_1_1migamma.html#ac9847093da59a9ba0ebb68d2c592f5dc" title="cache of iepdf.alpha">_alpha</a> - 1.0)); |
623 | | <a name="l00842"></a>00842 }; |
624 | | <a name="l00843"></a>00843 }; |
625 | | <a name="l00844"></a>00844 |
626 | | <a name="l00845"></a>00845 |
627 | | <a name="l00857"></a><a class="code" href="classbdm_1_1mgamma__fix.html">00857</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mgamma__fix.html" title="Gamma random walk around a fixed point.">mgamma_fix</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mgamma.html" title="Gamma random walk.">mgamma</a> |
628 | | <a name="l00858"></a>00858 { |
629 | | <a name="l00859"></a>00859 <span class="keyword">protected</span>: |
630 | | <a name="l00861"></a><a class="code" href="classbdm_1_1mgamma__fix.html#a1eb701506aabb2e6af007e487212d6fa">00861</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mgamma__fix.html#a1eb701506aabb2e6af007e487212d6fa" title="parameter l">l</a>; |
631 | | <a name="l00863"></a><a class="code" href="classbdm_1_1mgamma__fix.html#a018c6f901a04e419455308a07eb3b0b2">00863</a> vec <a class="code" href="classbdm_1_1mgamma__fix.html#a018c6f901a04e419455308a07eb3b0b2" title="reference vector">refl</a>; |
632 | | <a name="l00864"></a>00864 <span class="keyword">public</span>: |
633 | | <a name="l00866"></a><a class="code" href="classbdm_1_1mgamma__fix.html#a9a31bc9b4b60188a18a2a6b588dc4b2d">00866</a> <a class="code" href="classbdm_1_1mgamma__fix.html#a9a31bc9b4b60188a18a2a6b588dc4b2d" title="Constructor.">mgamma_fix</a> () : <a class="code" href="classbdm_1_1mgamma.html" title="Gamma random walk.">mgamma</a> (), <a class="code" href="classbdm_1_1mgamma__fix.html#a018c6f901a04e419455308a07eb3b0b2" title="reference vector">refl</a> () {}; |
634 | | <a name="l00868"></a><a class="code" href="classbdm_1_1mgamma__fix.html#a1bfd30e90db9dc1fbda4a9fbb0b716b2">00868</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgamma__fix.html#a1bfd30e90db9dc1fbda4a9fbb0b716b2" title="Set value of k.">set_parameters</a> (<span class="keywordtype">double</span> k0 , vec ref0, <span class="keywordtype">double</span> l0) { |
635 | | <a name="l00869"></a>00869 <a class="code" href="classbdm_1_1mgamma__fix.html#a1bfd30e90db9dc1fbda4a9fbb0b716b2" title="Set value of k.">mgamma::set_parameters</a> (k0, ref0); |
636 | | <a name="l00870"></a>00870 <a class="code" href="classbdm_1_1mgamma__fix.html#a018c6f901a04e419455308a07eb3b0b2" title="reference vector">refl</a> = pow (ref0, 1.0 - l0);<a class="code" href="classbdm_1_1mgamma__fix.html#a1eb701506aabb2e6af007e487212d6fa" title="parameter l">l</a> = l0; |
637 | | <a name="l00871"></a>00871 <a class="code" href="classbdm_1_1mpdf.html#a7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a> = dimension(); |
638 | | <a name="l00872"></a>00872 }; |
639 | | <a name="l00873"></a>00873 |
640 | | <a name="l00874"></a><a class="code" href="classbdm_1_1mgamma__fix.html#a1d539591deb7a38bb3403c2b396c8ff7">00874</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgamma__fix.html#a1d539591deb7a38bb3403c2b396c8ff7" title="Update iepdf so that it represents this mpdf conditioned on rvc = cond This function...">condition</a> (<span class="keyword">const</span> vec &val) {vec mean = elem_mult (<a class="code" href="classbdm_1_1mgamma__fix.html#a018c6f901a04e419455308a07eb3b0b2" title="reference vector">refl</a>, pow (val, <a class="code" href="classbdm_1_1mgamma__fix.html#a1eb701506aabb2e6af007e487212d6fa" title="parameter l">l</a>)); <a class="code" href="classbdm_1_1mgamma.html#a3d95f4dde9214ff6dba265e18af60312" title="cache of iepdf.beta">_beta</a> = <a class="code" href="classbdm_1_1mgamma.html#ab20cf88cca1fe9b0b8f2a412608bfd09" title="Constant .">k</a> / mean;}; |
641 | | <a name="l00875"></a>00875 }; |
642 | | <a name="l00876"></a>00876 |
643 | | <a name="l00877"></a>00877 |
644 | | <a name="l00890"></a><a class="code" href="classbdm_1_1migamma__ref.html">00890</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1migamma__ref.html" title="Inverse-Gamma random walk around a fixed point.">migamma_ref</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1migamma.html" title="Inverse-Gamma random walk.">migamma</a> |
645 | | <a name="l00891"></a>00891 { |
646 | | <a name="l00892"></a>00892 <span class="keyword">protected</span>: |
647 | | <a name="l00894"></a><a class="code" href="classbdm_1_1migamma__ref.html#acdc1345ba8375fbdb18a69322d2f841d">00894</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1migamma__ref.html#acdc1345ba8375fbdb18a69322d2f841d" title="parameter l">l</a>; |
648 | | <a name="l00896"></a><a class="code" href="classbdm_1_1migamma__ref.html#a3692dc67caf4367e15564d37f45476f6">00896</a> vec <a class="code" href="classbdm_1_1migamma__ref.html#a3692dc67caf4367e15564d37f45476f6" title="reference vector">refl</a>; |
649 | | <a name="l00897"></a>00897 <span class="keyword">public</span>: |
650 | | <a name="l00899"></a><a class="code" href="classbdm_1_1migamma__ref.html#af45b15a10f084991ba6b48295f10421f">00899</a> <a class="code" href="classbdm_1_1migamma__ref.html#af45b15a10f084991ba6b48295f10421f" title="Constructor.">migamma_ref</a> () : <a class="code" href="classbdm_1_1migamma.html" title="Inverse-Gamma random walk.">migamma</a> (), <a class="code" href="classbdm_1_1migamma__ref.html#a3692dc67caf4367e15564d37f45476f6" title="reference vector">refl</a> () {}; |
651 | | <a name="l00901"></a><a class="code" href="classbdm_1_1migamma__ref.html#ab0b4eb278ef5d0831ec4954ba7bd2800">00901</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1migamma__ref.html#ab0b4eb278ef5d0831ec4954ba7bd2800" title="Set value of k.">set_parameters</a> (<span class="keywordtype">double</span> k0 , vec ref0, <span class="keywordtype">double</span> l0) { |
652 | | <a name="l00902"></a>00902 <a class="code" href="classbdm_1_1migamma__ref.html#ab0b4eb278ef5d0831ec4954ba7bd2800" title="Set value of k.">migamma::set_parameters</a> (ref0.length(), k0); |
653 | | <a name="l00903"></a>00903 <a class="code" href="classbdm_1_1migamma__ref.html#a3692dc67caf4367e15564d37f45476f6" title="reference vector">refl</a> = pow (ref0, 1.0 - l0); |
654 | | <a name="l00904"></a>00904 <a class="code" href="classbdm_1_1migamma__ref.html#acdc1345ba8375fbdb18a69322d2f841d" title="parameter l">l</a> = l0; |
655 | | <a name="l00905"></a>00905 <a class="code" href="classbdm_1_1mpdf.html#a7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a> = dimension(); |
656 | | <a name="l00906"></a>00906 }; |
657 | | <a name="l00907"></a>00907 |
658 | | <a name="l00908"></a><a class="code" href="classbdm_1_1migamma__ref.html#aae86b2e4ff963d62e05d4e130514634a">00908</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1migamma__ref.html#aae86b2e4ff963d62e05d4e130514634a" title="Update iepdf so that it represents this mpdf conditioned on rvc = cond This function...">condition</a> (<span class="keyword">const</span> vec &val) { |
659 | | <a name="l00909"></a>00909 vec mean = elem_mult (<a class="code" href="classbdm_1_1migamma__ref.html#a3692dc67caf4367e15564d37f45476f6" title="reference vector">refl</a>, pow (val, <a class="code" href="classbdm_1_1migamma__ref.html#acdc1345ba8375fbdb18a69322d2f841d" title="parameter l">l</a>)); |
660 | | <a name="l00910"></a>00910 <a class="code" href="classbdm_1_1migamma__ref.html#aae86b2e4ff963d62e05d4e130514634a" title="Update iepdf so that it represents this mpdf conditioned on rvc = cond This function...">migamma::condition</a> (mean); |
661 | | <a name="l00911"></a>00911 }; |
662 | | <a name="l00912"></a>00912 |
663 | | <a name="l00913"></a>00913 |
664 | | <a name="l00926"></a>00926 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1migamma__ref.html#a9e7e0f7d2aa9ecca8ec1af8cbcb5ef1d">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>); |
665 | | <a name="l00927"></a>00927 |
666 | | <a name="l00928"></a>00928 <span class="comment">// TODO dodelat void to_setting( Setting &set ) const;</span> |
667 | | <a name="l00929"></a>00929 }; |
668 | | <a name="l00930"></a>00930 |
669 | | <a name="l00931"></a>00931 |
670 | | <a name="l00932"></a>00932 <a class="code" href="user__info_8h.html#a4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a> (migamma_ref); |
671 | | <a name="l00933"></a>00933 SHAREDPTR (migamma_ref); |
672 | | <a name="l00934"></a>00934 |
673 | | <a name="l00945"></a><a class="code" href="classbdm_1_1elognorm.html">00945</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1elognorm.html">elognorm</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm</a><ldmat> |
674 | | <a name="l00946"></a>00946 { |
675 | | <a name="l00947"></a>00947 <span class="keyword">public</span>: |
676 | | <a name="l00948"></a><a class="code" href="classbdm_1_1elognorm.html#a8b948e2bce1253765a2542199913aaba">00948</a> vec <a class="code" href="classbdm_1_1elognorm.html#a8b948e2bce1253765a2542199913aaba" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> exp (<a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<ldmat>::sample</a>());}; |
677 | | <a name="l00949"></a><a class="code" href="classbdm_1_1elognorm.html#aadb41e4f4d6600dec6f8c1dbc5ed9eea">00949</a> vec <a class="code" href="classbdm_1_1elognorm.html#aadb41e4f4d6600dec6f8c1dbc5ed9eea" title="return expected value">mean</a>()<span class="keyword"> const </span>{vec var = <a class="code" href="classbdm_1_1enorm.html#a729c75ef0fa8abae03d58ad1f81e6773" title="return expected variance (not covariance!)">enorm<ldmat>::variance</a>();<span class="keywordflow">return</span> exp (<a class="code" href="classbdm_1_1enorm.html#ac702a194720853570d08b65482f842c7" title="mean value">mu</a> - 0.5*var);}; |
678 | | <a name="l00950"></a>00950 |
679 | | <a name="l00951"></a>00951 }; |
| 615 | <a name="l00845"></a><a class="code" href="classbdm_1_1mgamma__fix.html">00845</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mgamma__fix.html" title="Gamma random walk around a fixed point.">mgamma_fix</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mgamma.html" title="Gamma random walk.">mgamma</a> |
| 616 | <a name="l00846"></a>00846 { |
| 617 | <a name="l00847"></a>00847 <span class="keyword">protected</span>: |
| 618 | <a name="l00849"></a><a class="code" href="classbdm_1_1mgamma__fix.html#a1eb701506aabb2e6af007e487212d6fa">00849</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mgamma__fix.html#a1eb701506aabb2e6af007e487212d6fa" title="parameter l">l</a>; |
| 619 | <a name="l00851"></a><a class="code" href="classbdm_1_1mgamma__fix.html#a018c6f901a04e419455308a07eb3b0b2">00851</a> vec <a class="code" href="classbdm_1_1mgamma__fix.html#a018c6f901a04e419455308a07eb3b0b2" title="reference vector">refl</a>; |
| 620 | <a name="l00852"></a>00852 <span class="keyword">public</span>: |
| 621 | <a name="l00854"></a><a class="code" href="classbdm_1_1mgamma__fix.html#a9a31bc9b4b60188a18a2a6b588dc4b2d">00854</a> <a class="code" href="classbdm_1_1mgamma__fix.html#a9a31bc9b4b60188a18a2a6b588dc4b2d" title="Constructor.">mgamma_fix</a> () : <a class="code" href="classbdm_1_1mgamma.html" title="Gamma random walk.">mgamma</a> (), <a class="code" href="classbdm_1_1mgamma__fix.html#a018c6f901a04e419455308a07eb3b0b2" title="reference vector">refl</a> () {}; |
| 622 | <a name="l00856"></a><a class="code" href="classbdm_1_1mgamma__fix.html#a1bfd30e90db9dc1fbda4a9fbb0b716b2">00856</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgamma__fix.html#a1bfd30e90db9dc1fbda4a9fbb0b716b2" title="Set value of k.">set_parameters</a> (<span class="keywordtype">double</span> k0 , vec ref0, <span class="keywordtype">double</span> l0) { |
| 623 | <a name="l00857"></a>00857 <a class="code" href="classbdm_1_1mgamma__fix.html#a1bfd30e90db9dc1fbda4a9fbb0b716b2" title="Set value of k.">mgamma::set_parameters</a> (k0, ref0); |
| 624 | <a name="l00858"></a>00858 <a class="code" href="classbdm_1_1mgamma__fix.html#a018c6f901a04e419455308a07eb3b0b2" title="reference vector">refl</a> = pow (ref0, 1.0 - l0);<a class="code" href="classbdm_1_1mgamma__fix.html#a1eb701506aabb2e6af007e487212d6fa" title="parameter l">l</a> = l0; |
| 625 | <a name="l00859"></a>00859 <a class="code" href="classbdm_1_1mpdf.html#a7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a> = dimension(); |
| 626 | <a name="l00860"></a>00860 }; |
| 627 | <a name="l00861"></a>00861 |
| 628 | <a name="l00862"></a><a class="code" href="classbdm_1_1mgamma__fix.html#a1d539591deb7a38bb3403c2b396c8ff7">00862</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgamma__fix.html#a1d539591deb7a38bb3403c2b396c8ff7" title="Update iepdf so that it represents this mpdf conditioned on rvc = cond This function...">condition</a> (<span class="keyword">const</span> vec &val) {vec mean = elem_mult (<a class="code" href="classbdm_1_1mgamma__fix.html#a018c6f901a04e419455308a07eb3b0b2" title="reference vector">refl</a>, pow (val, <a class="code" href="classbdm_1_1mgamma__fix.html#a1eb701506aabb2e6af007e487212d6fa" title="parameter l">l</a>)); <a class="code" href="classbdm_1_1mgamma.html#a3d95f4dde9214ff6dba265e18af60312" title="cache of iepdf.beta">_beta</a> = <a class="code" href="classbdm_1_1mgamma.html#ab20cf88cca1fe9b0b8f2a412608bfd09" title="Constant .">k</a> / mean;}; |
| 629 | <a name="l00863"></a>00863 }; |
| 630 | <a name="l00864"></a>00864 |
| 631 | <a name="l00865"></a>00865 |
| 632 | <a name="l00878"></a><a class="code" href="classbdm_1_1migamma__ref.html">00878</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1migamma__ref.html" title="Inverse-Gamma random walk around a fixed point.">migamma_ref</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1migamma.html" title="Inverse-Gamma random walk.">migamma</a> |
| 633 | <a name="l00879"></a>00879 { |
| 634 | <a name="l00880"></a>00880 <span class="keyword">protected</span>: |
| 635 | <a name="l00882"></a><a class="code" href="classbdm_1_1migamma__ref.html#acdc1345ba8375fbdb18a69322d2f841d">00882</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1migamma__ref.html#acdc1345ba8375fbdb18a69322d2f841d" title="parameter l">l</a>; |
| 636 | <a name="l00884"></a><a class="code" href="classbdm_1_1migamma__ref.html#a3692dc67caf4367e15564d37f45476f6">00884</a> vec <a class="code" href="classbdm_1_1migamma__ref.html#a3692dc67caf4367e15564d37f45476f6" title="reference vector">refl</a>; |
| 637 | <a name="l00885"></a>00885 <span class="keyword">public</span>: |
| 638 | <a name="l00887"></a><a class="code" href="classbdm_1_1migamma__ref.html#af45b15a10f084991ba6b48295f10421f">00887</a> <a class="code" href="classbdm_1_1migamma__ref.html#af45b15a10f084991ba6b48295f10421f" title="Constructor.">migamma_ref</a> () : <a class="code" href="classbdm_1_1migamma.html" title="Inverse-Gamma random walk.">migamma</a> (), <a class="code" href="classbdm_1_1migamma__ref.html#a3692dc67caf4367e15564d37f45476f6" title="reference vector">refl</a> () {}; |
| 639 | <a name="l00889"></a><a class="code" href="classbdm_1_1migamma__ref.html#ab0b4eb278ef5d0831ec4954ba7bd2800">00889</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1migamma__ref.html#ab0b4eb278ef5d0831ec4954ba7bd2800" title="Set value of k.">set_parameters</a> (<span class="keywordtype">double</span> k0 , vec ref0, <span class="keywordtype">double</span> l0) { |
| 640 | <a name="l00890"></a>00890 <a class="code" href="classbdm_1_1migamma__ref.html#ab0b4eb278ef5d0831ec4954ba7bd2800" title="Set value of k.">migamma::set_parameters</a> (ref0.length(), k0); |
| 641 | <a name="l00891"></a>00891 <a class="code" href="classbdm_1_1migamma__ref.html#a3692dc67caf4367e15564d37f45476f6" title="reference vector">refl</a> = pow (ref0, 1.0 - l0); |
| 642 | <a name="l00892"></a>00892 <a class="code" href="classbdm_1_1migamma__ref.html#acdc1345ba8375fbdb18a69322d2f841d" title="parameter l">l</a> = l0; |
| 643 | <a name="l00893"></a>00893 <a class="code" href="classbdm_1_1mpdf.html#a7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a> = dimension(); |
| 644 | <a name="l00894"></a>00894 }; |
| 645 | <a name="l00895"></a>00895 |
| 646 | <a name="l00896"></a><a class="code" href="classbdm_1_1migamma__ref.html#aae86b2e4ff963d62e05d4e130514634a">00896</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1migamma__ref.html#aae86b2e4ff963d62e05d4e130514634a" title="Update iepdf so that it represents this mpdf conditioned on rvc = cond This function...">condition</a> (<span class="keyword">const</span> vec &val) { |
| 647 | <a name="l00897"></a>00897 vec mean = elem_mult (<a class="code" href="classbdm_1_1migamma__ref.html#a3692dc67caf4367e15564d37f45476f6" title="reference vector">refl</a>, pow (val, <a class="code" href="classbdm_1_1migamma__ref.html#acdc1345ba8375fbdb18a69322d2f841d" title="parameter l">l</a>)); |
| 648 | <a name="l00898"></a>00898 <a class="code" href="classbdm_1_1migamma__ref.html#aae86b2e4ff963d62e05d4e130514634a" title="Update iepdf so that it represents this mpdf conditioned on rvc = cond This function...">migamma::condition</a> (mean); |
| 649 | <a name="l00899"></a>00899 }; |
| 650 | <a name="l00900"></a>00900 |
| 651 | <a name="l00901"></a>00901 |
| 652 | <a name="l00914"></a>00914 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1migamma__ref.html#a9e7e0f7d2aa9ecca8ec1af8cbcb5ef1d">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>); |
| 653 | <a name="l00915"></a>00915 |
| 654 | <a name="l00916"></a>00916 <span class="comment">// TODO dodelat void to_setting( Setting &set ) const;</span> |
| 655 | <a name="l00917"></a>00917 }; |
| 656 | <a name="l00918"></a>00918 |
| 657 | <a name="l00919"></a>00919 |
| 658 | <a name="l00920"></a>00920 <a class="code" href="user__info_8h.html#a4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a> (migamma_ref); |
| 659 | <a name="l00921"></a>00921 SHAREDPTR (migamma_ref); |
| 660 | <a name="l00922"></a>00922 |
| 661 | <a name="l00933"></a><a class="code" href="classbdm_1_1elognorm.html">00933</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1elognorm.html">elognorm</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm</a><ldmat> |
| 662 | <a name="l00934"></a>00934 { |
| 663 | <a name="l00935"></a>00935 <span class="keyword">public</span>: |
| 664 | <a name="l00936"></a><a class="code" href="classbdm_1_1elognorm.html#a8b948e2bce1253765a2542199913aaba">00936</a> vec <a class="code" href="classbdm_1_1elognorm.html#a8b948e2bce1253765a2542199913aaba" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> exp (<a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<ldmat>::sample</a>());}; |
| 665 | <a name="l00937"></a><a class="code" href="classbdm_1_1elognorm.html#aadb41e4f4d6600dec6f8c1dbc5ed9eea">00937</a> vec <a class="code" href="classbdm_1_1elognorm.html#aadb41e4f4d6600dec6f8c1dbc5ed9eea" title="return expected value">mean</a>()<span class="keyword"> const </span>{vec var = <a class="code" href="classbdm_1_1enorm.html#a729c75ef0fa8abae03d58ad1f81e6773" title="return expected variance (not covariance!)">enorm<ldmat>::variance</a>();<span class="keywordflow">return</span> exp (<a class="code" href="classbdm_1_1enorm.html#ac702a194720853570d08b65482f842c7" title="mean value">mu</a> - 0.5*var);}; |
| 666 | <a name="l00938"></a>00938 |
| 667 | <a name="l00939"></a>00939 }; |
| 668 | <a name="l00940"></a>00940 |
| 669 | <a name="l00947"></a><a class="code" href="classbdm_1_1mlognorm.html">00947</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mlognorm.html" title="Log-Normal random walk.">mlognorm</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mpdf__internal.html" title="Mpdf with internal epdf that is modified by function condition.">mpdf_internal</a><elognorm> |
| 670 | <a name="l00948"></a>00948 { |
| 671 | <a name="l00949"></a>00949 <span class="keyword">protected</span>: |
| 672 | <a name="l00951"></a><a class="code" href="classbdm_1_1mlognorm.html#aa51128a2e503b8b2ce698244b9e0db1a">00951</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mlognorm.html#aa51128a2e503b8b2ce698244b9e0db1a" title="parameter 1/2*sigma^2">sig2</a>; |
693 | | <a name="l00975"></a><a class="code" href="classbdm_1_1mlognorm.html#a604cab0e8a76f9041dc3c606043bb39f">00975</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlognorm.html#a604cab0e8a76f9041dc3c606043bb39f" title="Set value of k.">set_parameters</a> (<span class="keywordtype">int</span> size, <span class="keywordtype">double</span> k) { |
694 | | <a name="l00976"></a>00976 <a class="code" href="classbdm_1_1mlognorm.html#aa51128a2e503b8b2ce698244b9e0db1a" title="parameter 1/2*sigma^2">sig2</a> = 0.5 * log (k * k + 1); |
695 | | <a name="l00977"></a>00977 <a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.set_parameters (zeros (size), 2*<a class="code" href="classbdm_1_1mlognorm.html#aa51128a2e503b8b2ce698244b9e0db1a" title="parameter 1/2*sigma^2">sig2</a>*eye (size)); |
696 | | <a name="l00978"></a>00978 |
697 | | <a name="l00979"></a>00979 <a class="code" href="classbdm_1_1mpdf.html#a7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a> = size; |
698 | | <a name="l00980"></a>00980 }; |
699 | | <a name="l00981"></a>00981 |
700 | | <a name="l00982"></a><a class="code" href="classbdm_1_1mlognorm.html#a9106d8fd8bdf2b6be675ffd8f3ca584e">00982</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlognorm.html#a9106d8fd8bdf2b6be675ffd8f3ca584e" title="Update iepdf so that it represents this mpdf conditioned on rvc = cond This function...">condition</a> (<span class="keyword">const</span> vec &val) { |
701 | | <a name="l00983"></a>00983 <a class="code" href="classbdm_1_1mlognorm.html#a7d0063f77d899ef22e8c5edd642176d2" title="access">mu</a> = log (val) - <a class="code" href="classbdm_1_1mlognorm.html#aa51128a2e503b8b2ce698244b9e0db1a" title="parameter 1/2*sigma^2">sig2</a>;<span class="comment">//elem_mult ( refl,pow ( val,l ) );</span> |
702 | | <a name="l00984"></a>00984 }; |
703 | | <a name="l00985"></a>00985 |
704 | | <a name="l00997"></a>00997 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlognorm.html#a49e45ea13a869da607ef9be7a229128a">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>); |
705 | | <a name="l00998"></a>00998 |
706 | | <a name="l00999"></a>00999 <span class="comment">// TODO dodelat void to_setting( Setting &set ) const;</span> |
707 | | <a name="l01000"></a>01000 |
708 | | <a name="l01001"></a>01001 }; |
709 | | <a name="l01002"></a>01002 |
710 | | <a name="l01003"></a>01003 <a class="code" href="user__info_8h.html#a4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a> (mlognorm); |
711 | | <a name="l01004"></a>01004 SHAREDPTR (mlognorm); |
712 | | <a name="l01005"></a>01005 |
713 | | <a name="l01009"></a><a class="code" href="classbdm_1_1eWishartCh.html">01009</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1eWishartCh.html">eWishartCh</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> |
714 | | <a name="l01010"></a>01010 { |
715 | | <a name="l01011"></a>01011 <span class="keyword">protected</span>: |
716 | | <a name="l01013"></a><a class="code" href="classbdm_1_1eWishartCh.html#a1b42f9284a32f23b0b253a628cda7490">01013</a> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> <a class="code" href="classbdm_1_1eWishartCh.html#a1b42f9284a32f23b0b253a628cda7490" title="Upper-Triagle of Choleski decomposition of .">Y</a>; |
717 | | <a name="l01015"></a><a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f">01015</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f" title="dimension of matrix ">p</a>; |
718 | | <a name="l01017"></a><a class="code" href="classbdm_1_1eWishartCh.html#a1879a14d7d2bb05062523b189baa11c3">01017</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eWishartCh.html#a1879a14d7d2bb05062523b189baa11c3" title="degrees of freedom ">delta</a>; |
719 | | <a name="l01018"></a>01018 <span class="keyword">public</span>: |
720 | | <a name="l01020"></a><a class="code" href="classbdm_1_1eWishartCh.html#a183d961532ee97b7dc5ec81701aa59a0">01020</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eWishartCh.html#a183d961532ee97b7dc5ec81701aa59a0" title="Set internal structures.">set_parameters</a> (<span class="keyword">const</span> mat &Y0, <span class="keyword">const</span> <span class="keywordtype">double</span> delta0) {<a class="code" href="classbdm_1_1eWishartCh.html#a1b42f9284a32f23b0b253a628cda7490" title="Upper-Triagle of Choleski decomposition of .">Y</a> = <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> (Y0);<a class="code" href="classbdm_1_1eWishartCh.html#a1879a14d7d2bb05062523b189baa11c3" title="degrees of freedom ">delta</a> = delta0; <a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f" title="dimension of matrix ">p</a> = <a class="code" href="classbdm_1_1eWishartCh.html#a1b42f9284a32f23b0b253a628cda7490" title="Upper-Triagle of Choleski decomposition of .">Y</a>.<a class="code" href="classbdm_1_1sqmat.html#a73e639221343dcce76c3305524d67590" title="Reimplementing common functions of mat: rows().">rows</a>(); <a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = <a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f" title="dimension of matrix ">p</a> * <a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f" title="dimension of matrix ">p</a>; } |
721 | | <a name="l01022"></a><a class="code" href="classbdm_1_1eWishartCh.html#acc664035d70d2622bf264a29270f8339">01022</a> mat <a class="code" href="classbdm_1_1eWishartCh.html#acc664035d70d2622bf264a29270f8339" title="Sample matrix argument.">sample_mat</a>()<span class="keyword"> const </span>{ |
722 | | <a name="l01023"></a>01023 mat X = zeros (<a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f" title="dimension of matrix ">p</a>, <a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f" title="dimension of matrix ">p</a>); |
723 | | <a name="l01024"></a>01024 |
724 | | <a name="l01025"></a>01025 <span class="comment">//sample diagonal</span> |
725 | | <a name="l01026"></a>01026 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0;i < <a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f" title="dimension of matrix ">p</a>;i++) { |
726 | | <a name="l01027"></a>01027 GamRNG.setup (0.5* (<a class="code" href="classbdm_1_1eWishartCh.html#a1879a14d7d2bb05062523b189baa11c3" title="degrees of freedom ">delta</a> - i) , 0.5); <span class="comment">// no +1 !! index if from 0</span> |
727 | | <a name="l01028"></a>01028 <span class="preprocessor">#pragma omp critical</span> |
728 | | <a name="l01029"></a>01029 <span class="preprocessor"></span> X (i, i) = sqrt (GamRNG()); |
729 | | <a name="l01030"></a>01030 } |
730 | | <a name="l01031"></a>01031 <span class="comment">//do the rest</span> |
731 | | <a name="l01032"></a>01032 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0;i < p;i++) { |
732 | | <a name="l01033"></a>01033 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = i + 1;j < p;j++) { |
733 | | <a name="l01034"></a>01034 <span class="preprocessor">#pragma omp critical</span> |
734 | | <a name="l01035"></a>01035 <span class="preprocessor"></span> X (i, j) = NorRNG.sample(); |
735 | | <a name="l01036"></a>01036 } |
736 | | <a name="l01037"></a>01037 } |
737 | | <a name="l01038"></a>01038 <span class="keywordflow">return</span> X*<a class="code" href="classbdm_1_1eWishartCh.html#a1b42f9284a32f23b0b253a628cda7490" title="Upper-Triagle of Choleski decomposition of .">Y</a>.<a class="code" href="classbdm_1_1chmat.html#a17daa8c5c5914bd3194cb3053c5793a5" title="Access function.">_Ch</a>();<span class="comment">// return upper triangular part of the decomposition</span> |
738 | | <a name="l01039"></a>01039 } |
739 | | <a name="l01040"></a><a class="code" href="classbdm_1_1eWishartCh.html#a8f2154b8b5be8f4c5788f261b6d57b9a">01040</a> vec <a class="code" href="classbdm_1_1eWishartCh.html#a8f2154b8b5be8f4c5788f261b6d57b9a" title="Returns a sample, from density .">sample</a> ()<span class="keyword"> const </span>{ |
740 | | <a name="l01041"></a>01041 <span class="keywordflow">return</span> vec (<a class="code" href="classbdm_1_1eWishartCh.html#acc664035d70d2622bf264a29270f8339" title="Sample matrix argument.">sample_mat</a>()._data(), <a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f" title="dimension of matrix ">p</a>*<a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f" title="dimension of matrix ">p</a>); |
741 | | <a name="l01042"></a>01042 } |
742 | | <a name="l01044"></a><a class="code" href="classbdm_1_1eWishartCh.html#a4eee757c0535c2a88bb20f0767c64981">01044</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eWishartCh.html#a4eee757c0535c2a88bb20f0767c64981" title="fast access function y0 will be copied into Y.Ch.">setY</a> (<span class="keyword">const</span> mat &Ch0) {copy_vector (<a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>, Ch0._data(), <a class="code" href="classbdm_1_1eWishartCh.html#a1b42f9284a32f23b0b253a628cda7490" title="Upper-Triagle of Choleski decomposition of .">Y</a>.<a class="code" href="classbdm_1_1chmat.html#a17daa8c5c5914bd3194cb3053c5793a5" title="Access function.">_Ch</a>()._data());} |
743 | | <a name="l01046"></a><a class="code" href="classbdm_1_1eWishartCh.html#a7eac414ec10b85aa5536b0092c57bc4a">01046</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eWishartCh.html#a7eac414ec10b85aa5536b0092c57bc4a" title="fast access function y0 will be copied into Y.Ch.">_setY</a> (<span class="keyword">const</span> vec &ch0) {copy_vector (<a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>, ch0._data(), <a class="code" href="classbdm_1_1eWishartCh.html#a1b42f9284a32f23b0b253a628cda7490" title="Upper-Triagle of Choleski decomposition of .">Y</a>.<a class="code" href="classbdm_1_1chmat.html#a17daa8c5c5914bd3194cb3053c5793a5" title="Access function.">_Ch</a>()._data()); } |
744 | | <a name="l01048"></a><a class="code" href="classbdm_1_1eWishartCh.html#a1708cacb5d8cb1b96395d35f5327cb7e">01048</a> <span class="keyword">const</span> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>& <a class="code" href="classbdm_1_1eWishartCh.html#a1708cacb5d8cb1b96395d35f5327cb7e" title="access function">getY</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eWishartCh.html#a1b42f9284a32f23b0b253a628cda7490" title="Upper-Triagle of Choleski decomposition of .">Y</a>;} |
745 | | <a name="l01049"></a>01049 }; |
746 | | <a name="l01050"></a>01050 |
747 | | <a name="l01052"></a>01052 |
748 | | <a name="l01054"></a><a class="code" href="classbdm_1_1eiWishartCh.html">01054</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1eiWishartCh.html" title="Inverse Wishart on Choleski decomposition.">eiWishartCh</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> |
749 | | <a name="l01055"></a>01055 { |
750 | | <a name="l01056"></a>01056 <span class="keyword">protected</span>: |
751 | | <a name="l01058"></a><a class="code" href="classbdm_1_1eiWishartCh.html#ac6b684b52dc62b8d46e67d5992f98b9a">01058</a> <a class="code" href="classbdm_1_1eWishartCh.html">eWishartCh</a> <a class="code" href="classbdm_1_1eiWishartCh.html#ac6b684b52dc62b8d46e67d5992f98b9a" title="Internal instance of Wishart density.">W</a>; |
752 | | <a name="l01060"></a><a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd">01060</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd" title="size of Ch">p</a>; |
753 | | <a name="l01062"></a><a class="code" href="classbdm_1_1eiWishartCh.html#aca3035f7bd5e4597cc1843cf07af8464">01062</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eiWishartCh.html#aca3035f7bd5e4597cc1843cf07af8464" title="parameter delta">delta</a>; |
754 | | <a name="l01063"></a>01063 <span class="keyword">public</span>: |
755 | | <a name="l01065"></a><a class="code" href="classbdm_1_1eiWishartCh.html#af463caed9d22d9949f3ee67614e7dcd3">01065</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eiWishartCh.html#af463caed9d22d9949f3ee67614e7dcd3" title="constructor function">set_parameters</a> (<span class="keyword">const</span> mat &Y0, <span class="keyword">const</span> <span class="keywordtype">double</span> delta0) { |
756 | | <a name="l01066"></a>01066 <a class="code" href="classbdm_1_1eiWishartCh.html#aca3035f7bd5e4597cc1843cf07af8464" title="parameter delta">delta</a> = delta0; |
757 | | <a name="l01067"></a>01067 <a class="code" href="classbdm_1_1eiWishartCh.html#ac6b684b52dc62b8d46e67d5992f98b9a" title="Internal instance of Wishart density.">W</a>.<a class="code" href="classbdm_1_1eWishartCh.html#a183d961532ee97b7dc5ec81701aa59a0" title="Set internal structures.">set_parameters</a> (inv (Y0), delta0); |
758 | | <a name="l01068"></a>01068 <a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = <a class="code" href="classbdm_1_1eiWishartCh.html#ac6b684b52dc62b8d46e67d5992f98b9a" title="Internal instance of Wishart density.">W</a>.<a class="code" href="classbdm_1_1epdf.html#a7083a65f7b7a0d0d13b2c516bd2ec29c" title="Size of the random variable.">dimension</a>(); <a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd" title="size of Ch">p</a> = Y0.rows(); |
759 | | <a name="l01069"></a>01069 } |
760 | | <a name="l01070"></a><a class="code" href="classbdm_1_1eiWishartCh.html#a2f668192cc9c2e3a5b7e608164685a3e">01070</a> vec <a class="code" href="classbdm_1_1eiWishartCh.html#a2f668192cc9c2e3a5b7e608164685a3e" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{mat iCh; iCh = inv (<a class="code" href="classbdm_1_1eiWishartCh.html#ac6b684b52dc62b8d46e67d5992f98b9a" title="Internal instance of Wishart density.">W</a>.<a class="code" href="classbdm_1_1eWishartCh.html#acc664035d70d2622bf264a29270f8339" title="Sample matrix argument.">sample_mat</a>()); <span class="keywordflow">return</span> vec (iCh._data(), <a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>);} |
761 | | <a name="l01072"></a><a class="code" href="classbdm_1_1eiWishartCh.html#ad9947933dfc94546cbd6a81f95ec5af5">01072</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eiWishartCh.html#ad9947933dfc94546cbd6a81f95ec5af5" title="access function">_setY</a> (<span class="keyword">const</span> vec &y0) { |
762 | | <a name="l01073"></a>01073 mat Ch (<a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd" title="size of Ch">p</a>, <a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd" title="size of Ch">p</a>); |
763 | | <a name="l01074"></a>01074 mat iCh (<a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd" title="size of Ch">p</a>, <a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd" title="size of Ch">p</a>); |
764 | | <a name="l01075"></a>01075 copy_vector (<a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>, y0._data(), Ch._data()); |
765 | | <a name="l01076"></a>01076 |
766 | | <a name="l01077"></a>01077 iCh = inv (Ch); |
767 | | <a name="l01078"></a>01078 <a class="code" href="classbdm_1_1eiWishartCh.html#ac6b684b52dc62b8d46e67d5992f98b9a" title="Internal instance of Wishart density.">W</a>.<a class="code" href="classbdm_1_1eWishartCh.html#a4eee757c0535c2a88bb20f0767c64981" title="fast access function y0 will be copied into Y.Ch.">setY</a> (iCh); |
768 | | <a name="l01079"></a>01079 } |
769 | | <a name="l01080"></a><a class="code" href="classbdm_1_1eiWishartCh.html#aa6ddbd815b8b666dd542e97f009f89bb">01080</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eiWishartCh.html#aa6ddbd815b8b666dd542e97f009f89bb" title="Compute log-probability of argument val In case the argument is out of suport return...">evallog</a> (<span class="keyword">const</span> vec &val)<span class="keyword"> const </span>{ |
770 | | <a name="l01081"></a>01081 <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> X (<a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd" title="size of Ch">p</a>); |
771 | | <a name="l01082"></a>01082 <span class="keyword">const</span> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>& Y = <a class="code" href="classbdm_1_1eiWishartCh.html#ac6b684b52dc62b8d46e67d5992f98b9a" title="Internal instance of Wishart density.">W</a>.<a class="code" href="classbdm_1_1eWishartCh.html#a1708cacb5d8cb1b96395d35f5327cb7e" title="access function">getY</a>(); |
772 | | <a name="l01083"></a>01083 |
773 | | <a name="l01084"></a>01084 copy_vector (<a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd" title="size of Ch">p</a>*<a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd" title="size of Ch">p</a>, val._data(), X.<a class="code" href="classbdm_1_1chmat.html#a17daa8c5c5914bd3194cb3053c5793a5" title="Access function.">_Ch</a>()._data()); |
774 | | <a name="l01085"></a>01085 <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> iX (p);X.<a class="code" href="classbdm_1_1chmat.html#acbf3389db96dff41fb2e9532d59b13c0" title="Inversion in the same form, i.e. cholesky.">inv</a> (iX); |
775 | | <a name="l01086"></a>01086 <span class="comment">// compute</span> |
776 | | <a name="l01087"></a>01087 <span class="comment">// \frac{ |\Psi|^{m/2}|X|^{-(m+p+1)/2}e^{-tr(\Psi X^{-1})/2} }{ 2^{mp/2}\Gamma_p(m/2)},</span> |
777 | | <a name="l01088"></a>01088 mat M = Y.<a class="code" href="classbdm_1_1chmat.html#a4b4c5d4dbb8a3d585b68d936cb6df31b" title="Conversion to full matrix.">to_mat</a>() * iX.to_mat(); |
778 | | <a name="l01089"></a>01089 |
779 | | <a name="l01090"></a>01090 <span class="keywordtype">double</span> log1 = 0.5 * p * (2 * Y.<a class="code" href="classbdm_1_1chmat.html#a949ccd174ed19f9cfe36366cbd5c56a4" title="Logarithm of a determinant.">logdet</a>()) - 0.5 * (<a class="code" href="classbdm_1_1eiWishartCh.html#aca3035f7bd5e4597cc1843cf07af8464" title="parameter delta">delta</a> + p + 1) * (2 * X.<a class="code" href="classbdm_1_1chmat.html#a949ccd174ed19f9cfe36366cbd5c56a4" title="Logarithm of a determinant.">logdet</a>()) - 0.5 * trace (M); |
780 | | <a name="l01091"></a>01091 <span class="comment">//Fixme! Multivariate gamma omitted!! it is ok for sampling, but not otherwise!!</span> |
| 692 | <a name="l00985"></a>00985 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlognorm.html#a49e45ea13a869da607ef9be7a229128a">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>); |
| 693 | <a name="l00986"></a>00986 |
| 694 | <a name="l00987"></a>00987 <span class="comment">// TODO dodelat void to_setting( Setting &set ) const;</span> |
| 695 | <a name="l00988"></a>00988 |
| 696 | <a name="l00989"></a>00989 }; |
| 697 | <a name="l00990"></a>00990 |
| 698 | <a name="l00991"></a>00991 <a class="code" href="user__info_8h.html#a4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a> (mlognorm); |
| 699 | <a name="l00992"></a>00992 SHAREDPTR (mlognorm); |
| 700 | <a name="l00993"></a>00993 |
| 701 | <a name="l00997"></a><a class="code" href="classbdm_1_1eWishartCh.html">00997</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1eWishartCh.html">eWishartCh</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> |
| 702 | <a name="l00998"></a>00998 { |
| 703 | <a name="l00999"></a>00999 <span class="keyword">protected</span>: |
| 704 | <a name="l01001"></a><a class="code" href="classbdm_1_1eWishartCh.html#a1b42f9284a32f23b0b253a628cda7490">01001</a> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> <a class="code" href="classbdm_1_1eWishartCh.html#a1b42f9284a32f23b0b253a628cda7490" title="Upper-Triagle of Choleski decomposition of .">Y</a>; |
| 705 | <a name="l01003"></a><a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f">01003</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f" title="dimension of matrix ">p</a>; |
| 706 | <a name="l01005"></a><a class="code" href="classbdm_1_1eWishartCh.html#a1879a14d7d2bb05062523b189baa11c3">01005</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eWishartCh.html#a1879a14d7d2bb05062523b189baa11c3" title="degrees of freedom ">delta</a>; |
| 707 | <a name="l01006"></a>01006 <span class="keyword">public</span>: |
| 708 | <a name="l01008"></a><a class="code" href="classbdm_1_1eWishartCh.html#a183d961532ee97b7dc5ec81701aa59a0">01008</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eWishartCh.html#a183d961532ee97b7dc5ec81701aa59a0" title="Set internal structures.">set_parameters</a> (<span class="keyword">const</span> mat &Y0, <span class="keyword">const</span> <span class="keywordtype">double</span> delta0) {<a class="code" href="classbdm_1_1eWishartCh.html#a1b42f9284a32f23b0b253a628cda7490" title="Upper-Triagle of Choleski decomposition of .">Y</a> = <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> (Y0);<a class="code" href="classbdm_1_1eWishartCh.html#a1879a14d7d2bb05062523b189baa11c3" title="degrees of freedom ">delta</a> = delta0; <a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f" title="dimension of matrix ">p</a> = <a class="code" href="classbdm_1_1eWishartCh.html#a1b42f9284a32f23b0b253a628cda7490" title="Upper-Triagle of Choleski decomposition of .">Y</a>.<a class="code" href="classbdm_1_1sqmat.html#a73e639221343dcce76c3305524d67590" title="Reimplementing common functions of mat: rows().">rows</a>(); <a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = <a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f" title="dimension of matrix ">p</a> * <a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f" title="dimension of matrix ">p</a>; } |
| 709 | <a name="l01010"></a><a class="code" href="classbdm_1_1eWishartCh.html#acc664035d70d2622bf264a29270f8339">01010</a> mat <a class="code" href="classbdm_1_1eWishartCh.html#acc664035d70d2622bf264a29270f8339" title="Sample matrix argument.">sample_mat</a>()<span class="keyword"> const </span>{ |
| 710 | <a name="l01011"></a>01011 mat X = zeros (<a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f" title="dimension of matrix ">p</a>, <a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f" title="dimension of matrix ">p</a>); |
| 711 | <a name="l01012"></a>01012 |
| 712 | <a name="l01013"></a>01013 <span class="comment">//sample diagonal</span> |
| 713 | <a name="l01014"></a>01014 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0;i < <a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f" title="dimension of matrix ">p</a>;i++) { |
| 714 | <a name="l01015"></a>01015 GamRNG.setup (0.5* (<a class="code" href="classbdm_1_1eWishartCh.html#a1879a14d7d2bb05062523b189baa11c3" title="degrees of freedom ">delta</a> - i) , 0.5); <span class="comment">// no +1 !! index if from 0</span> |
| 715 | <a name="l01016"></a>01016 <span class="preprocessor">#pragma omp critical</span> |
| 716 | <a name="l01017"></a>01017 <span class="preprocessor"></span> X (i, i) = sqrt (GamRNG()); |
| 717 | <a name="l01018"></a>01018 } |
| 718 | <a name="l01019"></a>01019 <span class="comment">//do the rest</span> |
| 719 | <a name="l01020"></a>01020 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0;i < p;i++) { |
| 720 | <a name="l01021"></a>01021 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j = i + 1;j < p;j++) { |
| 721 | <a name="l01022"></a>01022 <span class="preprocessor">#pragma omp critical</span> |
| 722 | <a name="l01023"></a>01023 <span class="preprocessor"></span> X (i, j) = NorRNG.sample(); |
| 723 | <a name="l01024"></a>01024 } |
| 724 | <a name="l01025"></a>01025 } |
| 725 | <a name="l01026"></a>01026 <span class="keywordflow">return</span> X*<a class="code" href="classbdm_1_1eWishartCh.html#a1b42f9284a32f23b0b253a628cda7490" title="Upper-Triagle of Choleski decomposition of .">Y</a>.<a class="code" href="classbdm_1_1chmat.html#a17daa8c5c5914bd3194cb3053c5793a5" title="Access function.">_Ch</a>();<span class="comment">// return upper triangular part of the decomposition</span> |
| 726 | <a name="l01027"></a>01027 } |
| 727 | <a name="l01028"></a><a class="code" href="classbdm_1_1eWishartCh.html#a8f2154b8b5be8f4c5788f261b6d57b9a">01028</a> vec <a class="code" href="classbdm_1_1eWishartCh.html#a8f2154b8b5be8f4c5788f261b6d57b9a" title="Returns a sample, from density .">sample</a> ()<span class="keyword"> const </span>{ |
| 728 | <a name="l01029"></a>01029 <span class="keywordflow">return</span> vec (<a class="code" href="classbdm_1_1eWishartCh.html#acc664035d70d2622bf264a29270f8339" title="Sample matrix argument.">sample_mat</a>()._data(), <a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f" title="dimension of matrix ">p</a>*<a class="code" href="classbdm_1_1eWishartCh.html#ab745c73faef785009484180582050a1f" title="dimension of matrix ">p</a>); |
| 729 | <a name="l01030"></a>01030 } |
| 730 | <a name="l01032"></a><a class="code" href="classbdm_1_1eWishartCh.html#a4eee757c0535c2a88bb20f0767c64981">01032</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eWishartCh.html#a4eee757c0535c2a88bb20f0767c64981" title="fast access function y0 will be copied into Y.Ch.">setY</a> (<span class="keyword">const</span> mat &Ch0) {copy_vector (<a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>, Ch0._data(), <a class="code" href="classbdm_1_1eWishartCh.html#a1b42f9284a32f23b0b253a628cda7490" title="Upper-Triagle of Choleski decomposition of .">Y</a>.<a class="code" href="classbdm_1_1chmat.html#a17daa8c5c5914bd3194cb3053c5793a5" title="Access function.">_Ch</a>()._data());} |
| 731 | <a name="l01034"></a><a class="code" href="classbdm_1_1eWishartCh.html#a7eac414ec10b85aa5536b0092c57bc4a">01034</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eWishartCh.html#a7eac414ec10b85aa5536b0092c57bc4a" title="fast access function y0 will be copied into Y.Ch.">_setY</a> (<span class="keyword">const</span> vec &ch0) {copy_vector (<a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>, ch0._data(), <a class="code" href="classbdm_1_1eWishartCh.html#a1b42f9284a32f23b0b253a628cda7490" title="Upper-Triagle of Choleski decomposition of .">Y</a>.<a class="code" href="classbdm_1_1chmat.html#a17daa8c5c5914bd3194cb3053c5793a5" title="Access function.">_Ch</a>()._data()); } |
| 732 | <a name="l01036"></a><a class="code" href="classbdm_1_1eWishartCh.html#a1708cacb5d8cb1b96395d35f5327cb7e">01036</a> <span class="keyword">const</span> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>& <a class="code" href="classbdm_1_1eWishartCh.html#a1708cacb5d8cb1b96395d35f5327cb7e" title="access function">getY</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eWishartCh.html#a1b42f9284a32f23b0b253a628cda7490" title="Upper-Triagle of Choleski decomposition of .">Y</a>;} |
| 733 | <a name="l01037"></a>01037 }; |
| 734 | <a name="l01038"></a>01038 |
| 735 | <a name="l01040"></a>01040 |
| 736 | <a name="l01042"></a><a class="code" href="classbdm_1_1eiWishartCh.html">01042</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1eiWishartCh.html" title="Inverse Wishart on Choleski decomposition.">eiWishartCh</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> |
| 737 | <a name="l01043"></a>01043 { |
| 738 | <a name="l01044"></a>01044 <span class="keyword">protected</span>: |
| 739 | <a name="l01046"></a><a class="code" href="classbdm_1_1eiWishartCh.html#ac6b684b52dc62b8d46e67d5992f98b9a">01046</a> <a class="code" href="classbdm_1_1eWishartCh.html">eWishartCh</a> <a class="code" href="classbdm_1_1eiWishartCh.html#ac6b684b52dc62b8d46e67d5992f98b9a" title="Internal instance of Wishart density.">W</a>; |
| 740 | <a name="l01048"></a><a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd">01048</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd" title="size of Ch">p</a>; |
| 741 | <a name="l01050"></a><a class="code" href="classbdm_1_1eiWishartCh.html#aca3035f7bd5e4597cc1843cf07af8464">01050</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eiWishartCh.html#aca3035f7bd5e4597cc1843cf07af8464" title="parameter delta">delta</a>; |
| 742 | <a name="l01051"></a>01051 <span class="keyword">public</span>: |
| 743 | <a name="l01053"></a><a class="code" href="classbdm_1_1eiWishartCh.html#af463caed9d22d9949f3ee67614e7dcd3">01053</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eiWishartCh.html#af463caed9d22d9949f3ee67614e7dcd3" title="constructor function">set_parameters</a> (<span class="keyword">const</span> mat &Y0, <span class="keyword">const</span> <span class="keywordtype">double</span> delta0) { |
| 744 | <a name="l01054"></a>01054 <a class="code" href="classbdm_1_1eiWishartCh.html#aca3035f7bd5e4597cc1843cf07af8464" title="parameter delta">delta</a> = delta0; |
| 745 | <a name="l01055"></a>01055 <a class="code" href="classbdm_1_1eiWishartCh.html#ac6b684b52dc62b8d46e67d5992f98b9a" title="Internal instance of Wishart density.">W</a>.<a class="code" href="classbdm_1_1eWishartCh.html#a183d961532ee97b7dc5ec81701aa59a0" title="Set internal structures.">set_parameters</a> (inv (Y0), delta0); |
| 746 | <a name="l01056"></a>01056 <a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = <a class="code" href="classbdm_1_1eiWishartCh.html#ac6b684b52dc62b8d46e67d5992f98b9a" title="Internal instance of Wishart density.">W</a>.<a class="code" href="classbdm_1_1epdf.html#a7083a65f7b7a0d0d13b2c516bd2ec29c" title="Size of the random variable.">dimension</a>(); <a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd" title="size of Ch">p</a> = Y0.rows(); |
| 747 | <a name="l01057"></a>01057 } |
| 748 | <a name="l01058"></a><a class="code" href="classbdm_1_1eiWishartCh.html#a2f668192cc9c2e3a5b7e608164685a3e">01058</a> vec <a class="code" href="classbdm_1_1eiWishartCh.html#a2f668192cc9c2e3a5b7e608164685a3e" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{mat iCh; iCh = inv (<a class="code" href="classbdm_1_1eiWishartCh.html#ac6b684b52dc62b8d46e67d5992f98b9a" title="Internal instance of Wishart density.">W</a>.<a class="code" href="classbdm_1_1eWishartCh.html#acc664035d70d2622bf264a29270f8339" title="Sample matrix argument.">sample_mat</a>()); <span class="keywordflow">return</span> vec (iCh._data(), <a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>);} |
| 749 | <a name="l01060"></a><a class="code" href="classbdm_1_1eiWishartCh.html#ad9947933dfc94546cbd6a81f95ec5af5">01060</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eiWishartCh.html#ad9947933dfc94546cbd6a81f95ec5af5" title="access function">_setY</a> (<span class="keyword">const</span> vec &y0) { |
| 750 | <a name="l01061"></a>01061 mat Ch (<a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd" title="size of Ch">p</a>, <a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd" title="size of Ch">p</a>); |
| 751 | <a name="l01062"></a>01062 mat iCh (<a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd" title="size of Ch">p</a>, <a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd" title="size of Ch">p</a>); |
| 752 | <a name="l01063"></a>01063 copy_vector (<a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>, y0._data(), Ch._data()); |
| 753 | <a name="l01064"></a>01064 |
| 754 | <a name="l01065"></a>01065 iCh = inv (Ch); |
| 755 | <a name="l01066"></a>01066 <a class="code" href="classbdm_1_1eiWishartCh.html#ac6b684b52dc62b8d46e67d5992f98b9a" title="Internal instance of Wishart density.">W</a>.<a class="code" href="classbdm_1_1eWishartCh.html#a4eee757c0535c2a88bb20f0767c64981" title="fast access function y0 will be copied into Y.Ch.">setY</a> (iCh); |
| 756 | <a name="l01067"></a>01067 } |
| 757 | <a name="l01068"></a><a class="code" href="classbdm_1_1eiWishartCh.html#aa6ddbd815b8b666dd542e97f009f89bb">01068</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eiWishartCh.html#aa6ddbd815b8b666dd542e97f009f89bb" title="Compute log-probability of argument val In case the argument is out of suport return...">evallog</a> (<span class="keyword">const</span> vec &val)<span class="keyword"> const </span>{ |
| 758 | <a name="l01069"></a>01069 <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> X (<a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd" title="size of Ch">p</a>); |
| 759 | <a name="l01070"></a>01070 <span class="keyword">const</span> <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a>& Y = <a class="code" href="classbdm_1_1eiWishartCh.html#ac6b684b52dc62b8d46e67d5992f98b9a" title="Internal instance of Wishart density.">W</a>.<a class="code" href="classbdm_1_1eWishartCh.html#a1708cacb5d8cb1b96395d35f5327cb7e" title="access function">getY</a>(); |
| 760 | <a name="l01071"></a>01071 |
| 761 | <a name="l01072"></a>01072 copy_vector (<a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd" title="size of Ch">p</a>*<a class="code" href="classbdm_1_1eiWishartCh.html#ac11f1c41183f743b97fbb73a4e9ba6cd" title="size of Ch">p</a>, val._data(), X.<a class="code" href="classbdm_1_1chmat.html#a17daa8c5c5914bd3194cb3053c5793a5" title="Access function.">_Ch</a>()._data()); |
| 762 | <a name="l01073"></a>01073 <a class="code" href="classbdm_1_1chmat.html" title="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</a> iX (p);X.<a class="code" href="classbdm_1_1chmat.html#acbf3389db96dff41fb2e9532d59b13c0" title="Inversion in the same form, i.e. cholesky.">inv</a> (iX); |
| 763 | <a name="l01074"></a>01074 <span class="comment">// compute</span> |
| 764 | <a name="l01075"></a>01075 <span class="comment">// \frac{ |\Psi|^{m/2}|X|^{-(m+p+1)/2}e^{-tr(\Psi X^{-1})/2} }{ 2^{mp/2}\Gamma_p(m/2)},</span> |
| 765 | <a name="l01076"></a>01076 mat M = Y.<a class="code" href="classbdm_1_1chmat.html#a4b4c5d4dbb8a3d585b68d936cb6df31b" title="Conversion to full matrix.">to_mat</a>() * iX.to_mat(); |
| 766 | <a name="l01077"></a>01077 |
| 767 | <a name="l01078"></a>01078 <span class="keywordtype">double</span> log1 = 0.5 * p * (2 * Y.<a class="code" href="classbdm_1_1chmat.html#a949ccd174ed19f9cfe36366cbd5c56a4" title="Logarithm of a determinant.">logdet</a>()) - 0.5 * (<a class="code" href="classbdm_1_1eiWishartCh.html#aca3035f7bd5e4597cc1843cf07af8464" title="parameter delta">delta</a> + p + 1) * (2 * X.<a class="code" href="classbdm_1_1chmat.html#a949ccd174ed19f9cfe36366cbd5c56a4" title="Logarithm of a determinant.">logdet</a>()) - 0.5 * trace (M); |
| 768 | <a name="l01079"></a>01079 <span class="comment">//Fixme! Multivariate gamma omitted!! it is ok for sampling, but not otherwise!!</span> |
| 769 | <a name="l01080"></a>01080 |
| 770 | <a name="l01081"></a>01081 <span class="comment">/* if (0) {</span> |
| 771 | <a name="l01082"></a>01082 <span class="comment"> mat XX=X.to_mat();</span> |
| 772 | <a name="l01083"></a>01083 <span class="comment"> mat YY=Y.to_mat();</span> |
| 773 | <a name="l01084"></a>01084 <span class="comment"></span> |
| 774 | <a name="l01085"></a>01085 <span class="comment"> double log2 = 0.5*p*log(det(YY))-0.5*(delta+p+1)*log(det(XX))-0.5*trace(YY*inv(XX));</span> |
| 775 | <a name="l01086"></a>01086 <span class="comment"> cout << log1 << "," << log2 << endl;</span> |
| 776 | <a name="l01087"></a>01087 <span class="comment"> }*/</span> |
| 777 | <a name="l01088"></a>01088 <span class="keywordflow">return</span> log1; |
| 778 | <a name="l01089"></a>01089 }; |
| 779 | <a name="l01090"></a>01090 |
| 780 | <a name="l01091"></a>01091 }; |
782 | | <a name="l01093"></a>01093 <span class="comment">/* if (0) {</span> |
783 | | <a name="l01094"></a>01094 <span class="comment"> mat XX=X.to_mat();</span> |
784 | | <a name="l01095"></a>01095 <span class="comment"> mat YY=Y.to_mat();</span> |
785 | | <a name="l01096"></a>01096 <span class="comment"></span> |
786 | | <a name="l01097"></a>01097 <span class="comment"> double log2 = 0.5*p*log(det(YY))-0.5*(delta+p+1)*log(det(XX))-0.5*trace(YY*inv(XX));</span> |
787 | | <a name="l01098"></a>01098 <span class="comment"> cout << log1 << "," << log2 << endl;</span> |
788 | | <a name="l01099"></a>01099 <span class="comment"> }*/</span> |
789 | | <a name="l01100"></a>01100 <span class="keywordflow">return</span> log1; |
790 | | <a name="l01101"></a>01101 }; |
791 | | <a name="l01102"></a>01102 |
792 | | <a name="l01103"></a>01103 }; |
793 | | <a name="l01104"></a>01104 |
794 | | <a name="l01106"></a><a class="code" href="classbdm_1_1rwiWishartCh.html">01106</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1rwiWishartCh.html" title="Random Walk on inverse Wishart.">rwiWishartCh</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mpdf__internal.html" title="Mpdf with internal epdf that is modified by function condition.">mpdf_internal</a><eiWishartCh> |
795 | | <a name="l01107"></a>01107 { |
796 | | <a name="l01108"></a>01108 <span class="keyword">protected</span>: |
797 | | <a name="l01110"></a><a class="code" href="classbdm_1_1rwiWishartCh.html#a2004675b37f712abe3913057bae97cfb">01110</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1rwiWishartCh.html#a2004675b37f712abe3913057bae97cfb" title="square root of - needed for computation of from conditions">sqd</a>; |
798 | | <a name="l01112"></a><a class="code" href="classbdm_1_1rwiWishartCh.html#a239b26c71ebcc118ba6925dfb6efc50a">01112</a> vec <a class="code" href="classbdm_1_1rwiWishartCh.html#a239b26c71ebcc118ba6925dfb6efc50a" title="reference point for diagonal">refl</a>; |
799 | | <a name="l01114"></a><a class="code" href="classbdm_1_1rwiWishartCh.html#a758cd05efa67c60b4bf4f7554b9ba861">01114</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1rwiWishartCh.html#a758cd05efa67c60b4bf4f7554b9ba861" title="power of the reference">l</a>; |
800 | | <a name="l01116"></a><a class="code" href="classbdm_1_1rwiWishartCh.html#a7ba06d431995c347d2fce30a59c20663">01116</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1rwiWishartCh.html#a7ba06d431995c347d2fce30a59c20663" title="dimension">p</a>; |
801 | | <a name="l01117"></a>01117 |
802 | | <a name="l01118"></a>01118 <span class="keyword">public</span>: |
803 | | <a name="l01119"></a>01119 <a class="code" href="classbdm_1_1rwiWishartCh.html" title="Random Walk on inverse Wishart.">rwiWishartCh</a>() : <a class="code" href="classbdm_1_1rwiWishartCh.html#a2004675b37f712abe3913057bae97cfb" title="square root of - needed for computation of from conditions">sqd</a> (0), <a class="code" href="classbdm_1_1rwiWishartCh.html#a758cd05efa67c60b4bf4f7554b9ba861" title="power of the reference">l</a> (0), <a class="code" href="classbdm_1_1rwiWishartCh.html#a7ba06d431995c347d2fce30a59c20663" title="dimension">p</a> (0) {} |
804 | | <a name="l01121"></a><a class="code" href="classbdm_1_1rwiWishartCh.html#a28549ee3ce1ff8509360171ea3cf717c">01121</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1rwiWishartCh.html#a28549ee3ce1ff8509360171ea3cf717c" title="constructor function">set_parameters</a> (<span class="keywordtype">int</span> p0, <span class="keywordtype">double</span> k, vec ref0, <span class="keywordtype">double</span> l0) { |
805 | | <a name="l01122"></a>01122 <a class="code" href="classbdm_1_1rwiWishartCh.html#a7ba06d431995c347d2fce30a59c20663" title="dimension">p</a> = p0; |
806 | | <a name="l01123"></a>01123 <span class="keywordtype">double</span> delta = 2 / (k * k) + <a class="code" href="classbdm_1_1rwiWishartCh.html#a7ba06d431995c347d2fce30a59c20663" title="dimension">p</a> + 3; |
807 | | <a name="l01124"></a>01124 <a class="code" href="classbdm_1_1rwiWishartCh.html#a2004675b37f712abe3913057bae97cfb" title="square root of - needed for computation of from conditions">sqd</a> = sqrt (delta - <a class="code" href="classbdm_1_1rwiWishartCh.html#a7ba06d431995c347d2fce30a59c20663" title="dimension">p</a> - 1); |
808 | | <a name="l01125"></a>01125 <a class="code" href="classbdm_1_1rwiWishartCh.html#a758cd05efa67c60b4bf4f7554b9ba861" title="power of the reference">l</a> = l0; |
809 | | <a name="l01126"></a>01126 <a class="code" href="classbdm_1_1rwiWishartCh.html#a239b26c71ebcc118ba6925dfb6efc50a" title="reference point for diagonal">refl</a> = pow (ref0, 1 - <a class="code" href="classbdm_1_1rwiWishartCh.html#a758cd05efa67c60b4bf4f7554b9ba861" title="power of the reference">l</a>); |
810 | | <a name="l01127"></a>01127 |
811 | | <a name="l01128"></a>01128 <a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.<a class="code" href="classbdm_1_1eiWishartCh.html#af463caed9d22d9949f3ee67614e7dcd3" title="constructor function">set_parameters</a> (eye (<a class="code" href="classbdm_1_1rwiWishartCh.html#a7ba06d431995c347d2fce30a59c20663" title="dimension">p</a>), delta); |
812 | | <a name="l01129"></a>01129 <a class="code" href="classbdm_1_1mpdf.html#a7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a> = <a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.<a class="code" href="classbdm_1_1epdf.html#a7083a65f7b7a0d0d13b2c516bd2ec29c" title="Size of the random variable.">dimension</a>(); |
813 | | <a name="l01130"></a>01130 } |
814 | | <a name="l01131"></a><a class="code" href="classbdm_1_1rwiWishartCh.html#aac087ba6c885d3faeda9171229f9b4e6">01131</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1rwiWishartCh.html#aac087ba6c885d3faeda9171229f9b4e6" title="Update iepdf so that it represents this mpdf conditioned on rvc = cond This function...">condition</a> (<span class="keyword">const</span> vec &c) { |
815 | | <a name="l01132"></a>01132 vec z = c; |
816 | | <a name="l01133"></a>01133 <span class="keywordtype">int</span> ri = 0; |
817 | | <a name="l01134"></a>01134 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0;i < <a class="code" href="classbdm_1_1rwiWishartCh.html#a7ba06d431995c347d2fce30a59c20663" title="dimension">p</a>*<a class="code" href="classbdm_1_1rwiWishartCh.html#a7ba06d431995c347d2fce30a59c20663" title="dimension">p</a>;i += (p + 1)) {<span class="comment">//trace diagonal element</span> |
818 | | <a name="l01135"></a>01135 z (i) = pow (z (i), <a class="code" href="classbdm_1_1rwiWishartCh.html#a758cd05efa67c60b4bf4f7554b9ba861" title="power of the reference">l</a>) * <a class="code" href="classbdm_1_1rwiWishartCh.html#a239b26c71ebcc118ba6925dfb6efc50a" title="reference point for diagonal">refl</a> (ri); |
819 | | <a name="l01136"></a>01136 ri++; |
820 | | <a name="l01137"></a>01137 } |
821 | | <a name="l01138"></a>01138 |
822 | | <a name="l01139"></a>01139 <a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.<a class="code" href="classbdm_1_1eiWishartCh.html#ad9947933dfc94546cbd6a81f95ec5af5" title="access function">_setY</a> (<a class="code" href="classbdm_1_1rwiWishartCh.html#a2004675b37f712abe3913057bae97cfb" title="square root of - needed for computation of from conditions">sqd</a>*z); |
823 | | <a name="l01140"></a>01140 } |
824 | | <a name="l01141"></a>01141 }; |
825 | | <a name="l01142"></a>01142 |
826 | | <a name="l01144"></a>01144 <span class="keyword">enum</span> RESAMPLING_METHOD { MULTINOMIAL = 0, STRATIFIED = 1, SYSTEMATIC = 3 }; |
827 | | <a name="l01150"></a><a class="code" href="classbdm_1_1eEmp.html">01150</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1eEmp.html" title="Weighted empirical density.">eEmp</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> |
828 | | <a name="l01151"></a>01151 { |
829 | | <a name="l01152"></a>01152 <span class="keyword">protected</span> : |
830 | | <a name="l01154"></a><a class="code" href="classbdm_1_1eEmp.html#a9798006271ca77629855113f1283a031">01154</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1eEmp.html#a9798006271ca77629855113f1283a031" title="Number of particles.">n</a>; |
831 | | <a name="l01156"></a><a class="code" href="classbdm_1_1eEmp.html#a9d39241aab7c4bbeb07c6d516421c67d">01156</a> vec <a class="code" href="classbdm_1_1eEmp.html#a9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a>; |
832 | | <a name="l01158"></a><a class="code" href="classbdm_1_1eEmp.html#a73d819553a0f268b055a087d2d4486f3">01158</a> Array<vec> <a class="code" href="classbdm_1_1eEmp.html#a73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a>; |
833 | | <a name="l01159"></a>01159 <span class="keyword">public</span>: |
834 | | <a name="l01162"></a>01162 <a class="code" href="classbdm_1_1eEmp.html" title="Weighted empirical density.">eEmp</a> () : <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> (), <a class="code" href="classbdm_1_1eEmp.html#a9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a> (), <a class="code" href="classbdm_1_1eEmp.html#a73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a> () {}; |
835 | | <a name="l01164"></a><a class="code" href="classbdm_1_1eEmp.html#aa3daf6363455af099921715e1233c076">01164</a> <a class="code" href="classbdm_1_1eEmp.html#aa3daf6363455af099921715e1233c076" title="copy constructor">eEmp</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1eEmp.html" title="Weighted empirical density.">eEmp</a> &e) : <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> (e), <a class="code" href="classbdm_1_1eEmp.html#a9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a> (e.<a class="code" href="classbdm_1_1eEmp.html#a9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a>), <a class="code" href="classbdm_1_1eEmp.html#a73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a> (e.<a class="code" href="classbdm_1_1eEmp.html#a73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a>) {}; |
836 | | <a name="l01166"></a>01166 |
837 | | <a name="l01168"></a>01168 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eEmp.html#ae7f8f98310c1de51bd5c8a1c87528f72" title="Set samples and weights.">set_statistics</a> (<span class="keyword">const</span> vec &w0, <span class="keyword">const</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> &pdf0); |
838 | | <a name="l01170"></a><a class="code" href="classbdm_1_1eEmp.html#a4f7e6ba7183972e3c7ae399613861b95">01170</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eEmp.html#a4f7e6ba7183972e3c7ae399613861b95" title="Set samples and weights.">set_statistics</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> &pdf0 , <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1eEmp.html#a9798006271ca77629855113f1283a031" title="Number of particles.">n</a>) {<a class="code" href="classbdm_1_1eEmp.html#a4f7e6ba7183972e3c7ae399613861b95" title="Set samples and weights.">set_statistics</a> (ones (n) / n, pdf0);}; |
839 | | <a name="l01172"></a>01172 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eEmp.html#ab62d802b8ef39f7c4dcbeb366c90951a" title="Set sample.">set_samples</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* pdf0); |
840 | | <a name="l01174"></a><a class="code" href="classbdm_1_1eEmp.html#ac74c281d652356c19b6b079e42ca7ef1">01174</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eEmp.html#ac74c281d652356c19b6b079e42ca7ef1" title="Set sample.">set_parameters</a> (<span class="keywordtype">int</span> n0, <span class="keywordtype">bool</span> copy = <span class="keyword">true</span>) {<a class="code" href="classbdm_1_1eEmp.html#a9798006271ca77629855113f1283a031" title="Number of particles.">n</a> = n0; <a class="code" href="classbdm_1_1eEmp.html#a9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a>.set_size (n0, copy);<a class="code" href="classbdm_1_1eEmp.html#a73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a>.set_size (n0, copy);}; |
841 | | <a name="l01176"></a><a class="code" href="classbdm_1_1eEmp.html#a37937007a3a676cf653a7de412674481">01176</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eEmp.html#a37937007a3a676cf653a7de412674481" title="Set samples.">set_parameters</a> (<span class="keyword">const</span> Array<vec> &Av) { |
842 | | <a name="l01177"></a>01177 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a>(Av.size()>0,<span class="stringliteral">"Empty samples"</span>); |
843 | | <a name="l01178"></a>01178 <a class="code" href="classbdm_1_1eEmp.html#a9798006271ca77629855113f1283a031" title="Number of particles.">n</a> = Av.size(); |
844 | | <a name="l01179"></a>01179 <a class="code" href="classbdm_1_1eEmp.html#ac74c281d652356c19b6b079e42ca7ef1" title="Set sample.">epdf::set_parameters</a>(Av(0).length()); |
845 | | <a name="l01180"></a>01180 <a class="code" href="classbdm_1_1eEmp.html#a9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a>=1/n*ones(n); |
846 | | <a name="l01181"></a>01181 <a class="code" href="classbdm_1_1eEmp.html#a73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a>=Av; |
847 | | <a name="l01182"></a>01182 }; |
848 | | <a name="l01184"></a><a class="code" href="classbdm_1_1eEmp.html#ad7f83cc0415cd44ae7cc8b4bdad93aef">01184</a> vec& <a class="code" href="classbdm_1_1eEmp.html#ad7f83cc0415cd44ae7cc8b4bdad93aef" title="Potentially dangerous, use with care.">_w</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eEmp.html#a9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a>;}; |
849 | | <a name="l01186"></a><a class="code" href="classbdm_1_1eEmp.html#ab7d7106f486e3fad38590914a693d714">01186</a> <span class="keyword">const</span> vec& <a class="code" href="classbdm_1_1eEmp.html#ab7d7106f486e3fad38590914a693d714" title="Potentially dangerous, use with care.">_w</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eEmp.html#a9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a>;}; |
850 | | <a name="l01188"></a><a class="code" href="classbdm_1_1eEmp.html#ac24966b0aaeb767bc8a6b4fd60931be2">01188</a> Array<vec>& <a class="code" href="classbdm_1_1eEmp.html#ac24966b0aaeb767bc8a6b4fd60931be2" title="access function">_samples</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eEmp.html#a73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a>;}; |
851 | | <a name="l01190"></a><a class="code" href="classbdm_1_1eEmp.html#ab59af0efdb009d98ea8ebfa965e74ae2">01190</a> <span class="keyword">const</span> Array<vec>& <a class="code" href="classbdm_1_1eEmp.html#ab59af0efdb009d98ea8ebfa965e74ae2" title="access function">_samples</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eEmp.html#a73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a>;}; |
852 | | <a name="l01192"></a>01192 ivec <a class="code" href="classbdm_1_1eEmp.html#af06ce255de5dbb2313f52ee51f82ba3d" title="Function performs resampling, i.e. removal of low-weight samples and duplication...">resample</a> (RESAMPLING_METHOD method = SYSTEMATIC); |
| 782 | <a name="l01094"></a><a class="code" href="classbdm_1_1rwiWishartCh.html">01094</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1rwiWishartCh.html" title="Random Walk on inverse Wishart.">rwiWishartCh</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mpdf__internal.html" title="Mpdf with internal epdf that is modified by function condition.">mpdf_internal</a><eiWishartCh> |
| 783 | <a name="l01095"></a>01095 { |
| 784 | <a name="l01096"></a>01096 <span class="keyword">protected</span>: |
| 785 | <a name="l01098"></a><a class="code" href="classbdm_1_1rwiWishartCh.html#a2004675b37f712abe3913057bae97cfb">01098</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1rwiWishartCh.html#a2004675b37f712abe3913057bae97cfb" title="square root of - needed for computation of from conditions">sqd</a>; |
| 786 | <a name="l01100"></a><a class="code" href="classbdm_1_1rwiWishartCh.html#a239b26c71ebcc118ba6925dfb6efc50a">01100</a> vec <a class="code" href="classbdm_1_1rwiWishartCh.html#a239b26c71ebcc118ba6925dfb6efc50a" title="reference point for diagonal">refl</a>; |
| 787 | <a name="l01102"></a><a class="code" href="classbdm_1_1rwiWishartCh.html#a758cd05efa67c60b4bf4f7554b9ba861">01102</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1rwiWishartCh.html#a758cd05efa67c60b4bf4f7554b9ba861" title="power of the reference">l</a>; |
| 788 | <a name="l01104"></a><a class="code" href="classbdm_1_1rwiWishartCh.html#a7ba06d431995c347d2fce30a59c20663">01104</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1rwiWishartCh.html#a7ba06d431995c347d2fce30a59c20663" title="dimension">p</a>; |
| 789 | <a name="l01105"></a>01105 |
| 790 | <a name="l01106"></a>01106 <span class="keyword">public</span>: |
| 791 | <a name="l01107"></a>01107 <a class="code" href="classbdm_1_1rwiWishartCh.html" title="Random Walk on inverse Wishart.">rwiWishartCh</a>() : <a class="code" href="classbdm_1_1rwiWishartCh.html#a2004675b37f712abe3913057bae97cfb" title="square root of - needed for computation of from conditions">sqd</a> (0), <a class="code" href="classbdm_1_1rwiWishartCh.html#a758cd05efa67c60b4bf4f7554b9ba861" title="power of the reference">l</a> (0), <a class="code" href="classbdm_1_1rwiWishartCh.html#a7ba06d431995c347d2fce30a59c20663" title="dimension">p</a> (0) {} |
| 792 | <a name="l01109"></a><a class="code" href="classbdm_1_1rwiWishartCh.html#a28549ee3ce1ff8509360171ea3cf717c">01109</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1rwiWishartCh.html#a28549ee3ce1ff8509360171ea3cf717c" title="constructor function">set_parameters</a> (<span class="keywordtype">int</span> p0, <span class="keywordtype">double</span> k, vec ref0, <span class="keywordtype">double</span> l0) { |
| 793 | <a name="l01110"></a>01110 <a class="code" href="classbdm_1_1rwiWishartCh.html#a7ba06d431995c347d2fce30a59c20663" title="dimension">p</a> = p0; |
| 794 | <a name="l01111"></a>01111 <span class="keywordtype">double</span> delta = 2 / (k * k) + <a class="code" href="classbdm_1_1rwiWishartCh.html#a7ba06d431995c347d2fce30a59c20663" title="dimension">p</a> + 3; |
| 795 | <a name="l01112"></a>01112 <a class="code" href="classbdm_1_1rwiWishartCh.html#a2004675b37f712abe3913057bae97cfb" title="square root of - needed for computation of from conditions">sqd</a> = sqrt (delta - <a class="code" href="classbdm_1_1rwiWishartCh.html#a7ba06d431995c347d2fce30a59c20663" title="dimension">p</a> - 1); |
| 796 | <a name="l01113"></a>01113 <a class="code" href="classbdm_1_1rwiWishartCh.html#a758cd05efa67c60b4bf4f7554b9ba861" title="power of the reference">l</a> = l0; |
| 797 | <a name="l01114"></a>01114 <a class="code" href="classbdm_1_1rwiWishartCh.html#a239b26c71ebcc118ba6925dfb6efc50a" title="reference point for diagonal">refl</a> = pow (ref0, 1 - <a class="code" href="classbdm_1_1rwiWishartCh.html#a758cd05efa67c60b4bf4f7554b9ba861" title="power of the reference">l</a>); |
| 798 | <a name="l01115"></a>01115 |
| 799 | <a name="l01116"></a>01116 <a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.<a class="code" href="classbdm_1_1eiWishartCh.html#af463caed9d22d9949f3ee67614e7dcd3" title="constructor function">set_parameters</a> (eye (<a class="code" href="classbdm_1_1rwiWishartCh.html#a7ba06d431995c347d2fce30a59c20663" title="dimension">p</a>), delta); |
| 800 | <a name="l01117"></a>01117 <a class="code" href="classbdm_1_1mpdf.html#a7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a> = <a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.<a class="code" href="classbdm_1_1epdf.html#a7083a65f7b7a0d0d13b2c516bd2ec29c" title="Size of the random variable.">dimension</a>(); |
| 801 | <a name="l01118"></a>01118 } |
| 802 | <a name="l01119"></a><a class="code" href="classbdm_1_1rwiWishartCh.html#aac087ba6c885d3faeda9171229f9b4e6">01119</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1rwiWishartCh.html#aac087ba6c885d3faeda9171229f9b4e6" title="Update iepdf so that it represents this mpdf conditioned on rvc = cond This function...">condition</a> (<span class="keyword">const</span> vec &c) { |
| 803 | <a name="l01120"></a>01120 vec z = c; |
| 804 | <a name="l01121"></a>01121 <span class="keywordtype">int</span> ri = 0; |
| 805 | <a name="l01122"></a>01122 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0;i < <a class="code" href="classbdm_1_1rwiWishartCh.html#a7ba06d431995c347d2fce30a59c20663" title="dimension">p</a>*<a class="code" href="classbdm_1_1rwiWishartCh.html#a7ba06d431995c347d2fce30a59c20663" title="dimension">p</a>;i += (p + 1)) {<span class="comment">//trace diagonal element</span> |
| 806 | <a name="l01123"></a>01123 z (i) = pow (z (i), <a class="code" href="classbdm_1_1rwiWishartCh.html#a758cd05efa67c60b4bf4f7554b9ba861" title="power of the reference">l</a>) * <a class="code" href="classbdm_1_1rwiWishartCh.html#a239b26c71ebcc118ba6925dfb6efc50a" title="reference point for diagonal">refl</a> (ri); |
| 807 | <a name="l01124"></a>01124 ri++; |
| 808 | <a name="l01125"></a>01125 } |
| 809 | <a name="l01126"></a>01126 |
| 810 | <a name="l01127"></a>01127 <a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.<a class="code" href="classbdm_1_1eiWishartCh.html#ad9947933dfc94546cbd6a81f95ec5af5" title="access function">_setY</a> (<a class="code" href="classbdm_1_1rwiWishartCh.html#a2004675b37f712abe3913057bae97cfb" title="square root of - needed for computation of from conditions">sqd</a>*z); |
| 811 | <a name="l01128"></a>01128 } |
| 812 | <a name="l01129"></a>01129 }; |
| 813 | <a name="l01130"></a>01130 |
| 814 | <a name="l01132"></a>01132 <span class="keyword">enum</span> RESAMPLING_METHOD { MULTINOMIAL = 0, STRATIFIED = 1, SYSTEMATIC = 3 }; |
| 815 | <a name="l01138"></a><a class="code" href="classbdm_1_1eEmp.html">01138</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1eEmp.html" title="Weighted empirical density.">eEmp</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> |
| 816 | <a name="l01139"></a>01139 { |
| 817 | <a name="l01140"></a>01140 <span class="keyword">protected</span> : |
| 818 | <a name="l01142"></a><a class="code" href="classbdm_1_1eEmp.html#a9798006271ca77629855113f1283a031">01142</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1eEmp.html#a9798006271ca77629855113f1283a031" title="Number of particles.">n</a>; |
| 819 | <a name="l01144"></a><a class="code" href="classbdm_1_1eEmp.html#a9d39241aab7c4bbeb07c6d516421c67d">01144</a> vec <a class="code" href="classbdm_1_1eEmp.html#a9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a>; |
| 820 | <a name="l01146"></a><a class="code" href="classbdm_1_1eEmp.html#a73d819553a0f268b055a087d2d4486f3">01146</a> Array<vec> <a class="code" href="classbdm_1_1eEmp.html#a73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a>; |
| 821 | <a name="l01147"></a>01147 <span class="keyword">public</span>: |
| 822 | <a name="l01150"></a>01150 <a class="code" href="classbdm_1_1eEmp.html" title="Weighted empirical density.">eEmp</a> () : <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> (), <a class="code" href="classbdm_1_1eEmp.html#a9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a> (), <a class="code" href="classbdm_1_1eEmp.html#a73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a> () {}; |
| 823 | <a name="l01152"></a><a class="code" href="classbdm_1_1eEmp.html#aa3daf6363455af099921715e1233c076">01152</a> <a class="code" href="classbdm_1_1eEmp.html#aa3daf6363455af099921715e1233c076" title="copy constructor">eEmp</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1eEmp.html" title="Weighted empirical density.">eEmp</a> &e) : <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> (e), <a class="code" href="classbdm_1_1eEmp.html#a9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a> (e.<a class="code" href="classbdm_1_1eEmp.html#a9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a>), <a class="code" href="classbdm_1_1eEmp.html#a73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a> (e.<a class="code" href="classbdm_1_1eEmp.html#a73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a>) {}; |
| 824 | <a name="l01154"></a>01154 |
| 825 | <a name="l01156"></a>01156 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eEmp.html#ae7f8f98310c1de51bd5c8a1c87528f72" title="Set samples and weights.">set_statistics</a> (<span class="keyword">const</span> vec &w0, <span class="keyword">const</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> &pdf0); |
| 826 | <a name="l01158"></a><a class="code" href="classbdm_1_1eEmp.html#a4f7e6ba7183972e3c7ae399613861b95">01158</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eEmp.html#a4f7e6ba7183972e3c7ae399613861b95" title="Set samples and weights.">set_statistics</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> &pdf0 , <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1eEmp.html#a9798006271ca77629855113f1283a031" title="Number of particles.">n</a>) {<a class="code" href="classbdm_1_1eEmp.html#a4f7e6ba7183972e3c7ae399613861b95" title="Set samples and weights.">set_statistics</a> (ones (n) / n, pdf0);}; |
| 827 | <a name="l01160"></a>01160 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eEmp.html#ab62d802b8ef39f7c4dcbeb366c90951a" title="Set sample.">set_samples</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* pdf0); |
| 828 | <a name="l01162"></a><a class="code" href="classbdm_1_1eEmp.html#ac74c281d652356c19b6b079e42ca7ef1">01162</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eEmp.html#ac74c281d652356c19b6b079e42ca7ef1" title="Set sample.">set_parameters</a> (<span class="keywordtype">int</span> n0, <span class="keywordtype">bool</span> copy = <span class="keyword">true</span>) {<a class="code" href="classbdm_1_1eEmp.html#a9798006271ca77629855113f1283a031" title="Number of particles.">n</a> = n0; <a class="code" href="classbdm_1_1eEmp.html#a9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a>.set_size (n0, copy);<a class="code" href="classbdm_1_1eEmp.html#a73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a>.set_size (n0, copy);}; |
| 829 | <a name="l01164"></a><a class="code" href="classbdm_1_1eEmp.html#a37937007a3a676cf653a7de412674481">01164</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eEmp.html#a37937007a3a676cf653a7de412674481" title="Set samples.">set_parameters</a> (<span class="keyword">const</span> Array<vec> &Av) { |
| 830 | <a name="l01165"></a>01165 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a>(Av.size()>0,<span class="stringliteral">"Empty samples"</span>); |
| 831 | <a name="l01166"></a>01166 <a class="code" href="classbdm_1_1eEmp.html#a9798006271ca77629855113f1283a031" title="Number of particles.">n</a> = Av.size(); |
| 832 | <a name="l01167"></a>01167 <a class="code" href="classbdm_1_1eEmp.html#ac74c281d652356c19b6b079e42ca7ef1" title="Set sample.">epdf::set_parameters</a>(Av(0).length()); |
| 833 | <a name="l01168"></a>01168 <a class="code" href="classbdm_1_1eEmp.html#a9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a>=1/n*ones(n); |
| 834 | <a name="l01169"></a>01169 <a class="code" href="classbdm_1_1eEmp.html#a73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a>=Av; |
| 835 | <a name="l01170"></a>01170 }; |
| 836 | <a name="l01172"></a><a class="code" href="classbdm_1_1eEmp.html#ad7f83cc0415cd44ae7cc8b4bdad93aef">01172</a> vec& <a class="code" href="classbdm_1_1eEmp.html#ad7f83cc0415cd44ae7cc8b4bdad93aef" title="Potentially dangerous, use with care.">_w</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eEmp.html#a9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a>;}; |
| 837 | <a name="l01174"></a><a class="code" href="classbdm_1_1eEmp.html#ab7d7106f486e3fad38590914a693d714">01174</a> <span class="keyword">const</span> vec& <a class="code" href="classbdm_1_1eEmp.html#ab7d7106f486e3fad38590914a693d714" title="Potentially dangerous, use with care.">_w</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eEmp.html#a9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a>;}; |
| 838 | <a name="l01176"></a><a class="code" href="classbdm_1_1eEmp.html#ac24966b0aaeb767bc8a6b4fd60931be2">01176</a> Array<vec>& <a class="code" href="classbdm_1_1eEmp.html#ac24966b0aaeb767bc8a6b4fd60931be2" title="access function">_samples</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eEmp.html#a73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a>;}; |
| 839 | <a name="l01178"></a><a class="code" href="classbdm_1_1eEmp.html#ab59af0efdb009d98ea8ebfa965e74ae2">01178</a> <span class="keyword">const</span> Array<vec>& <a class="code" href="classbdm_1_1eEmp.html#ab59af0efdb009d98ea8ebfa965e74ae2" title="access function">_samples</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eEmp.html#a73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a>;}; |
| 840 | <a name="l01180"></a>01180 ivec <a class="code" href="classbdm_1_1eEmp.html#af06ce255de5dbb2313f52ee51f82ba3d" title="Function performs resampling, i.e. removal of low-weight samples and duplication...">resample</a> (RESAMPLING_METHOD method = SYSTEMATIC); |
| 841 | <a name="l01181"></a>01181 |
| 842 | <a name="l01183"></a><a class="code" href="classbdm_1_1eEmp.html#a97f1e07b5ae6eebc91c7365f0f88d270">01183</a> vec <a class="code" href="classbdm_1_1eEmp.html#a97f1e07b5ae6eebc91c7365f0f88d270" title="inherited operation : NOT implemented">sample</a>()<span class="keyword"> const </span>{ |
| 843 | <a name="l01184"></a>01184 <a class="code" href="bdmerror_8h.html#a7c43f3a72afe68ab0c85663a1bb3521a" title="Unconditionally throw std::runtime_error.">bdm_error</a> (<span class="stringliteral">"Not implemented"</span>); |
| 844 | <a name="l01185"></a>01185 <span class="keywordflow">return</span> vec(); |
| 845 | <a name="l01186"></a>01186 } |
| 846 | <a name="l01187"></a>01187 |
| 847 | <a name="l01189"></a><a class="code" href="classbdm_1_1eEmp.html#a01654c014d3aa068f8d4ecba4be86d09">01189</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eEmp.html#a01654c014d3aa068f8d4ecba4be86d09" title="inherited operation : NOT implemented">evallog</a> (<span class="keyword">const</span> vec &val)<span class="keyword"> const </span>{ |
| 848 | <a name="l01190"></a>01190 <a class="code" href="bdmerror_8h.html#a7c43f3a72afe68ab0c85663a1bb3521a" title="Unconditionally throw std::runtime_error.">bdm_error</a> (<span class="stringliteral">"Not implemented"</span>); |
| 849 | <a name="l01191"></a>01191 <span class="keywordflow">return</span> 0.0; |
| 850 | <a name="l01192"></a>01192 } |
999 | | <a name="l01343"></a>01343 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> (<a class="code" href="classbdm_1_1epdf.html#ac4b863ff84c7a4882fb3ad18556027f9" title="True if rv is assigned.">isnamed</a>(), <span class="stringliteral">"rv description is not assigned"</span>); |
1000 | | <a name="l01344"></a>01344 ivec irvn = rvn.<a class="code" href="classbdm_1_1RV.html#acbebdb5e0d30101a6eb63550ef701c55" title="when this rv is a part of bigger rv, this function returns indices of self in the...">dataind</a> (<a class="code" href="classbdm_1_1epdf.html#a62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>); |
1001 | | <a name="l01345"></a>01345 |
1002 | | <a name="l01346"></a>01346 sq_T Rn (<a class="code" href="classbdm_1_1enorm.html#a2d92dde696b2a7a5b10ddef5d22ba2c2" title="Covariance matrix in decomposed form.">R</a>, irvn); <span class="comment">// select rows and columns of R</span> |
1003 | | <a name="l01347"></a>01347 |
1004 | | <a name="l01348"></a>01348 target.<a class="code" href="classbdm_1_1epdf.html#af423e28448dbb69ef4905295ec8de8ff" title="Name its rv.">set_rv</a> ( rvn ); |
1005 | | <a name="l01349"></a>01349 target.set_parameters (<a class="code" href="classbdm_1_1enorm.html#ac702a194720853570d08b65482f842c7" title="mean value">mu</a> (irvn), Rn); |
1006 | | <a name="l01350"></a>01350 } |
1007 | | <a name="l01351"></a>01351 |
1008 | | <a name="l01352"></a>01352 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
1009 | | <a name="l01353"></a><a class="code" href="classbdm_1_1enorm.html#a40201ca12c6900f7aeb493bb7c582e20">01353</a> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<mpdf></a> <a class="code" href="classbdm_1_1enorm.html#a40201ca12c6900f7aeb493bb7c582e20" title="Return conditional density on the given RV, the remaining rvs will be in conditioning...">enorm<sq_T>::condition</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rvn )<span class="keyword"> const</span> |
1010 | | <a name="l01354"></a>01354 <span class="keyword"></span>{ |
1011 | | <a name="l01355"></a>01355 <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm<sq_T></a> *tmp = <span class="keyword">new</span> <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm<sq_T></a> (); |
1012 | | <a name="l01356"></a>01356 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<mpdf></a> narrow(tmp); |
1013 | | <a name="l01357"></a>01357 <a class="code" href="classbdm_1_1enorm.html#a40201ca12c6900f7aeb493bb7c582e20" title="Return conditional density on the given RV, the remaining rvs will be in conditioning...">condition</a> ( rvn, *tmp ); |
1014 | | <a name="l01358"></a>01358 <span class="keywordflow">return</span> narrow; |
1015 | | <a name="l01359"></a>01359 } |
1016 | | <a name="l01360"></a>01360 |
1017 | | <a name="l01361"></a>01361 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
1018 | | <a name="l01362"></a>01362 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1enorm.html#a40201ca12c6900f7aeb493bb7c582e20" title="Return conditional density on the given RV, the remaining rvs will be in conditioning...">enorm<sq_T>::condition</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rvn, <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling , where is random variable, rv, and...">mpdf</a> &target )<span class="keyword"> const</span> |
1019 | | <a name="l01363"></a>01363 <span class="keyword"></span>{ |
1020 | | <a name="l01364"></a>01364 <span class="keyword">typedef</span> <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm<sq_T></a> TMlnorm; |
1021 | | <a name="l01365"></a>01365 |
1022 | | <a name="l01366"></a>01366 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> (<a class="code" href="classbdm_1_1epdf.html#ac4b863ff84c7a4882fb3ad18556027f9" title="True if rv is assigned.">isnamed</a>(), <span class="stringliteral">"rvs are not assigned"</span>); |
1023 | | <a name="l01367"></a>01367 TMlnorm &uptarget = <span class="keyword">dynamic_cast<</span>TMlnorm &<span class="keyword">></span>(target); |
1024 | | <a name="l01368"></a>01368 |
1025 | | <a name="l01369"></a>01369 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> rvc = <a class="code" href="classbdm_1_1epdf.html#a62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#aaec44dabdf0a6d90fbae95e1356eda39" title="Subtract another variable from the current one.">subt</a> (rvn); |
1026 | | <a name="l01370"></a>01370 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> ( (rvc.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>() + rvn.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>() == <a class="code" href="classbdm_1_1epdf.html#a62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>()), <span class="stringliteral">"wrong rvn"</span>); |
1027 | | <a name="l01371"></a>01371 <span class="comment">//Permutation vector of the new R</span> |
1028 | | <a name="l01372"></a>01372 ivec irvn = rvn.<a class="code" href="classbdm_1_1RV.html#acbebdb5e0d30101a6eb63550ef701c55" title="when this rv is a part of bigger rv, this function returns indices of self in the...">dataind</a> (<a class="code" href="classbdm_1_1epdf.html#a62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>); |
1029 | | <a name="l01373"></a>01373 ivec irvc = rvc.<a class="code" href="classbdm_1_1RV.html#acbebdb5e0d30101a6eb63550ef701c55" title="when this rv is a part of bigger rv, this function returns indices of self in the...">dataind</a> (<a class="code" href="classbdm_1_1epdf.html#a62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>); |
1030 | | <a name="l01374"></a>01374 ivec perm = concat (irvn , irvc); |
1031 | | <a name="l01375"></a>01375 sq_T Rn (<a class="code" href="classbdm_1_1enorm.html#a2d92dde696b2a7a5b10ddef5d22ba2c2" title="Covariance matrix in decomposed form.">R</a>, perm); |
1032 | | <a name="l01376"></a>01376 |
1033 | | <a name="l01377"></a>01377 <span class="comment">//fixme - could this be done in general for all sq_T?</span> |
1034 | | <a name="l01378"></a>01378 mat S = Rn.to_mat(); |
1035 | | <a name="l01379"></a>01379 <span class="comment">//fixme</span> |
1036 | | <a name="l01380"></a>01380 <span class="keywordtype">int</span> n = rvn.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>() - 1; |
1037 | | <a name="l01381"></a>01381 <span class="keywordtype">int</span> end = <a class="code" href="classbdm_1_1enorm.html#a2d92dde696b2a7a5b10ddef5d22ba2c2" title="Covariance matrix in decomposed form.">R</a>.rows() - 1; |
1038 | | <a name="l01382"></a>01382 mat S11 = S.get (0, n, 0, n); |
1039 | | <a name="l01383"></a>01383 mat S12 = S.get (0, n , rvn.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>(), end); |
1040 | | <a name="l01384"></a>01384 mat S22 = S.get (rvn.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>(), end, rvn.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>(), end); |
1041 | | <a name="l01385"></a>01385 |
1042 | | <a name="l01386"></a>01386 vec mu1 = <a class="code" href="classbdm_1_1enorm.html#ac702a194720853570d08b65482f842c7" title="mean value">mu</a> (irvn); |
1043 | | <a name="l01387"></a>01387 vec mu2 = <a class="code" href="classbdm_1_1enorm.html#ac702a194720853570d08b65482f842c7" title="mean value">mu</a> (irvc); |
1044 | | <a name="l01388"></a>01388 mat A = S12 * inv (S22); |
1045 | | <a name="l01389"></a>01389 sq_T R_n (S11 - A *S12.T()); |
1046 | | <a name="l01390"></a>01390 |
1047 | | <a name="l01391"></a>01391 uptarget.set_rv (rvn); |
1048 | | <a name="l01392"></a>01392 uptarget.set_rvc (rvc); |
1049 | | <a name="l01393"></a>01393 uptarget.set_parameters (A, mu1 - A*mu2, R_n); |
1050 | | <a name="l01394"></a>01394 } |
1051 | | <a name="l01395"></a>01395 |
1052 | | <a name="l01398"></a>01398 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
1053 | | <a name="l01399"></a><a class="code" href="classbdm_1_1mgnorm.html#ab736332d20e418bf50d45836e129f339">01399</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgnorm.html#ab736332d20e418bf50d45836e129f339" title="set mean function">mgnorm<sq_T >::set_parameters</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<fnc></a> &g0, <span class="keyword">const</span> sq_T &R0) { |
1054 | | <a name="l01400"></a>01400 g = g0; |
1055 | | <a name="l01401"></a>01401 this-><a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.set_parameters (zeros (g->dimension()), R0); |
1056 | | <a name="l01402"></a>01402 } |
1057 | | <a name="l01403"></a>01403 |
1058 | | <a name="l01404"></a>01404 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
1059 | | <a name="l01405"></a><a class="code" href="classbdm_1_1mgnorm.html#ab31d63472cf6a1030cd8dbd8094c1f6d">01405</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgnorm.html#ab31d63472cf6a1030cd8dbd8094c1f6d" title="Update iepdf so that it represents this mpdf conditioned on rvc = cond This function...">mgnorm<sq_T >::condition</a> (<span class="keyword">const</span> vec &cond) {this-><a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>._mu() = g->eval (cond);}; |
1060 | | <a name="l01406"></a>01406 |
1061 | | <a name="l01408"></a>01408 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
1062 | | <a name="l01409"></a>01409 std::ostream &operator<< (std::ostream &os, mlnorm<sq_T> &ml) |
1063 | | <a name="l01410"></a>01410 { |
1064 | | <a name="l01411"></a>01411 os << <span class="stringliteral">"A:"</span> << ml.A << endl; |
1065 | | <a name="l01412"></a>01412 os << <span class="stringliteral">"mu:"</span> << ml.mu_const << endl; |
1066 | | <a name="l01413"></a>01413 os << <span class="stringliteral">"R:"</span> << ml._R() << endl; |
1067 | | <a name="l01414"></a>01414 <span class="keywordflow">return</span> os; |
1068 | | <a name="l01415"></a>01415 }; |
1069 | | <a name="l01416"></a>01416 |
1070 | | <a name="l01417"></a>01417 } |
1071 | | <a name="l01418"></a>01418 <span class="preprocessor">#endif //EF_H</span> |
| 999 | <a name="l01343"></a>01343 <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm<sq_T></a> *tmp = <span class="keyword">new</span> <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm<sq_T></a> (); |
| 1000 | <a name="l01344"></a>01344 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<mpdf></a> narrow(tmp); |
| 1001 | <a name="l01345"></a>01345 <a class="code" href="classbdm_1_1enorm.html#a40201ca12c6900f7aeb493bb7c582e20" title="Return conditional density on the given RV, the remaining rvs will be in conditioning...">condition</a> ( rvn, *tmp ); |
| 1002 | <a name="l01346"></a>01346 <span class="keywordflow">return</span> narrow; |
| 1003 | <a name="l01347"></a>01347 } |
| 1004 | <a name="l01348"></a>01348 |
| 1005 | <a name="l01349"></a>01349 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
| 1006 | <a name="l01350"></a>01350 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1enorm.html#a40201ca12c6900f7aeb493bb7c582e20" title="Return conditional density on the given RV, the remaining rvs will be in conditioning...">enorm<sq_T>::condition</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rvn, <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling , where is random variable, rv, and...">mpdf</a> &target )<span class="keyword"> const</span> |
| 1007 | <a name="l01351"></a>01351 <span class="keyword"></span>{ |
| 1008 | <a name="l01352"></a>01352 <span class="keyword">typedef</span> <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm<sq_T></a> TMlnorm; |
| 1009 | <a name="l01353"></a>01353 |
| 1010 | <a name="l01354"></a>01354 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> (<a class="code" href="classbdm_1_1epdf.html#ac4b863ff84c7a4882fb3ad18556027f9" title="True if rv is assigned.">isnamed</a>(), <span class="stringliteral">"rvs are not assigned"</span>); |
| 1011 | <a name="l01355"></a>01355 TMlnorm &uptarget = <span class="keyword">dynamic_cast<</span>TMlnorm &<span class="keyword">></span>(target); |
| 1012 | <a name="l01356"></a>01356 |
| 1013 | <a name="l01357"></a>01357 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> rvc = <a class="code" href="classbdm_1_1epdf.html#a62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#aaec44dabdf0a6d90fbae95e1356eda39" title="Subtract another variable from the current one.">subt</a> (rvn); |
| 1014 | <a name="l01358"></a>01358 <a class="code" href="bdmerror_8h.html#a7a3399d182b8e3065532596e76f84849" title="Throw std::runtime_exception if t is not true.">bdm_assert</a> ( (rvc.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>() + rvn.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>() == <a class="code" href="classbdm_1_1epdf.html#a62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>()), <span class="stringliteral">"wrong rvn"</span>); |
| 1015 | <a name="l01359"></a>01359 <span class="comment">//Permutation vector of the new R</span> |
| 1016 | <a name="l01360"></a>01360 ivec irvn = rvn.<a class="code" href="classbdm_1_1RV.html#acbebdb5e0d30101a6eb63550ef701c55" title="when this rv is a part of bigger rv, this function returns indices of self in the...">dataind</a> (<a class="code" href="classbdm_1_1epdf.html#a62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>); |
| 1017 | <a name="l01361"></a>01361 ivec irvc = rvc.<a class="code" href="classbdm_1_1RV.html#acbebdb5e0d30101a6eb63550ef701c55" title="when this rv is a part of bigger rv, this function returns indices of self in the...">dataind</a> (<a class="code" href="classbdm_1_1epdf.html#a62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>); |
| 1018 | <a name="l01362"></a>01362 ivec perm = concat (irvn , irvc); |
| 1019 | <a name="l01363"></a>01363 sq_T Rn (<a class="code" href="classbdm_1_1enorm.html#a2d92dde696b2a7a5b10ddef5d22ba2c2" title="Covariance matrix in decomposed form.">R</a>, perm); |
| 1020 | <a name="l01364"></a>01364 |
| 1021 | <a name="l01365"></a>01365 <span class="comment">//fixme - could this be done in general for all sq_T?</span> |
| 1022 | <a name="l01366"></a>01366 mat S = Rn.to_mat(); |
| 1023 | <a name="l01367"></a>01367 <span class="comment">//fixme</span> |
| 1024 | <a name="l01368"></a>01368 <span class="keywordtype">int</span> n = rvn.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>() - 1; |
| 1025 | <a name="l01369"></a>01369 <span class="keywordtype">int</span> end = <a class="code" href="classbdm_1_1enorm.html#a2d92dde696b2a7a5b10ddef5d22ba2c2" title="Covariance matrix in decomposed form.">R</a>.rows() - 1; |
| 1026 | <a name="l01370"></a>01370 mat S11 = S.get (0, n, 0, n); |
| 1027 | <a name="l01371"></a>01371 mat S12 = S.get (0, n , rvn.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>(), end); |
| 1028 | <a name="l01372"></a>01372 mat S22 = S.get (rvn.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>(), end, rvn.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>(), end); |
| 1029 | <a name="l01373"></a>01373 |
| 1030 | <a name="l01374"></a>01374 vec mu1 = <a class="code" href="classbdm_1_1enorm.html#ac702a194720853570d08b65482f842c7" title="mean value">mu</a> (irvn); |
| 1031 | <a name="l01375"></a>01375 vec mu2 = <a class="code" href="classbdm_1_1enorm.html#ac702a194720853570d08b65482f842c7" title="mean value">mu</a> (irvc); |
| 1032 | <a name="l01376"></a>01376 mat A = S12 * inv (S22); |
| 1033 | <a name="l01377"></a>01377 sq_T R_n (S11 - A *S12.T()); |
| 1034 | <a name="l01378"></a>01378 |
| 1035 | <a name="l01379"></a>01379 uptarget.set_rv (rvn); |
| 1036 | <a name="l01380"></a>01380 uptarget.set_rvc (rvc); |
| 1037 | <a name="l01381"></a>01381 uptarget.set_parameters (A, mu1 - A*mu2, R_n); |
| 1038 | <a name="l01382"></a>01382 } |
| 1039 | <a name="l01383"></a>01383 |
| 1040 | <a name="l01386"></a>01386 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
| 1041 | <a name="l01387"></a><a class="code" href="classbdm_1_1mgnorm.html#ab736332d20e418bf50d45836e129f339">01387</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgnorm.html#ab736332d20e418bf50d45836e129f339" title="set mean function">mgnorm<sq_T >::set_parameters</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<fnc></a> &g0, <span class="keyword">const</span> sq_T &R0) { |
| 1042 | <a name="l01388"></a>01388 g = g0; |
| 1043 | <a name="l01389"></a>01389 this-><a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.set_parameters (zeros (g->dimension()), R0); |
| 1044 | <a name="l01390"></a>01390 } |
| 1045 | <a name="l01391"></a>01391 |
| 1046 | <a name="l01392"></a>01392 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
| 1047 | <a name="l01393"></a><a class="code" href="classbdm_1_1mgnorm.html#ab31d63472cf6a1030cd8dbd8094c1f6d">01393</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgnorm.html#ab31d63472cf6a1030cd8dbd8094c1f6d" title="Update iepdf so that it represents this mpdf conditioned on rvc = cond This function...">mgnorm<sq_T >::condition</a> (<span class="keyword">const</span> vec &cond) {this-><a class="code" href="classbdm_1_1mpdf__internal.html#a47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>._mu() = g->eval (cond);}; |
| 1048 | <a name="l01394"></a>01394 |
| 1049 | <a name="l01396"></a>01396 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> |
| 1050 | <a name="l01397"></a>01397 std::ostream &operator<< (std::ostream &os, mlnorm<sq_T> &ml) |
| 1051 | <a name="l01398"></a>01398 { |
| 1052 | <a name="l01399"></a>01399 os << <span class="stringliteral">"A:"</span> << ml.A << endl; |
| 1053 | <a name="l01400"></a>01400 os << <span class="stringliteral">"mu:"</span> << ml.mu_const << endl; |
| 1054 | <a name="l01401"></a>01401 os << <span class="stringliteral">"R:"</span> << ml._R() << endl; |
| 1055 | <a name="l01402"></a>01402 <span class="keywordflow">return</span> os; |
| 1056 | <a name="l01403"></a>01403 }; |
| 1057 | <a name="l01404"></a>01404 |
| 1058 | <a name="l01405"></a>01405 } |
| 1059 | <a name="l01406"></a>01406 <span class="preprocessor">#endif //EF_H</span> |