📄 sirflt_8hpp-source.html
字号:
<a name="l00142"></a><a class="code" href="classBayesian__filter_1_1Sampled__general__predict__model.html#a2">00142</a> <span class="keywordtype">void</span> <a class="code" href="classBayesian__filter_1_1Sampled__general__predict__model.html#a2">init_GqG</a>() <span class="keyword">const</span>00143 <span class="comment">/* initialise predict given a change to q,G</span>00144 <span class="comment"> * Implementation: Update rootq</span>00145 <span class="comment"> */</span>00146 {00147 first_init = <span class="keyword">false</span>;00148 <span class="keywordflow">for</span> (FM::Vec::const_iterator qi = this->q.begin(); qi != this->q.end(); ++qi) {00149 <span class="keywordflow">if</span> (*qi < 0.)00150 <a class="code" href="classBayesian__filter_1_1Bayes__base.html#e0">error</a> (<a class="code" href="classBayesian__filter_1_1Numeric__exception.html">Numeric_exception</a>(<span class="stringliteral">"Negative q in init_GqG"</span>));00151 rootq[qi.index()] = std::sqrt(*qi);00152 }00153 }00154 <span class="keyword">private</span>:00155 SIR_random& genn;00156 <span class="keyword">mutable</span> FM::Vec xp;00157 <span class="keyword">mutable</span> FM::DenseVec n;00158 <span class="keyword">mutable</span> FM::Vec rootq; <span class="comment">// Optimisation of sqrt(q) calculation, automatic on first use</span>00159 <span class="keyword">mutable</span> <span class="keywordtype">bool</span> first_init; 00160 };00161 <a name="l00162"></a><a class="code" href="namespaceBayesian__filter.html#a1">00162</a> <span class="keyword">typedef</span> <a class="code" href="classBayesian__filter_1_1Sampled__general__predict__model.html">Sampled_general_predict_model<Linear_predict_model></a> <a class="code" href="namespaceBayesian__filter.html#a1">Sampled_LiAd_predict_model</a>;<a name="l00163"></a><a class="code" href="namespaceBayesian__filter.html#a2">00163</a> <span class="keyword">typedef</span> <a class="code" href="classBayesian__filter_1_1Sampled__general__predict__model.html">Sampled_general_predict_model<Linear_invertable_predict_model></a> <a class="code" href="namespaceBayesian__filter.html#a2">Sampled_LiInAd_predict_model</a>;00164 <span class="comment">// Sampled predict model generalisations</span>00165 <span class="comment">// Names a shortened to first two letters of their model properties</span>00166 00167 00168 <a name="l00169"></a><a class="code" href="classBayesian__filter_1_1SIR__scheme.html">00169</a> <span class="keyword">class </span><a class="code" href="classBayesian__filter_1_1SIR__scheme.html">SIR_scheme</a> : <span class="keyword">public</span> <a class="code" href="classBayesian__filter_1_1Sample__filter.html">Sample_filter</a>00170 <span class="comment">/*</span>00171 <span class="comment"> * Sampling Importance Resampleing Filter Scheme.</span>00172 <span class="comment"> * Implement a general form of SIR filter</span>00173 <span class="comment"> * Importance resampling is delayed until an update is required. The sampler used</span>00174 <span class="comment"> * is a parameter of update to allow a wide variety of usage.</span>00175 <span class="comment"> * A stochastic sample is defined as a sample with a unqiue stochastic history other then roughening</span>00176 <span class="comment"> */</span>00177 {<a name="l00178"></a><a class="code" href="classBayesian__filter_1_1SIR__scheme.html#n0">00178</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classBayesian__filter_1_1SIR__kalman__scheme.html">SIR_kalman_scheme</a>;00179 <span class="keyword">public</span>:<a name="l00180"></a><a class="code" href="classBayesian__filter_1_1SIR__scheme.html#o0">00180</a> size_t <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#o0">stochastic_samples</a>; <span class="comment">// Number of stochastic samples in S</span>00181 00182 <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#a0">SIR_scheme</a> (size_t x_size, size_t s_size, <a class="code" href="structBayesian__filter_1_1SIR__random.html">SIR_random</a>& random_helper);00183 <a class="code" href="classBayesian__filter_1_1SIR__scheme.html">SIR_scheme</a>& <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#a1">operator= </a>(<span class="keyword">const</span> <a class="code" href="classBayesian__filter_1_1SIR__scheme.html">SIR_scheme</a>&);00184 <span class="comment">// Optimise copy assignment to only copy filter state</span>00185 00186 <span class="comment">/* Specialisations for filter algorithm */</span>00187 <span class="keywordtype">void</span> <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#a2">init_S</a> ();00188 <a name="l00189"></a><a class="code" href="classBayesian__filter_1_1SIR__scheme.html#a3">00189</a> <a class="code" href="classBayesian__filter_1_1Bayes__base.html#w0">Float</a> <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#a3">update_resample</a> ()00190 <span class="comment">// Default resampling update</span>00191 { <span class="keywordflow">return</span> <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#a3">update_resample</a> (<a class="code" href="classBayesian__filter_1_1Standard__resampler.html">Standard_resampler</a>());00192 }00193 00194 <span class="keyword">virtual</span> <a class="code" href="classBayesian__filter_1_1Bayes__base.html#w0">Float</a> <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#a3">update_resample</a> (<span class="keyword">const</span> Importance_resampler& resampler);00195 <span class="comment">/* Update: resample particles using weights and then roughen</span>00196 <span class="comment"> * Return: lcond</span>00197 <span class="comment"> */</span>00198 <a name="l00199"></a><a class="code" href="classBayesian__filter_1_1SIR__scheme.html#a5">00199</a> <span class="keywordtype">void</span> <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#a5">predict</a> (<a class="code" href="classBayesian__filter_1_1Functional__predict__model.html">Functional_predict_model</a>& f)00200 <span class="comment">// Predict samples without noise</span>00201 { Sample_filter::predict (f);00202 }00203 <span class="keywordtype">void</span> <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#a5">predict</a> (Sampled_predict_model& f);00204 <span class="comment">// Predict samples with noise model</span>00205 00206 <span class="keywordtype">void</span> <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#a7">observe</a> (Likelihood_observe_model& h, <span class="keyword">const</span> FM::Vec& z);00207 <span class="comment">// Weight particles using likelihood model h and z</span>00208 00209 <span class="keywordtype">void</span> <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#a8">observe_likelihood</a> (<span class="keyword">const</span> FM::Vec& lw);00210 <span class="comment">// Observation fusion directly from likelihood weights</span>00211 <a name="l00212"></a><a class="code" href="classBayesian__filter_1_1SIR__scheme.html#o1">00212</a> <a class="code" href="classBayesian__filter_1_1Bayes__base.html#w0">Float</a> <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#o1">rougheningK</a>; <span class="comment">// Current roughening value (0 implies no roughening)</span><a name="l00213"></a><a class="code" href="classBayesian__filter_1_1SIR__scheme.html#a9">00213</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#a9">roughen</a>()00214 <span class="comment">// Generalised roughening: Default to roughen_minmax</span>00215 {00216 <span class="keywordflow">if</span> (<a class="code" href="classBayesian__filter_1_1SIR__scheme.html#o1">rougheningK</a> != 0.)00217 <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#b0">roughen_minmax</a> (<a class="code" href="classBayesian__filter_1_1Sample__state__filter.html#o0">S</a>, <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#o1">rougheningK</a>);00218 }00219 00220 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#e0">copy_resamples</a> (FM::ColMatrix& P, <span class="keyword">const</span> Importance_resampler::Resamples_t& presamples);00221 <span class="comment">// Update P by selectively copying based on presamples </span>00222 <a name="l00223"></a><a class="code" href="classBayesian__filter_1_1SIR__scheme.html#o2">00223</a> <a class="code" href="structBayesian__filter_1_1SIR__random.html">SIR_random</a>& <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#o2">random</a>; <span class="comment">// Reference random number generator helper</span>00224 00225 <span class="keyword">protected</span>:00226 <span class="keywordtype">void</span> <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#b0">roughen_minmax</a> (FM::ColMatrix& P, Float K) <span class="keyword">const</span>; <span class="comment">// roughening using minmax of P distribution</span><a name="l00227"></a><a class="code" href="classBayesian__filter_1_1SIR__scheme.html#p0">00227</a> Importance_resampler::Resamples_t <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#p0">resamples</a>; <span class="comment">// resampling counts</span><a name="l00228"></a><a class="code" href="classBayesian__filter_1_1SIR__scheme.html#p1">00228</a> FM::DenseVec <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#p1">wir</a>; <span class="comment">// resamping weights</span><a name="l00229"></a><a class="code" href="classBayesian__filter_1_1SIR__scheme.html#p2">00229</a> <span class="keywordtype">bool</span> <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#p2">wir_update</a>; <span class="comment">// weights have been updated requring a resampling on update</span>00230 <span class="keyword">private</span>:00231 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classBayesian__filter_1_1Bayes__base.html#w0">Float</a> rougheningKinit;00232 size_t x_size;00233 };00234 00235 <a name="l00236"></a><a class="code" href="classBayesian__filter_1_1SIR__kalman__scheme.html">00236</a> <span class="keyword">class </span><a class="code" href="classBayesian__filter_1_1SIR__kalman__scheme.html">SIR_kalman_scheme</a> : <span class="keyword">public</span> <a class="code" href="classBayesian__filter_1_1SIR__scheme.html">SIR_scheme</a>, <span class="keyword">virtual</span> <span class="keyword">public</span> <a class="code" href="classBayesian__filter_1_1Kalman__state__filter.html">Kalman_state_filter</a>00237 <span class="comment">/*</span>00238 <span class="comment"> * SIR implementation of a Kalman filter</span>00239 <span class="comment"> * Updates Kalman statistics of SIR_filter</span>00240 <span class="comment"> * These statistics are use to provide a specialised correlated roughening procedure</span>00241 <span class="comment"> */</span>00242 {00243 <span class="keyword">public</span>:00244 <a class="code" href="classBayesian__filter_1_1SIR__kalman__scheme.html#a0">SIR_kalman_scheme</a> (size_t x_size, size_t s_size, <a class="code" href="structBayesian__filter_1_1SIR__random.html">SIR_random</a>& random_helper);00245 00246 <span class="comment">/* Specialisations for filter algorithm */</span>00247 00248 <span class="keywordtype">void</span> <a class="code" href="classBayesian__filter_1_1SIR__kalman__scheme.html#a1">init</a> ();00249 <a name="l00250"></a><a class="code" href="classBayesian__filter_1_1SIR__kalman__scheme.html#a2">00250</a> <span class="keywordtype">void</span> <a class="code" href="classBayesian__filter_1_1SIR__kalman__scheme.html#a2">update</a> ()00251 <span class="comment">// Implement Kalman_filter::update identically to SIR_scheme</span>00252 { (<span class="keywordtype">void</span>)SIR_scheme::update_resample();00253 }00254 <a name="l00255"></a><a class="code" href="classBayesian__filter_1_1SIR__kalman__scheme.html#a3">00255</a> <a class="code" href="classBayesian__filter_1_1Bayes__base.html#w0">Float</a> <a class="code" href="classBayesian__filter_1_1SIR__kalman__scheme.html#a3">update_resample</a> ()00256 <span class="comment">// Implement identically to SIR_scheme</span>00257 { <span class="keywordflow">return</span> SIR_scheme::update_resample();00258 }00259 00260 <a class="code" href="classBayesian__filter_1_1Bayes__base.html#w0">Float</a> <a class="code" href="classBayesian__filter_1_1SIR__kalman__scheme.html#a3">update_resample</a> (<span class="keyword">const</span> Importance_resampler& resampler);00261 <span class="comment">// Modified SIR_filter update implementation: update mean and covariance of sampled distribution</span>00262 00263 <span class="keywordtype">void</span> <a class="code" href="classBayesian__filter_1_1SIR__kalman__scheme.html#a5">update_statistics</a> ();00264 <span class="comment">// Update kalman statistics without resampling</span>00265 <a name="l00266"></a><a class="code" href="classBayesian__filter_1_1SIR__kalman__scheme.html#a6">00266</a> <span class="keywordtype">void</span> <a class="code" href="classBayesian__filter_1_1SIR__kalman__scheme.html#a6">roughen</a>()00267 { <span class="comment">// Specialised correlated roughening</span>00268 <span class="keywordflow">if</span> (<a class="code" href="classBayesian__filter_1_1SIR__scheme.html#o1">rougheningK</a> != 0.)00269 <a class="code" href="classBayesian__filter_1_1SIR__kalman__scheme.html#b0">roughen_correlated</a> (<a class="code" href="classBayesian__filter_1_1Sample__state__filter.html#o0">S</a>, <a class="code" href="classBayesian__filter_1_1SIR__scheme.html#o1">rougheningK</a>);00270 }00271 00272 <span class="keyword">protected</span>:00273 <span class="keywordtype">void</span> <a class="code" href="classBayesian__filter_1_1SIR__kalman__scheme.html#b0">roughen_correlated</a> (FM::ColMatrix& P, Float K); <span class="comment">// Roughening using covariance of P distribution</span><a name="l00274"></a><a class="code" href="classBayesian__filter_1_1SIR__kalman__scheme.html#p0">00274</a> <a class="code" href="namespaceBayesian__filter.html#a1">Sampled_LiAd_predict_model</a> <a class="code" href="classBayesian__filter_1_1SIR__kalman__scheme.html#p0">roughen_model</a>; <span class="comment">// roughening predict</span>00275 <span class="keyword">private</span>:00276 <span class="keyword">static</span> <a class="code" href="classBayesian__filter_1_1Bayes__base.html#w0">Float</a> scaled_vector_square(<span class="keyword">const</span> FM::Vec& v, <span class="keyword">const</span> FM::SymMatrix& S);00277 <span class="keywordtype">void</span> mean();00278 };00279 00280 00281 }<span class="comment">//namespace</span>00282 <span class="preprocessor">#endif</span></pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Feb 16 11:20:40 2004 for Bayes++ Bayesian Filtering Classes by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 > </a>1.3.2 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -