Changeset 354 for doc/html/libPF_8h-source.html
- Timestamp:
- 06/02/09 10:24:26 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
doc/html/libPF_8h-source.html
r353 r354 77 77 <a name="l00032"></a><a class="code" href="classbdm_1_1PF.html#dc049265b9086cad7071f98d00a2b9af">00032</a> <a class="code" href="classbdm_1_1eEmp.html" title="Weighted empirical density.">eEmp</a> <a class="code" href="classbdm_1_1PF.html#dc049265b9086cad7071f98d00a2b9af" title="posterior density">est</a>; 78 78 <a name="l00034"></a><a class="code" href="classbdm_1_1PF.html#f5149d5522d1095d39240c4c607f61a3">00034</a> vec &<a class="code" href="classbdm_1_1PF.html#f5149d5522d1095d39240c4c607f61a3" title="pointer into eEmp ">_w</a>; 79 <a name="l00036"></a><a class="code" href="classbdm_1_1PF.html#914bd66025692c4018dbd482cb3c47c1">00036</a> <a class="code" href="classitpp_1_1Array.html">Array<vec></a>&<a class="code" href="classbdm_1_1PF.html#914bd66025692c4018dbd482cb3c47c1" title="pointer into eEmp ">_samples</a>;79 <a name="l00036"></a><a class="code" href="classbdm_1_1PF.html#914bd66025692c4018dbd482cb3c47c1">00036</a> Array<vec> &<a class="code" href="classbdm_1_1PF.html#914bd66025692c4018dbd482cb3c47c1" title="pointer into eEmp ">_samples</a>; 80 80 <a name="l00038"></a><a class="code" href="classbdm_1_1PF.html#521e9621d3b5e1274275f323691afdaf">00038</a> <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> *<a class="code" href="classbdm_1_1PF.html#521e9621d3b5e1274275f323691afdaf" title="Parameter evolution model.">par</a>; 81 81 <a name="l00040"></a><a class="code" href="classbdm_1_1PF.html#d6e7a62fba1e0a0d73c9b87f4fb683ec">00040</a> <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> *<a class="code" href="classbdm_1_1PF.html#d6e7a62fba1e0a0d73c9b87f4fb683ec" title="Observation model.">obs</a>; … … 107 107 <a name="l00083"></a>00083 <span class="keyword">template</span><<span class="keyword">class</span> BM_T> 108 108 <a name="l00084"></a><a class="code" href="classbdm_1_1MPF.html">00084</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1MPF.html" title="Marginalized Particle filter.">MPF</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1PF.html" title="Trivial particle filter with proposal density equal to parameter evolution model...">PF</a> { 109 <a name="l00085"></a>00085 <a class="code" href="classitpp_1_1Array.html">Array<BM_T*></a>BMs;109 <a name="l00085"></a>00085 Array<BM_T*> BMs; 110 110 <a name="l00086"></a>00086 111 111 <a name="l00088"></a>00088 … … 114 114 <a name="l00091"></a>00091 <a class="code" href="classbdm_1_1eEmp.html" title="Weighted empirical density.">eEmp</a> &E; 115 115 <a name="l00092"></a>00092 vec &<a class="code" href="classbdm_1_1PF.html#f5149d5522d1095d39240c4c607f61a3" title="pointer into eEmp ">_w</a>; 116 <a name="l00093"></a>00093 <a class="code" href="classitpp_1_1Array.html">Array<const epdf*></a>Coms;116 <a name="l00093"></a>00093 Array<const epdf*> Coms; 117 117 <a name="l00094"></a>00094 <span class="keyword">public</span>: 118 118 <a name="l00095"></a>00095 mpfepdf ( <a class="code" href="classbdm_1_1eEmp.html" title="Weighted empirical density.">eEmp</a> &E0 ) : … … 120 120 <a name="l00097"></a>00097 Coms ( <a class="code" href="classbdm_1_1PF.html#f5149d5522d1095d39240c4c607f61a3" title="pointer into eEmp ">_w</a>.length() ) { 121 121 <a name="l00098"></a>00098 }; 122 <a name="l00100"></a>00100 <span class="keywordtype">void</span> read_statistics ( <a class="code" href="classitpp_1_1Array.html">Array<BM_T*></a>&A ) {122 <a name="l00100"></a>00100 <span class="keywordtype">void</span> read_statistics ( Array<BM_T*> &A ) { 123 123 <a name="l00101"></a>00101 dim = E.dimension() +A ( 0 )->posterior().dimension(); 124 124 <a name="l00102"></a>00102 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i<<a class="code" href="classbdm_1_1PF.html#f5149d5522d1095d39240c4c607f61a3" title="pointer into eEmp ">_w</a>.length() ;i++ ) {Coms ( i ) = A ( i )->_e();} … … 128 128 <a name="l00107"></a>00107 129 129 <a name="l00108"></a>00108 <span class="keywordtype">void</span> set_parameters ( <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1PF.html#eeafaf9b8ad75fe62ee9fd6369e3f7fe" title="number of particles;">n</a> ) { 130 <a name="l00109"></a>00109 E. set_parameters( n, <span class="keyword">false</span> );130 <a name="l00109"></a>00109 E.<a class="code" href="classbdm_1_1epdf.html#840de94aa33cf4f2ebd2427f45a165d8">set_parameters</a> ( n, <span class="keyword">false</span> ); 131 131 <a name="l00110"></a>00110 Coms.set_length ( n ); 132 132 <a name="l00111"></a>00111 } 133 <a name="l00112"></a>00112 vec <a class="code" href="group__statistics.html#gc370b4cfdc6baa037b7442ae6e2c4b5c" title="The mean value.">mean</a>()<span class="keyword"> const </span>{133 <a name="l00112"></a>00112 vec mean()<span class="keyword"> const </span>{ 134 134 <a name="l00113"></a>00113 <span class="comment">// ugly</span> 135 <a name="l00114"></a>00114 vec pom= <a class="code" href="group__specmat.html#g10723ecada06221cbe64fe2736a59de1" title="A Double (rows,cols)-matrix of zeros.">zeros</a>( Coms ( 0 )->dimension() );135 <a name="l00114"></a>00114 vec pom=zeros ( Coms ( 0 )->dimension() ); 136 136 <a name="l00115"></a>00115 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i<<a class="code" href="classbdm_1_1PF.html#f5149d5522d1095d39240c4c607f61a3" title="pointer into eEmp ">_w</a>.length(); i++ ) {pom += Coms ( i )->mean() * <a class="code" href="classbdm_1_1PF.html#f5149d5522d1095d39240c4c607f61a3" title="pointer into eEmp ">_w</a> ( i );} 137 137 <a name="l00116"></a>00116 <span class="keywordflow">return</span> concat ( E.mean(),pom ); 138 138 <a name="l00117"></a>00117 } 139 <a name="l00118"></a>00118 vec <a class="code" href="group__statistics.html#g7a4799948ff9779eaeecabde0ce5fcbb" title="The variance of the elements in the vector. Normalized with N-1 to be unbiased.">variance</a>()<span class="keyword"> const </span>{139 <a name="l00118"></a>00118 vec variance()<span class="keyword"> const </span>{ 140 140 <a name="l00119"></a>00119 <span class="comment">// ugly</span> 141 <a name="l00120"></a>00120 vec pom= <a class="code" href="group__specmat.html#g10723ecada06221cbe64fe2736a59de1" title="A Double (rows,cols)-matrix of zeros.">zeros</a>( Coms ( 0 )->dimension() );142 <a name="l00121"></a>00121 vec pom2= <a class="code" href="group__specmat.html#g10723ecada06221cbe64fe2736a59de1" title="A Double (rows,cols)-matrix of zeros.">zeros</a>( Coms ( 0 )->dimension() );141 <a name="l00120"></a>00120 vec pom=zeros ( Coms ( 0 )->dimension() ); 142 <a name="l00121"></a>00121 vec pom2=zeros ( Coms ( 0 )->dimension() ); 143 143 <a name="l00122"></a>00122 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i<<a class="code" href="classbdm_1_1PF.html#f5149d5522d1095d39240c4c607f61a3" title="pointer into eEmp ">_w</a>.length(); i++ ) { 144 144 <a name="l00123"></a>00123 pom += Coms ( i )->mean() * <a class="code" href="classbdm_1_1PF.html#f5149d5522d1095d39240c4c607f61a3" title="pointer into eEmp ">_w</a> ( i ); 145 <a name="l00124"></a>00124 pom2 += ( Coms ( i )->variance() + <a class="code" href="group__logexpfunc.html#g40f48a75172e7f8bc8e58ed54262a04d" title="Calculates x to the power of y (x^y).">pow</a> ( Coms ( i )-><a class="code" href="group__statistics.html#gc370b4cfdc6baa037b7442ae6e2c4b5c" title="The mean value.">mean</a>(),2 ) ) * <a class="code" href="classbdm_1_1PF.html#f5149d5522d1095d39240c4c607f61a3" title="pointer into eEmp ">_w</a> ( i );145 <a name="l00124"></a>00124 pom2 += ( Coms ( i )->variance() + pow ( Coms ( i )->mean(),2 ) ) * <a class="code" href="classbdm_1_1PF.html#f5149d5522d1095d39240c4c607f61a3" title="pointer into eEmp ">_w</a> ( i ); 146 146 <a name="l00125"></a>00125 } 147 <a name="l00126"></a>00126 <span class="keywordflow">return</span> concat ( E.variance(),pom2- <a class="code" href="group__logexpfunc.html#g40f48a75172e7f8bc8e58ed54262a04d" title="Calculates x to the power of y (x^y).">pow</a>( pom,2 ) );147 <a name="l00126"></a>00126 <span class="keywordflow">return</span> concat ( E.variance(),pom2-pow ( pom,2 ) ); 148 148 <a name="l00127"></a>00127 } 149 149 <a name="l00128"></a>00128 <span class="keywordtype">void</span> qbounds ( vec &lb, vec &ub, <span class="keywordtype">double</span> perc=0.95 )<span class="keyword"> const </span>{ … … 177 177 <a name="l00156"></a>00156 } 178 178 <a name="l00157"></a>00157 179 <a name="l00158"></a>00158 vec sample()<span class="keyword"> const </span>{ <a class="code" href="group__errorhandlingfunc.html#g22d38e98332f9edff88cc501463eedce" title="Abort unconditionally.">it_error</a>( <span class="stringliteral">"Not implemented"</span> );<span class="keywordflow">return</span> 0;}179 <a name="l00158"></a>00158 vec sample()<span class="keyword"> const </span>{it_error ( <span class="stringliteral">"Not implemented"</span> );<span class="keywordflow">return</span> 0;} 180 180 <a name="l00159"></a>00159 181 <a name="l00160"></a>00160 <span class="keywordtype">double</span> evallog ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{ <a class="code" href="group__errorhandlingfunc.html#g22d38e98332f9edff88cc501463eedce" title="Abort unconditionally.">it_error</a>( <span class="stringliteral">"not implemented"</span> ); <span class="keywordflow">return</span> 0.0;}181 <a name="l00160"></a>00160 <span class="keywordtype">double</span> evallog ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{it_error ( <span class="stringliteral">"not implemented"</span> ); <span class="keywordflow">return</span> 0.0;} 182 182 <a name="l00161"></a>00161 }; 183 183 <a name="l00162"></a>00162 … … 191 191 <a name="l00173"></a>00173 PF::set_parameters ( par0, obs0, n0, rm ); 192 192 <a name="l00174"></a>00174 jest.set_parameters ( n0 );<span class="comment">//duplication of rm</span> 193 <a name="l00175"></a>00175 BMs. <a class="code" href="classitpp_1_1Array.html#3709407656d26aae2c5d3e844316d4e0" title="Resizing an Array&lt;T&gt;.">set_length</a>( n0 );193 <a name="l00175"></a>00175 BMs.set_length ( n0 ); 194 194 <a name="l00176"></a>00176 } 195 195 <a name="l00177"></a>00177 <span class="keywordtype">void</span> set_statistics ( epdf *epdf0, <span class="keyword">const</span> BM_T* BMcond0 ) { 196 196 <a name="l00178"></a>00178 197 <a name="l00179"></a>00179 PF::set_statistics ( <a class="code" href="group__specmat.html#gdc0f3edbf58bced9e82d8b260d395cac" title="A float (rows,cols)-matrix of ones.">ones</a>( <a class="code" href="classbdm_1_1PF.html#eeafaf9b8ad75fe62ee9fd6369e3f7fe" title="number of particles;">n</a> ) /<a class="code" href="classbdm_1_1PF.html#eeafaf9b8ad75fe62ee9fd6369e3f7fe" title="number of particles;">n</a>, epdf0 );197 <a name="l00179"></a>00179 PF::set_statistics ( ones ( <a class="code" href="classbdm_1_1PF.html#eeafaf9b8ad75fe62ee9fd6369e3f7fe" title="number of particles;">n</a> ) /<a class="code" href="classbdm_1_1PF.html#eeafaf9b8ad75fe62ee9fd6369e3f7fe" title="number of particles;">n</a>, epdf0 ); 198 198 <a name="l00180"></a>00180 <span class="comment">// copy</span> 199 199 <a name="l00181"></a>00181 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1PF.html#eeafaf9b8ad75fe62ee9fd6369e3f7fe" title="number of particles;">n</a>;i++ ) { BMs ( i ) = <span class="keyword">new</span> BM_T ( *BMcond0 ); BMs ( i )->condition ( <a class="code" href="classbdm_1_1PF.html#914bd66025692c4018dbd482cb3c47c1" title="pointer into eEmp ">_samples</a> ( i ) );} … … 243 243 <a name="l00227"></a>00227 <span class="preprocessor">#pragma omp parallel for</span> 244 244 <a name="l00228"></a>00228 <span class="preprocessor"></span> <span class="keywordflow">for</span> ( i=0;i<n;i++ ) { 245 <a name="l00229"></a>00229 <a class="code" href="classbdm_1_1PF.html#f5149d5522d1095d39240c4c607f61a3" title="pointer into eEmp ">_w</a> ( i ) *= <a class="code" href="group__logexpfunc.html#g7a3da29d4e6a8c814237453086793335" title="Exp of the elements of a complex matrix m.">exp</a>( lls ( i ) - mlls ); <span class="comment">// multiply w by likelihood</span>245 <a name="l00229"></a>00229 <a class="code" href="classbdm_1_1PF.html#f5149d5522d1095d39240c4c607f61a3" title="pointer into eEmp ">_w</a> ( i ) *= exp ( lls ( i ) - mlls ); <span class="comment">// multiply w by likelihood</span> 246 246 <a name="l00230"></a>00230 sum_w+=<a class="code" href="classbdm_1_1PF.html#f5149d5522d1095d39240c4c607f61a3" title="pointer into eEmp ">_w</a> ( i ); 247 247 <a name="l00231"></a>00231 } … … 283 283 <a name="l00267"></a>00267 284 284 </pre></div></div> 285 <hr size="1"><address style="text-align: right;"><small>Generated on Tue Jun 2 10: 02:122009 for mixpp by 285 <hr size="1"><address style="text-align: right;"><small>Generated on Tue Jun 2 10:11:00 2009 for mixpp by 286 286 <a href="http://www.doxygen.org/index.html"> 287 287 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>