Index: doc/html/libPF_8h-source.html
===================================================================
--- doc/html/libPF_8h-source.html (revision 224)
+++ doc/html/libPF_8h-source.html (revision 234)
@@ -44,153 +44,145 @@
 <a name="l00052"></a>00052         <span class="keywordtype">void</span> <a class="code" href="classPF.html#04d38fbcc0348b558212f530d9ec183e" title="Set posterior density by sampling from epdf0.">set_est</a> ( <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> &amp;epdf0 );
 <a name="l00053"></a>00053         <span class="keywordtype">void</span> <a class="code" href="classPF.html#64f636bbd63bea9efd778214e6b631d3" title="Incremental Bayes rule.">bayes</a> ( <span class="keyword">const</span> vec &amp;dt );
-<a name="l00054"></a>00054 };
-<a name="l00055"></a>00055 
-<a name="l00062"></a>00062 <span class="keyword">template</span>&lt;<span class="keyword">class</span> BM_T&gt;
-<a name="l00063"></a>00063 
-<a name="l00064"></a><a class="code" href="classMPF.html">00064</a> <span class="keyword">class </span><a class="code" href="classMPF.html" title="Marginalized Particle filter.">MPF</a> : <span class="keyword">public</span> <a class="code" href="classPF.html" title="Trivial particle filter with proposal density equal to parameter evolution model...">PF</a> {
-<a name="l00065"></a>00065         BM_T* Bms[10000];
-<a name="l00066"></a>00066 
+<a name="l00055"></a><a class="code" href="classPF.html#140a073d5236684078b09021892d3b20">00055</a>         vec* <a class="code" href="classPF.html#140a073d5236684078b09021892d3b20" title="access function">__w</a>(){<span class="keywordflow">return</span> &amp;<a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a>;}
+<a name="l00056"></a>00056 };
+<a name="l00057"></a>00057 
+<a name="l00064"></a>00064 <span class="keyword">template</span>&lt;<span class="keyword">class</span> BM_T&gt;
+<a name="l00065"></a>00065 
+<a name="l00066"></a><a class="code" href="classMPF.html">00066</a> <span class="keyword">class </span><a class="code" href="classMPF.html" title="Marginalized Particle filter.">MPF</a> : <span class="keyword">public</span> <a class="code" href="classPF.html" title="Trivial particle filter with proposal density equal to parameter evolution model...">PF</a> {
+<a name="l00067"></a>00067         BM_T* Bms[10000];
 <a name="l00068"></a>00068 
-<a name="l00069"></a>00069 <span class="keyword">class </span>mpfepdf : <span class="keyword">public</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>  {
-<a name="l00070"></a>00070         <span class="keyword">protected</span>:
-<a name="l00071"></a>00071                 <a class="code" href="classeEmp.html" title="Weighted empirical density.">eEmp</a> &amp;E;
-<a name="l00072"></a>00072                 vec &amp;<a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a>;
-<a name="l00073"></a>00073                 Array&lt;const epdf*&gt; Coms;
-<a name="l00074"></a>00074         <span class="keyword">public</span>:
-<a name="l00075"></a>00075                 mpfepdf ( <a class="code" href="classeEmp.html" title="Weighted empirical density.">eEmp</a> &amp;E0, <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rvc ) :
-<a name="l00076"></a>00076                                 <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a>( ) ), E ( E0 ),  <a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a> ( E._w() ),
-<a name="l00077"></a>00077                                 Coms ( <a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a>.length() ) {
-<a name="l00078"></a>00078                         <a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a>.<a class="code" href="classRV.html#935790526b630dec4ffefa9ec0c2b6fb" title="Add (concat) another variable to the current one,.">add</a> ( E._rv() );
-<a name="l00079"></a>00079                         <a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a>.<a class="code" href="classRV.html#935790526b630dec4ffefa9ec0c2b6fb" title="Add (concat) another variable to the current one,.">add</a> ( rvc );
-<a name="l00080"></a>00080                 };
-<a name="l00081"></a>00081 
-<a name="l00082"></a>00082                 <span class="keywordtype">void</span> set_elements ( <span class="keywordtype">int</span> &amp;i, <span class="keywordtype">double</span> wi, <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* ep )
-<a name="l00083"></a>00083                 {<a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a> ( i ) =wi; Coms ( i ) =ep;};
-<a name="l00084"></a>00084 
-<a name="l00085"></a>00085                 vec mean()<span class="keyword"> const </span>{
-<a name="l00086"></a>00086                         <span class="comment">// ugly</span>
-<a name="l00087"></a>00087                         vec pom=zeros ( ( Coms ( 0 )-&gt;<a class="code" href="classBM.html#126bd2595c48e311fc2a7ab72876092a" title="access function">_rv</a>() ).count() );
-<a name="l00088"></a>00088 
-<a name="l00089"></a>00089                         <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i&lt;<a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a>.length(); i++ ) {pom += Coms ( i )-&gt;mean() * <a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a> ( i );}
-<a name="l00090"></a>00090 
+<a name="l00070"></a>00070 
+<a name="l00071"></a>00071 <span class="keyword">class </span>mpfepdf : <span class="keyword">public</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>  {
+<a name="l00072"></a>00072         <span class="keyword">protected</span>:
+<a name="l00073"></a>00073                 <a class="code" href="classeEmp.html" title="Weighted empirical density.">eEmp</a> &amp;E;
+<a name="l00074"></a>00074                 vec &amp;<a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a>;
+<a name="l00075"></a>00075                 Array&lt;const epdf*&gt; Coms;
+<a name="l00076"></a>00076         <span class="keyword">public</span>:
+<a name="l00077"></a>00077                 mpfepdf ( <a class="code" href="classeEmp.html" title="Weighted empirical density.">eEmp</a> &amp;E0, <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rvc ) :
+<a name="l00078"></a>00078                                 <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a>( ) ), E ( E0 ),  <a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a> ( E._w() ),
+<a name="l00079"></a>00079                                 Coms ( <a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a>.length() ) {
+<a name="l00080"></a>00080                         <a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a>.<a class="code" href="classRV.html#935790526b630dec4ffefa9ec0c2b6fb" title="Add (concat) another variable to the current one,.">add</a> ( E._rv() );
+<a name="l00081"></a>00081                         <a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a>.<a class="code" href="classRV.html#935790526b630dec4ffefa9ec0c2b6fb" title="Add (concat) another variable to the current one,.">add</a> ( rvc );
+<a name="l00082"></a>00082                 };
+<a name="l00083"></a>00083 
+<a name="l00084"></a>00084                 <span class="keywordtype">void</span> set_elements ( <span class="keywordtype">int</span> &amp;i, <span class="keywordtype">double</span> wi, <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* ep )
+<a name="l00085"></a>00085                 {<a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a> ( i ) =wi; Coms ( i ) =ep;};
+<a name="l00086"></a>00086 
+<a name="l00087"></a>00087                 vec mean()<span class="keyword"> const </span>{
+<a name="l00088"></a>00088                         <span class="comment">// ugly</span>
+<a name="l00089"></a>00089                         vec pom=zeros ( ( Coms ( 0 )-&gt;<a class="code" href="classBM.html#126bd2595c48e311fc2a7ab72876092a" title="access function">_rv</a>() ).count() );
+<a name="l00090"></a>00090                         <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i&lt;<a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a>.length(); i++ ) {pom += Coms ( i )-&gt;mean() * <a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a> ( i );}
 <a name="l00091"></a>00091                         <span class="keywordflow">return</span> <a class="code" href="group__core.html#g33c114e83980d883c5b211c47d5322a4" title="Concat two random variables.">concat</a> ( E.mean(),pom );
 <a name="l00092"></a>00092                 }
-<a name="l00093"></a>00093 
-<a name="l00094"></a>00094                 vec sample()<span class="keyword"> const </span>{it_error ( <span class="stringliteral">"Not implemented"</span> );<span class="keywordflow">return</span> 0;}
-<a name="l00095"></a>00095 
-<a name="l00096"></a>00096                 <span class="keywordtype">double</span> evallog ( <span class="keyword">const</span> vec &amp;val )<span class="keyword"> const </span>{it_error ( <span class="stringliteral">"not implemented"</span> ); <span class="keywordflow">return</span> 0.0;}
-<a name="l00097"></a>00097         };
-<a name="l00098"></a>00098 
-<a name="l00100"></a>00100         mpfepdf jest;
-<a name="l00101"></a>00101 
-<a name="l00102"></a>00102 <span class="keyword">public</span>:
-<a name="l00104"></a><a class="code" href="classMPF.html#fc5e11e11eec3195e3c6503937bf02bd">00104</a>         <a class="code" href="classMPF.html#fc5e11e11eec3195e3c6503937bf02bd" title="Default constructor.">MPF</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rvlin, <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rvpf, <a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> &amp;par0, <a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> &amp;obs0, <span class="keywordtype">int</span> <a class="code" href="classPF.html#2c2f44ed7a4eaa42e07bdb58d503f280" title="number of particles;">n</a>, <span class="keyword">const</span> BM_T &amp;BMcond0 ) : <a class="code" href="classPF.html" title="Trivial particle filter with proposal density equal to parameter evolution model...">PF</a> ( rvpf ,par0,obs0,n ),jest ( <a class="code" href="classPF.html#1a0a09e309da997f63ae8e30d1e9806b" title="posterior density">est</a>,rvlin ) {
-<a name="l00105"></a>00105                 <span class="comment">//</span>
-<a name="l00106"></a>00106                 <span class="comment">//TODO test if rv and BMcond.rv are compatible.</span>
-<a name="l00107"></a>00107                 <a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a>.<a class="code" href="classRV.html#935790526b630dec4ffefa9ec0c2b6fb" title="Add (concat) another variable to the current one,.">add</a> ( rvlin );
-<a name="l00108"></a>00108                 <span class="comment">//</span>
-<a name="l00109"></a>00109 
-<a name="l00110"></a>00110                 <span class="keywordflow">if</span> ( n&gt;10000 ) {it_error ( <span class="stringliteral">"increase 10000 here!"</span> );}
-<a name="l00111"></a>00111 
-<a name="l00112"></a>00112                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i&lt;n;i++ ) {
-<a name="l00113"></a>00113                         Bms[i] = <span class="keyword">new</span> BM_T ( BMcond0 ); <span class="comment">//copy constructor</span>
-<a name="l00114"></a>00114                         <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>&amp; pom=Bms[i]-&gt;_epdf();
-<a name="l00115"></a>00115                         jest.set_elements ( i,1.0/n,&amp;pom );
-<a name="l00116"></a>00116                 }
-<a name="l00117"></a>00117         };
+<a name="l00093"></a>00093                 vec variance()<span class="keyword"> const </span>{
+<a name="l00094"></a>00094                         <span class="comment">// ugly</span>
+<a name="l00095"></a>00095                         vec pom=zeros ( ( Coms ( 0 )-&gt;<a class="code" href="classBM.html#126bd2595c48e311fc2a7ab72876092a" title="access function">_rv</a>() ).count() );
+<a name="l00096"></a>00096                         vec pom2=zeros ( ( Coms ( 0 )-&gt;<a class="code" href="classBM.html#126bd2595c48e311fc2a7ab72876092a" title="access function">_rv</a>() ).count() );
+<a name="l00097"></a>00097                         <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i&lt;<a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a>.length(); i++ ) {
+<a name="l00098"></a>00098                                 pom += Coms ( i )-&gt;mean() * <a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a> ( i );
+<a name="l00099"></a>00099                                 pom2 += (Coms ( i )-&gt;variance() + pow(Coms(i)-&gt;mean(),2)) * <a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a> ( i );}
+<a name="l00100"></a>00100                         <span class="keywordflow">return</span> <a class="code" href="group__core.html#g33c114e83980d883c5b211c47d5322a4" title="Concat two random variables.">concat</a> ( E.variance(),pom2-pow(pom,2) );
+<a name="l00101"></a>00101                 }
+<a name="l00102"></a>00102 
+<a name="l00103"></a>00103                 vec sample()<span class="keyword"> const </span>{it_error ( <span class="stringliteral">"Not implemented"</span> );<span class="keywordflow">return</span> 0;}
+<a name="l00104"></a>00104 
+<a name="l00105"></a>00105                 <span class="keywordtype">double</span> evallog ( <span class="keyword">const</span> vec &amp;val )<span class="keyword"> const </span>{it_error ( <span class="stringliteral">"not implemented"</span> ); <span class="keywordflow">return</span> 0.0;}
+<a name="l00106"></a>00106         };
+<a name="l00107"></a>00107 
+<a name="l00109"></a>00109         mpfepdf jest;
+<a name="l00110"></a>00110 
+<a name="l00111"></a>00111 <span class="keyword">public</span>:
+<a name="l00113"></a><a class="code" href="classMPF.html#fc5e11e11eec3195e3c6503937bf02bd">00113</a>         <a class="code" href="classMPF.html#fc5e11e11eec3195e3c6503937bf02bd" title="Default constructor.">MPF</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rvlin, <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rvpf, <a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> &amp;par0, <a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> &amp;obs0, <span class="keywordtype">int</span> <a class="code" href="classPF.html#2c2f44ed7a4eaa42e07bdb58d503f280" title="number of particles;">n</a>, <span class="keyword">const</span> BM_T &amp;BMcond0 ) : <a class="code" href="classPF.html" title="Trivial particle filter with proposal density equal to parameter evolution model...">PF</a> ( rvpf ,par0,obs0,n ),jest ( <a class="code" href="classPF.html#1a0a09e309da997f63ae8e30d1e9806b" title="posterior density">est</a>,rvlin ) {
+<a name="l00114"></a>00114                 <span class="comment">//</span>
+<a name="l00115"></a>00115                 <span class="comment">//TODO test if rv and BMcond.rv are compatible.</span>
+<a name="l00116"></a>00116                 <a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a>.<a class="code" href="classRV.html#935790526b630dec4ffefa9ec0c2b6fb" title="Add (concat) another variable to the current one,.">add</a> ( rvlin );
+<a name="l00117"></a>00117                 <span class="comment">//</span>
 <a name="l00118"></a>00118 
-<a name="l00119"></a>00119         ~<a class="code" href="classMPF.html" title="Marginalized Particle filter.">MPF</a>() {
-<a name="l00120"></a>00120         }
-<a name="l00121"></a>00121 
-<a name="l00122"></a>00122         <span class="keywordtype">void</span> <a class="code" href="classMPF.html#55daf8e4b6553dd9f47c692de7931623" title="Incremental Bayes rule.">bayes</a> ( <span class="keyword">const</span> vec &amp;dt );
-<a name="l00123"></a><a class="code" href="classMPF.html#992e01bb8f06c814cda036796e4a55ae">00123</a>         <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>&amp; <a class="code" href="classMPF.html#992e01bb8f06c814cda036796e4a55ae" title="Returns a reference to the epdf representing posterior density on parameters.">_epdf</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> jest;}
-<a name="l00124"></a><a class="code" href="classMPF.html#942a1eb28a57ef0f0239264e7b0b82eb">00124</a>         <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* <a class="code" href="classMPF.html#942a1eb28a57ef0f0239264e7b0b82eb" title="Returns a pointer to the epdf representing posterior density on parameters. Use with...">_e</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> &amp;jest;} <span class="comment">//Fixme: is it useful?</span>
-<a name="l00126"></a><a class="code" href="classMPF.html#7c66e1c1c0e45fc4ae765133cb3a1553">00126</a> <span class="comment"></span>        <span class="keywordtype">void</span> <a class="code" href="classMPF.html#7c66e1c1c0e45fc4ae765133cb3a1553" title="Set postrior of rvc to samples from epdf0. Statistics of Bms are not re-computed!...">set_est</a> ( <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>&amp; epdf0 ) {
-<a name="l00127"></a>00127                 <a class="code" href="classPF.html#04d38fbcc0348b558212f530d9ec183e" title="Set posterior density by sampling from epdf0.">PF::set_est</a> ( epdf0 );  <span class="comment">// sample params in condition</span>
-<a name="l00128"></a>00128                 <span class="comment">// copy conditions to BMs</span>
-<a name="l00129"></a>00129 
-<a name="l00130"></a>00130                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i&lt;<a class="code" href="classPF.html#2c2f44ed7a4eaa42e07bdb58d503f280" title="number of particles;">n</a>;i++ ) {Bms[i]-&gt;condition ( <a class="code" href="classPF.html#cf7dad75e31215780a746c30e71ad9c5" title="pointer into eEmp ">_samples</a> ( i ) );}
-<a name="l00131"></a>00131         }
-<a name="l00132"></a>00132 
-<a name="l00133"></a>00133 <span class="comment">//SimStr:</span>
-<a name="l00134"></a>00134         <span class="keywordtype">double</span> SSAT;
-<a name="l00135"></a>00135 };
-<a name="l00136"></a>00136 
-<a name="l00137"></a>00137 <span class="keyword">template</span>&lt;<span class="keyword">class</span> BM_T&gt;
-<a name="l00138"></a><a class="code" href="classMPF.html#55daf8e4b6553dd9f47c692de7931623">00138</a> <span class="keywordtype">void</span> <a class="code" href="classMPF.html#55daf8e4b6553dd9f47c692de7931623" title="Incremental Bayes rule.">MPF&lt;BM_T&gt;::bayes</a> ( <span class="keyword">const</span> vec &amp;dt ) {
-<a name="l00139"></a>00139         <span class="keywordtype">int</span> i;
-<a name="l00140"></a>00140         vec lls ( <a class="code" href="classPF.html#2c2f44ed7a4eaa42e07bdb58d503f280" title="number of particles;">n</a> );
-<a name="l00141"></a>00141         vec llsP ( <a class="code" href="classPF.html#2c2f44ed7a4eaa42e07bdb58d503f280" title="number of particles;">n</a> );
-<a name="l00142"></a>00142         ivec ind;
-<a name="l00143"></a>00143         <span class="keywordtype">double</span> mlls=-std::numeric_limits&lt;double&gt;::infinity();
-<a name="l00144"></a>00144 
-<a name="l00145"></a>00145         <span class="comment">// StrSim:06</span>
-<a name="l00146"></a>00146         <span class="keywordtype">double</span> sumLWL=0.0;
-<a name="l00147"></a>00147         <span class="keywordtype">double</span> sumL2WL=0.0;
-<a name="l00148"></a>00148         <span class="keywordtype">double</span> WL = 0.0;
-<a name="l00149"></a>00149 
-<a name="l00150"></a>00150 <span class="preprocessor">        #pragma omp parallel for</span>
-<a name="l00151"></a>00151 <span class="preprocessor"></span>        <span class="keywordflow">for</span> ( i=0;i&lt;<a class="code" href="classPF.html#2c2f44ed7a4eaa42e07bdb58d503f280" title="number of particles;">n</a>;i++ ) {   
-<a name="l00152"></a>00152                 <span class="comment">//generate new samples from paramater evolution model;</span>
-<a name="l00153"></a>00153                 <a class="code" href="classPF.html#cf7dad75e31215780a746c30e71ad9c5" title="pointer into eEmp ">_samples</a> ( i ) = <a class="code" href="classPF.html#d92ac103f88f8c21e197e90af5695a09" title="Parameter evolution model.">par</a>.<a class="code" href="classmpdf.html#3f172b79ec4a5ebc87898a5381141f1b" title="Returns the required moment of the epdf.">samplecond</a> ( <a class="code" href="classPF.html#cf7dad75e31215780a746c30e71ad9c5" title="pointer into eEmp ">_samples</a> ( i ), llsP ( i ) );
-<a name="l00154"></a>00154                 Bms[i]-&gt;condition ( <a class="code" href="classPF.html#cf7dad75e31215780a746c30e71ad9c5" title="pointer into eEmp ">_samples</a> ( i ) );
-<a name="l00155"></a>00155                 Bms[i]-&gt;bayes ( dt );
-<a name="l00156"></a>00156                 lls ( i ) = Bms[i]-&gt;_ll(); <span class="comment">// lls above is also in proposal her must be lls(i) =, not +=!!</span>
-<a name="l00157"></a>00157                 <span class="keywordflow">if</span> ( lls ( i ) &gt;mlls ) mlls=lls ( i ); <span class="comment">//find maximum likelihood (for numerical stability)</span>
-<a name="l00158"></a>00158         }
-<a name="l00159"></a>00159 
-<a name="l00160"></a>00160         <span class="keywordflow">if</span> ( <span class="keyword">false</span>) {
-<a name="l00161"></a>00161 <span class="preprocessor">                #pragma omp parallel for reduction(+:sumLWL,sumL2WL) private(WL)</span>
-<a name="l00162"></a>00162 <span class="preprocessor"></span>                <span class="keywordflow">for</span> ( i=0;i&lt;n;i++ ) {
-<a name="l00163"></a>00163                         WL = <a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a> ( i ) *exp ( llsP ( i ) ); <span class="comment">//using old weights!</span>
-<a name="l00164"></a>00164                         sumLWL += exp ( lls ( i ) ) *WL;
-<a name="l00165"></a>00165                         sumL2WL += exp ( 2*lls ( i ) ) *WL;
-<a name="l00166"></a>00166                 }
-<a name="l00167"></a>00167                 SSAT  = sumL2WL/ ( sumLWL*sumLWL );
-<a name="l00168"></a>00168         }
-<a name="l00169"></a>00169 
-<a name="l00170"></a>00170         <span class="keywordtype">double</span> sum_w=0.0;
-<a name="l00171"></a>00171         <span class="comment">// compute weights</span>
-<a name="l00172"></a>00172 <span class="preprocessor">        #pragma omp parallel for</span>
-<a name="l00173"></a>00173 <span class="preprocessor"></span>        <span class="keywordflow">for</span> ( i=0;i&lt;n;i++ ) {
-<a name="l00174"></a>00174                 <a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a> ( i ) *= exp ( lls ( i ) - mlls ); <span class="comment">// multiply w by likelihood</span>
-<a name="l00175"></a>00175                 sum_w+=<a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a>(i);
+<a name="l00119"></a>00119                 <span class="keywordflow">if</span> ( n&gt;10000 ) {it_error ( <span class="stringliteral">"increase 10000 here!"</span> );}
+<a name="l00120"></a>00120 
+<a name="l00121"></a>00121                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i&lt;n;i++ ) {
+<a name="l00122"></a>00122                         Bms[i] = <span class="keyword">new</span> BM_T ( BMcond0 ); <span class="comment">//copy constructor</span>
+<a name="l00123"></a>00123                         <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>&amp; pom=Bms[i]-&gt;_epdf();
+<a name="l00124"></a>00124                         jest.set_elements ( i,1.0/n,&amp;pom );
+<a name="l00125"></a>00125                 }
+<a name="l00126"></a>00126         };
+<a name="l00127"></a>00127 
+<a name="l00128"></a>00128         ~<a class="code" href="classMPF.html" title="Marginalized Particle filter.">MPF</a>() {
+<a name="l00129"></a>00129         }
+<a name="l00130"></a>00130 
+<a name="l00131"></a>00131         <span class="keywordtype">void</span> <a class="code" href="classMPF.html#55daf8e4b6553dd9f47c692de7931623" title="Incremental Bayes rule.">bayes</a> ( <span class="keyword">const</span> vec &amp;dt );
+<a name="l00132"></a><a class="code" href="classMPF.html#992e01bb8f06c814cda036796e4a55ae">00132</a>         <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>&amp; <a class="code" href="classMPF.html#992e01bb8f06c814cda036796e4a55ae" title="Returns a reference to the epdf representing posterior density on parameters.">_epdf</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> jest;}
+<a name="l00133"></a><a class="code" href="classMPF.html#942a1eb28a57ef0f0239264e7b0b82eb">00133</a>         <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* <a class="code" href="classMPF.html#942a1eb28a57ef0f0239264e7b0b82eb" title="Returns a pointer to the epdf representing posterior density on parameters. Use with...">_e</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> &amp;jest;} <span class="comment">//Fixme: is it useful?</span>
+<a name="l00135"></a><a class="code" href="classMPF.html#7c66e1c1c0e45fc4ae765133cb3a1553">00135</a> <span class="comment"></span>        <span class="keywordtype">void</span> <a class="code" href="classMPF.html#7c66e1c1c0e45fc4ae765133cb3a1553" title="Set postrior of rvc to samples from epdf0. Statistics of Bms are not re-computed!...">set_est</a> ( <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>&amp; epdf0 ) {
+<a name="l00136"></a>00136                 <a class="code" href="classPF.html#04d38fbcc0348b558212f530d9ec183e" title="Set posterior density by sampling from epdf0.">PF::set_est</a> ( epdf0 );  <span class="comment">// sample params in condition</span>
+<a name="l00137"></a>00137                 <span class="comment">// copy conditions to BMs</span>
+<a name="l00138"></a>00138 
+<a name="l00139"></a>00139                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i&lt;<a class="code" href="classPF.html#2c2f44ed7a4eaa42e07bdb58d503f280" title="number of particles;">n</a>;i++ ) {Bms[i]-&gt;condition ( <a class="code" href="classPF.html#cf7dad75e31215780a746c30e71ad9c5" title="pointer into eEmp ">_samples</a> ( i ) );}
+<a name="l00140"></a>00140         }
+<a name="l00141"></a>00141 
+<a name="l00143"></a><a class="code" href="classMPF.html#82e7d8fd6bce040a78327d5038ab668f">00143</a>         <a class="code" href="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a>* <a class="code" href="classMPF.html#82e7d8fd6bce040a78327d5038ab668f" title="Access function.">_BM</a>(<span class="keywordtype">int</span> i){<span class="keywordflow">return</span> Bms[i];}
+<a name="l00144"></a>00144 };
+<a name="l00145"></a>00145 
+<a name="l00146"></a>00146 <span class="keyword">template</span>&lt;<span class="keyword">class</span> BM_T&gt;
+<a name="l00147"></a><a class="code" href="classMPF.html#55daf8e4b6553dd9f47c692de7931623">00147</a> <span class="keywordtype">void</span> <a class="code" href="classMPF.html#55daf8e4b6553dd9f47c692de7931623" title="Incremental Bayes rule.">MPF&lt;BM_T&gt;::bayes</a> ( <span class="keyword">const</span> vec &amp;dt ) {
+<a name="l00148"></a>00148         <span class="keywordtype">int</span> i;
+<a name="l00149"></a>00149         vec lls ( <a class="code" href="classPF.html#2c2f44ed7a4eaa42e07bdb58d503f280" title="number of particles;">n</a> );
+<a name="l00150"></a>00150         vec llsP ( <a class="code" href="classPF.html#2c2f44ed7a4eaa42e07bdb58d503f280" title="number of particles;">n</a> );
+<a name="l00151"></a>00151         ivec ind;
+<a name="l00152"></a>00152         <span class="keywordtype">double</span> mlls=-std::numeric_limits&lt;double&gt;::infinity();
+<a name="l00153"></a>00153 
+<a name="l00154"></a>00154 <span class="preprocessor">        #pragma omp parallel for</span>
+<a name="l00155"></a>00155 <span class="preprocessor"></span>        <span class="keywordflow">for</span> ( i=0;i&lt;<a class="code" href="classPF.html#2c2f44ed7a4eaa42e07bdb58d503f280" title="number of particles;">n</a>;i++ ) {   
+<a name="l00156"></a>00156                 <span class="comment">//generate new samples from paramater evolution model;</span>
+<a name="l00157"></a>00157                 <a class="code" href="classPF.html#cf7dad75e31215780a746c30e71ad9c5" title="pointer into eEmp ">_samples</a> ( i ) = <a class="code" href="classPF.html#d92ac103f88f8c21e197e90af5695a09" title="Parameter evolution model.">par</a>.<a class="code" href="classmpdf.html#3f172b79ec4a5ebc87898a5381141f1b" title="Returns a sample from the density conditioned on cond, .">samplecond</a> ( <a class="code" href="classPF.html#cf7dad75e31215780a746c30e71ad9c5" title="pointer into eEmp ">_samples</a> ( i ), llsP ( i ) );
+<a name="l00158"></a>00158                 Bms[i]-&gt;condition ( <a class="code" href="classPF.html#cf7dad75e31215780a746c30e71ad9c5" title="pointer into eEmp ">_samples</a> ( i ) );
+<a name="l00159"></a>00159                 Bms[i]-&gt;bayes ( dt );
+<a name="l00160"></a>00160                 lls ( i ) = Bms[i]-&gt;_ll(); <span class="comment">// lls above is also in proposal her must be lls(i) =, not +=!!</span>
+<a name="l00161"></a>00161                 <span class="keywordflow">if</span> ( lls ( i ) &gt;mlls ) mlls=lls ( i ); <span class="comment">//find maximum likelihood (for numerical stability)</span>
+<a name="l00162"></a>00162         }
+<a name="l00163"></a>00163 
+<a name="l00164"></a>00164         <span class="keywordtype">double</span> sum_w=0.0;
+<a name="l00165"></a>00165         <span class="comment">// compute weights</span>
+<a name="l00166"></a>00166 <span class="preprocessor">        #pragma omp parallel for</span>
+<a name="l00167"></a>00167 <span class="preprocessor"></span>        <span class="keywordflow">for</span> ( i=0;i&lt;n;i++ ) {
+<a name="l00168"></a>00168                 <a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a> ( i ) *= exp ( lls ( i ) - mlls ); <span class="comment">// multiply w by likelihood</span>
+<a name="l00169"></a>00169                 sum_w+=<a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a>(i);
+<a name="l00170"></a>00170         }
+<a name="l00171"></a>00171 
+<a name="l00172"></a>00172         <span class="keywordflow">if</span> ( sum_w  &gt;0.0 ) {
+<a name="l00173"></a>00173                 <a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a> /=sum_w; <span class="comment">//?</span>
+<a name="l00174"></a>00174         } <span class="keywordflow">else</span> {
+<a name="l00175"></a>00175                 cout&lt;&lt;<span class="stringliteral">"sum(w)==0"</span>&lt;&lt;endl;
 <a name="l00176"></a>00176         }
 <a name="l00177"></a>00177 
-<a name="l00178"></a>00178         <span class="keywordflow">if</span> ( sum_w  &gt;0.0 ) {
-<a name="l00179"></a>00179                 <a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a> /=sum_w; <span class="comment">//?</span>
-<a name="l00180"></a>00180         } <span class="keywordflow">else</span> {
-<a name="l00181"></a>00181                 cout&lt;&lt;<span class="stringliteral">"sum(w)==0"</span>&lt;&lt;endl;
-<a name="l00182"></a>00182         }
+<a name="l00178"></a>00178 
+<a name="l00179"></a>00179         <span class="keywordtype">double</span> eff = 1.0/ ( <a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a>*<a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a> );
+<a name="l00180"></a>00180         <span class="keywordflow">if</span> ( eff &lt; ( 0.3*n ) ) {
+<a name="l00181"></a>00181                 ind = <a class="code" href="classPF.html#1a0a09e309da997f63ae8e30d1e9806b" title="posterior density">est</a>.<a class="code" href="classeEmp.html#77268292fc4465cb73ddbfb1f2932a59" title="Function performs resampling, i.e. removal of low-weight samples and duplication...">resample</a>();
+<a name="l00182"></a>00182                 <span class="comment">// Resample Bms!</span>
 <a name="l00183"></a>00183 
-<a name="l00184"></a>00184 
-<a name="l00185"></a>00185         <span class="keywordtype">double</span> eff = 1.0/ ( <a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a>*<a class="code" href="classPF.html#5c87aba508df321ff26536ced64dbb3a" title="pointer into eEmp ">_w</a> );
-<a name="l00186"></a>00186         <span class="keywordflow">if</span> ( eff &lt; ( 0.3*n ) ) {
-<a name="l00187"></a>00187                 ind = <a class="code" href="classPF.html#1a0a09e309da997f63ae8e30d1e9806b" title="posterior density">est</a>.<a class="code" href="classeEmp.html#77268292fc4465cb73ddbfb1f2932a59" title="Function performs resampling, i.e. removal of low-weight samples and duplication...">resample</a>();
-<a name="l00188"></a>00188                 <span class="comment">// Resample Bms!</span>
+<a name="l00184"></a>00184 <span class="preprocessor">                #pragma omp parallel for</span>
+<a name="l00185"></a>00185 <span class="preprocessor"></span>                <span class="keywordflow">for</span> ( i=0;i&lt;n;i++ ) {
+<a name="l00186"></a>00186                         <span class="keywordflow">if</span> ( ind ( i ) !=i ) {<span class="comment">//replace the current Bm by a new one</span>
+<a name="l00187"></a>00187                                 <span class="comment">//fixme this would require new assignment operator</span>
+<a name="l00188"></a>00188                                 <span class="comment">// *Bms[i] = *Bms[ind ( i ) ];</span>
 <a name="l00189"></a>00189 
-<a name="l00190"></a>00190 <span class="preprocessor">                #pragma omp parallel for</span>
-<a name="l00191"></a>00191 <span class="preprocessor"></span>                <span class="keywordflow">for</span> ( i=0;i&lt;n;i++ ) {
-<a name="l00192"></a>00192                         <span class="keywordflow">if</span> ( ind ( i ) !=i ) {<span class="comment">//replace the current Bm by a new one</span>
-<a name="l00193"></a>00193                                 <span class="comment">//fixme this would require new assignment operator</span>
-<a name="l00194"></a>00194                                 <span class="comment">// *Bms[i] = *Bms[ind ( i ) ];</span>
-<a name="l00195"></a>00195 
-<a name="l00196"></a>00196                                 <span class="comment">// poor-man's solution: replicate constructor here</span>
-<a name="l00197"></a>00197                                 <span class="comment">// copied from MPF::MPF</span>
-<a name="l00198"></a>00198                                 <span class="keyword">delete</span> Bms[i];
-<a name="l00199"></a>00199                                 Bms[i] = <span class="keyword">new</span> BM_T ( *Bms[ind ( i ) ] ); <span class="comment">//copy constructor</span>
-<a name="l00200"></a>00200                                 <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>&amp; pom=Bms[i]-&gt;_epdf();
-<a name="l00201"></a>00201                                 jest.set_elements ( i,1.0/n,&amp;pom );
-<a name="l00202"></a>00202                         }
-<a name="l00203"></a>00203                 };
-<a name="l00204"></a>00204                 cout &lt;&lt; <span class="charliteral">'.'</span>;
-<a name="l00205"></a>00205         }
-<a name="l00206"></a>00206 }
-<a name="l00207"></a>00207 
-<a name="l00208"></a>00208 <span class="preprocessor">#endif // KF_H</span>
-<a name="l00209"></a>00209 <span class="preprocessor"></span>
-<a name="l00210"></a>00210 
+<a name="l00190"></a>00190                                 <span class="comment">// poor-man's solution: replicate constructor here</span>
+<a name="l00191"></a>00191                                 <span class="comment">// copied from MPF::MPF</span>
+<a name="l00192"></a>00192                                 <span class="keyword">delete</span> Bms[i];
+<a name="l00193"></a>00193                                 Bms[i] = <span class="keyword">new</span> BM_T ( *Bms[ind ( i ) ] ); <span class="comment">//copy constructor</span>
+<a name="l00194"></a>00194                                 <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>&amp; pom=Bms[i]-&gt;_epdf();
+<a name="l00195"></a>00195                                 jest.set_elements ( i,1.0/n,&amp;pom );
+<a name="l00196"></a>00196                         }
+<a name="l00197"></a>00197                 };
+<a name="l00198"></a>00198                 cout &lt;&lt; <span class="charliteral">'.'</span>;
+<a name="l00199"></a>00199         }
+<a name="l00200"></a>00200 }
+<a name="l00201"></a>00201 
+<a name="l00202"></a>00202 <span class="preprocessor">#endif // KF_H</span>
+<a name="l00203"></a>00203 <span class="preprocessor"></span>
+<a name="l00204"></a>00204 
 </pre></div></div>
-<hr size="1"><address style="text-align: right;"><small>Generated on Mon Jan 5 19:29:09 2009 for mixpp by&nbsp;
+<hr size="1"><address style="text-align: right;"><small>Generated on Thu Jan 15 10:50:25 2009 for mixpp by&nbsp;
 <a href="http://www.doxygen.org/index.html">
 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
