1 | <?xml version='1.0' encoding='UTF-8' standalone='no'?> |
---|
2 | <doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.5.6"> |
---|
3 | <compounddef id="libPF_8h" kind="file"> |
---|
4 | <compoundname>libPF.h</compoundname> |
---|
5 | <includes local="no">itpp/itbase.h</includes> |
---|
6 | <includes refid="libEF_8h" local="yes">../stat/libEF.h</includes> |
---|
7 | <includes refid="libDC_8h" local="yes">../math/libDC.h</includes> |
---|
8 | <includedby refid="libPF_8cpp" local="yes">work/git/mixpp/bdm/estim/libPF.cpp</includedby> |
---|
9 | <includedby refid="pmsm__mix_8cpp" local="no">work/git/mixpp/pmsm/pmsm_mix.cpp</includedby> |
---|
10 | <includedby refid="pmsm__sim_8cpp" local="no">work/git/mixpp/pmsm/pmsm_sim.cpp</includedby> |
---|
11 | <includedby refid="pmsm__sim2_8cpp" local="no">work/git/mixpp/pmsm/pmsm_sim2.cpp</includedby> |
---|
12 | <includedby refid="pmsm__sim3_8cpp" local="no">work/git/mixpp/pmsm/pmsm_sim3.cpp</includedby> |
---|
13 | <includedby refid="pmsm__unkQ_8cpp" local="no">work/git/mixpp/pmsm/pmsm_unkQ.cpp</includedby> |
---|
14 | <includedby refid="pmsm__unkQpf_8cpp" local="no">work/git/mixpp/pmsm/pmsm_unkQpf.cpp</includedby> |
---|
15 | <includedby refid="testKF__QR_8cpp" local="no">work/git/mixpp/tests/testKF_QR.cpp</includedby> |
---|
16 | <includedby refid="testKF__QRexh_8cpp" local="no">work/git/mixpp/tests/testKF_QRexh.cpp</includedby> |
---|
17 | <includedby refid="testPF_8cpp" local="no">work/git/mixpp/tests/testPF.cpp</includedby> |
---|
18 | <includedby refid="testResample_8cpp" local="no">work/git/mixpp/tests/testResample.cpp</includedby> |
---|
19 | <incdepgraph> |
---|
20 | <node id="259"> |
---|
21 | <label>libBM.h</label> |
---|
22 | <link refid="libBM_8h"/> |
---|
23 | <childnode refid="256" relation="include"> |
---|
24 | </childnode> |
---|
25 | </node> |
---|
26 | <node id="260"> |
---|
27 | <label>../itpp_ext.h</label> |
---|
28 | <link refid="itpp__ext_8h-source"/> |
---|
29 | <childnode refid="256" relation="include"> |
---|
30 | </childnode> |
---|
31 | </node> |
---|
32 | <node id="257"> |
---|
33 | <label>../stat/libEF.h</label> |
---|
34 | <link refid="libEF_8h"/> |
---|
35 | <childnode refid="256" relation="include"> |
---|
36 | </childnode> |
---|
37 | <childnode refid="258" relation="include"> |
---|
38 | </childnode> |
---|
39 | <childnode refid="259" relation="include"> |
---|
40 | </childnode> |
---|
41 | <childnode refid="260" relation="include"> |
---|
42 | </childnode> |
---|
43 | </node> |
---|
44 | <node id="255"> |
---|
45 | <label>work/git/mixpp/bdm/estim/libPF.h</label> |
---|
46 | <link refid="libPF.h"/> |
---|
47 | <childnode refid="256" relation="include"> |
---|
48 | </childnode> |
---|
49 | <childnode refid="257" relation="include"> |
---|
50 | </childnode> |
---|
51 | <childnode refid="258" relation="include"> |
---|
52 | </childnode> |
---|
53 | </node> |
---|
54 | <node id="256"> |
---|
55 | <label>itpp/itbase.h</label> |
---|
56 | </node> |
---|
57 | <node id="258"> |
---|
58 | <label>../math/libDC.h</label> |
---|
59 | <link refid="libDC_8h"/> |
---|
60 | <childnode refid="256" relation="include"> |
---|
61 | </childnode> |
---|
62 | </node> |
---|
63 | </incdepgraph> |
---|
64 | <invincdepgraph> |
---|
65 | <node id="261"> |
---|
66 | <label>work/git/mixpp/bdm/estim/libPF.h</label> |
---|
67 | <link refid="libPF.h"/> |
---|
68 | <childnode refid="262" relation="include"> |
---|
69 | </childnode> |
---|
70 | </node> |
---|
71 | <node id="262"> |
---|
72 | <label>work/git/mixpp/pmsm/pmsm_mix.cpp</label> |
---|
73 | <link refid="pmsm__mix_8cpp"/> |
---|
74 | </node> |
---|
75 | </invincdepgraph> |
---|
76 | <innerclass refid="classPF" prot="public">PF</innerclass> |
---|
77 | <innerclass refid="classMPF" prot="public">MPF</innerclass> |
---|
78 | <innerclass refid="classMPF_1_1mpfepdf" prot="private">MPF::mpfepdf</innerclass> |
---|
79 | <sectiondef kind="var"> |
---|
80 | <memberdef kind="variable" id="libPF_8h_1718eb6f36f33fd5898956fb950d0d8f2" prot="public" static="no" mutable="no"> |
---|
81 | <type>double</type> |
---|
82 | <definition>double PF_SSAT</definition> |
---|
83 | <argsstring></argsstring> |
---|
84 | <name>PF_SSAT</name> |
---|
85 | <briefdescription> |
---|
86 | </briefdescription> |
---|
87 | <detaileddescription> |
---|
88 | </detaileddescription> |
---|
89 | <inbodydescription> |
---|
90 | </inbodydescription> |
---|
91 | <location file="/home/smidl/work/git/mixpp/bdm/estim/libPF.h" line="23"/> |
---|
92 | </memberdef> |
---|
93 | </sectiondef> |
---|
94 | <briefdescription> |
---|
95 | <para>Bayesian Filtering using stochastic sampling (Particle Filters). </para> </briefdescription> |
---|
96 | <detaileddescription> |
---|
97 | <para><simplesect kind="author"><para>Vaclav Smidl.</para></simplesect> |
---|
98 | ----------------------------------- BDM++ - C++ library for Bayesian Decision Making under Uncertainty</para><para>Using IT++ for numerical operations ----------------------------------- </para> </detaileddescription> |
---|
99 | <programlisting> |
---|
100 | <codeline lineno="1"></codeline> |
---|
101 | <codeline lineno="13"><highlight class="preprocessor">#ifndef<sp/>PF_H</highlight></codeline> |
---|
102 | <codeline lineno="14"><highlight class="preprocessor"></highlight><highlight class="preprocessor">#define<sp/>PF_H</highlight></codeline> |
---|
103 | <codeline lineno="15"><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline> |
---|
104 | <codeline lineno="16"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/><itpp/itbase.h></highlight><highlight class="normal"></highlight></codeline> |
---|
105 | <codeline lineno="17"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>"../stat/libEF.h"</highlight><highlight class="normal"></highlight></codeline> |
---|
106 | <codeline lineno="18"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>"../math/libDC.h"</highlight><highlight class="normal"></highlight></codeline> |
---|
107 | <codeline lineno="19"><highlight class="normal"></highlight></codeline> |
---|
108 | <codeline lineno="20"><highlight class="normal"></highlight><highlight class="keyword">using<sp/>namespace<sp/></highlight><highlight class="normal">itpp;</highlight></codeline> |
---|
109 | <codeline lineno="21"><highlight class="normal"></highlight></codeline> |
---|
110 | <codeline lineno="22"><highlight class="normal"></highlight><highlight class="comment">//UGLY<sp/>HACK</highlight><highlight class="normal"></highlight></codeline> |
---|
111 | <codeline lineno="23"><highlight class="normal"></highlight><highlight class="keyword">extern</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>PF_SSAT;</highlight><highlight class="comment">//used<sp/>for<sp/>StrSim:06<sp/>test...<sp/>if<sp/>length>0<sp/>the<sp/>value<sp/>is<sp/>written.</highlight><highlight class="normal"></highlight></codeline> |
---|
112 | <codeline lineno="24"><highlight class="normal"></highlight></codeline> |
---|
113 | <codeline lineno="31" refid="classPF" refkind="compound"><highlight class="keyword">class<sp/></highlight><highlight class="normal"><ref refid="classPF" kindref="compound" tooltip="Trivial particle filter with proposal density equal to parameter evolution model...">PF</ref><sp/>:<sp/></highlight><highlight class="keyword">public</highlight><highlight class="normal"><sp/><ref refid="classBM" kindref="compound" tooltip="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</ref><sp/>{</highlight></codeline> |
---|
114 | <codeline lineno="32"><highlight class="normal"></highlight><highlight class="keyword">protected</highlight><highlight class="normal">:</highlight></codeline> |
---|
115 | <codeline lineno="34" refid="classPF_12c2f44ed7a4eaa42e07bdb58d503f280" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/><ref refid="classPF_12c2f44ed7a4eaa42e07bdb58d503f280" kindref="member" tooltip="number of particles;">n</ref>;</highlight></codeline> |
---|
116 | <codeline lineno="36" refid="classPF_11a0a09e309da997f63ae8e30d1e9806b" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classeEmp" kindref="compound" tooltip="Weighted empirical density.">eEmp</ref><sp/><ref refid="classPF_11a0a09e309da997f63ae8e30d1e9806b" kindref="member" tooltip="posterior density">est</ref>;</highlight></codeline> |
---|
117 | <codeline lineno="38" refid="classPF_15c87aba508df321ff26536ced64dbb3a" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>&<ref refid="classPF_15c87aba508df321ff26536ced64dbb3a" kindref="member" tooltip="pointer into eEmp ">_w</ref>;</highlight></codeline> |
---|
118 | <codeline lineno="40" refid="classPF_1cf7dad75e31215780a746c30e71ad9c5" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Array<vec><sp/>&<ref refid="classPF_1cf7dad75e31215780a746c30e71ad9c5" kindref="member" tooltip="pointer into eEmp ">_samples</ref>;</highlight></codeline> |
---|
119 | <codeline lineno="42" refid="classPF_1d92ac103f88f8c21e197e90af5695a09" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classmpdf" kindref="compound" tooltip="Conditional probability density, e.g. modeling some dependencies.">mpdf</ref><sp/>&<ref refid="classPF_1d92ac103f88f8c21e197e90af5695a09" kindref="member" tooltip="Parameter evolution model.">par</ref>;</highlight></codeline> |
---|
120 | <codeline lineno="44" refid="classPF_1dd0a687a4515333d6809147335854e77" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classmpdf" kindref="compound" tooltip="Conditional probability density, e.g. modeling some dependencies.">mpdf</ref><sp/>&<ref refid="classPF_1dd0a687a4515333d6809147335854e77" kindref="member" tooltip="Observation model.">obs</ref>;</highlight></codeline> |
---|
121 | <codeline lineno="45"><highlight class="normal"></highlight><highlight class="keyword">public</highlight><highlight class="normal">:</highlight></codeline> |
---|
122 | <codeline lineno="47" refid="classPF_1e99f0d866721405dd281e315ecb690aa" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classPF_1e99f0d866721405dd281e315ecb690aa" kindref="member" tooltip="Default constructor.">PF</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="classRV" kindref="compound" tooltip="Class representing variables, most often random variables.">RV</ref><sp/>&rv0,<sp/><ref refid="classmpdf" kindref="compound" tooltip="Conditional probability density, e.g. modeling some dependencies.">mpdf</ref><sp/>&par0,<sp/><sp/><ref refid="classmpdf" kindref="compound" tooltip="Conditional probability density, e.g. modeling some dependencies.">mpdf</ref><sp/>&obs0,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>n0<sp/>)<sp/>:<ref refid="classBM" kindref="compound" tooltip="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</ref><sp/>(<sp/>rv0<sp/>),</highlight></codeline> |
---|
123 | <codeline lineno="48"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classPF_12c2f44ed7a4eaa42e07bdb58d503f280" kindref="member" tooltip="number of particles;">n</ref><sp/>(<sp/>n0<sp/>),<ref refid="classPF_11a0a09e309da997f63ae8e30d1e9806b" kindref="member" tooltip="posterior density">est</ref><sp/>(<sp/>rv0,<ref refid="classPF_12c2f44ed7a4eaa42e07bdb58d503f280" kindref="member" tooltip="number of particles;">n</ref><sp/>),<ref refid="classPF_15c87aba508df321ff26536ced64dbb3a" kindref="member" tooltip="pointer into eEmp ">_w</ref><sp/>(<sp/><ref refid="classPF_11a0a09e309da997f63ae8e30d1e9806b" kindref="member" tooltip="posterior density">est</ref>.<ref refid="classPF_15c87aba508df321ff26536ced64dbb3a" kindref="member" tooltip="pointer into eEmp ">_w</ref>()<sp/>),<ref refid="classPF_1cf7dad75e31215780a746c30e71ad9c5" kindref="member" tooltip="pointer into eEmp ">_samples</ref><sp/>(<sp/><ref refid="classPF_11a0a09e309da997f63ae8e30d1e9806b" kindref="member" tooltip="posterior density">est</ref>.<ref refid="classPF_1cf7dad75e31215780a746c30e71ad9c5" kindref="member" tooltip="pointer into eEmp ">_samples</ref>()<sp/>),</highlight></codeline> |
---|
124 | <codeline lineno="49"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classPF_1d92ac103f88f8c21e197e90af5695a09" kindref="member" tooltip="Parameter evolution model.">par</ref><sp/>(<sp/>par0<sp/>),<sp/><ref refid="classPF_1dd0a687a4515333d6809147335854e77" kindref="member" tooltip="Observation model.">obs</ref><sp/>(<sp/>obs0<sp/>)<sp/>{};</highlight></codeline> |
---|
125 | <codeline lineno="50"><highlight class="normal"></highlight></codeline> |
---|
126 | <codeline lineno="52"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="classPF_104d38fbcc0348b558212f530d9ec183e" kindref="member" tooltip="Set posterior density by sampling from epdf0.">set_est</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="classepdf" kindref="compound" tooltip="Probability density function with numerical statistics, e.g. posterior density.">epdf</ref><sp/>&epdf0<sp/>);</highlight></codeline> |
---|
127 | <codeline lineno="53"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="classPF_164f636bbd63bea9efd778214e6b631d3" kindref="member" tooltip="Incremental Bayes rule.">bayes</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>vec<sp/>&dt<sp/>);</highlight></codeline> |
---|
128 | <codeline lineno="54"><highlight class="normal">};</highlight></codeline> |
---|
129 | <codeline lineno="55"><highlight class="normal"></highlight></codeline> |
---|
130 | <codeline lineno="62"><highlight class="keyword">template</highlight><highlight class="normal"><</highlight><highlight class="keyword">class</highlight><highlight class="normal"><sp/>BM_T></highlight></codeline> |
---|
131 | <codeline lineno="63"><highlight class="normal"></highlight></codeline> |
---|
132 | <codeline lineno="64" refid="classMPF" refkind="compound"><highlight class="normal"></highlight><highlight class="keyword">class<sp/></highlight><highlight class="normal"><ref refid="classMPF" kindref="compound" tooltip="Marginalized Particle filter.">MPF</ref><sp/>:<sp/></highlight><highlight class="keyword">public</highlight><highlight class="normal"><sp/><ref refid="classPF" kindref="compound" tooltip="Trivial particle filter with proposal density equal to parameter evolution model...">PF</ref><sp/>{</highlight></codeline> |
---|
133 | <codeline lineno="65"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>BM_T*<sp/>Bms[10000];</highlight></codeline> |
---|
134 | <codeline lineno="66"><highlight class="normal"></highlight></codeline> |
---|
135 | <codeline lineno="68"><highlight class="normal"></highlight></codeline> |
---|
136 | <codeline lineno="69"><highlight class="normal"></highlight><highlight class="keyword">class<sp/></highlight><highlight class="normal">mpfepdf<sp/>:<sp/></highlight><highlight class="keyword">public</highlight><highlight class="normal"><sp/><ref refid="classepdf" kindref="compound" tooltip="Probability density function with numerical statistics, e.g. posterior density.">epdf</ref><sp/><sp/>{</highlight></codeline> |
---|
137 | <codeline lineno="70"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">protected</highlight><highlight class="normal">:</highlight></codeline> |
---|
138 | <codeline lineno="71"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classeEmp" kindref="compound" tooltip="Weighted empirical density.">eEmp</ref><sp/>&E;</highlight></codeline> |
---|
139 | <codeline lineno="72"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>&<ref refid="classPF_15c87aba508df321ff26536ced64dbb3a" kindref="member" tooltip="pointer into eEmp ">_w</ref>;</highlight></codeline> |
---|
140 | <codeline lineno="73"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Array<epdf*><sp/>Coms;</highlight></codeline> |
---|
141 | <codeline lineno="74"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">public</highlight><highlight class="normal">:</highlight></codeline> |
---|
142 | <codeline lineno="75"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>mpfepdf<sp/>(<sp/><ref refid="classeEmp" kindref="compound" tooltip="Weighted empirical density.">eEmp</ref><sp/>&E0,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="classRV" kindref="compound" tooltip="Class representing variables, most often random variables.">RV</ref><sp/>&rvc<sp/>)<sp/>:</highlight></codeline> |
---|
143 | <codeline lineno="76"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classepdf" kindref="compound" tooltip="Probability density function with numerical statistics, e.g. posterior density.">epdf</ref><sp/>(<sp/><ref refid="classRV" kindref="compound" tooltip="Class representing variables, most often random variables.">RV</ref>(<sp/>)<sp/>),<sp/>E<sp/>(<sp/>E0<sp/>),<sp/><sp/><ref refid="classPF_15c87aba508df321ff26536ced64dbb3a" kindref="member" tooltip="pointer into eEmp ">_w</ref><sp/>(<sp/>E._w()<sp/>),</highlight></codeline> |
---|
144 | <codeline lineno="77"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Coms<sp/>(<sp/><ref refid="classPF_15c87aba508df321ff26536ced64dbb3a" kindref="member" tooltip="pointer into eEmp ">_w</ref>.length()<sp/>)<sp/>{</highlight></codeline> |
---|
145 | <codeline lineno="78"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classBM_1af00f0612fabe66241dd507188cdbf88" kindref="member" tooltip="Random variable of the posterior.">rv</ref>.<ref refid="classRV_1935790526b630dec4ffefa9ec0c2b6fb" kindref="member" tooltip="Add (concat) another variable to the current one,.">add</ref><sp/>(<sp/>E._rv()<sp/>);</highlight></codeline> |
---|
146 | <codeline lineno="79"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classBM_1af00f0612fabe66241dd507188cdbf88" kindref="member" tooltip="Random variable of the posterior.">rv</ref>.<ref refid="classRV_1935790526b630dec4ffefa9ec0c2b6fb" kindref="member" tooltip="Add (concat) another variable to the current one,.">add</ref><sp/>(<sp/>rvc<sp/>);</highlight></codeline> |
---|
147 | <codeline lineno="80"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>};</highlight></codeline> |
---|
148 | <codeline lineno="81"><highlight class="normal"></highlight></codeline> |
---|
149 | <codeline lineno="82"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>set_elements<sp/>(<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>&i,<sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>wi,<sp/><ref refid="classepdf" kindref="compound" tooltip="Probability density function with numerical statistics, e.g. posterior density.">epdf</ref>*<sp/>ep<sp/>)</highlight></codeline> |
---|
150 | <codeline lineno="83"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>{<ref refid="classPF_15c87aba508df321ff26536ced64dbb3a" kindref="member" tooltip="pointer into eEmp ">_w</ref><sp/>(<sp/>i<sp/>)<sp/>=wi;<sp/>Coms<sp/>(<sp/>i<sp/>)<sp/>=ep;};</highlight></codeline> |
---|
151 | <codeline lineno="84"><highlight class="normal"></highlight></codeline> |
---|
152 | <codeline lineno="85"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>mean()</highlight><highlight class="keyword"><sp/>const<sp/></highlight><highlight class="normal">{</highlight></codeline> |
---|
153 | <codeline lineno="86"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>ugly</highlight><highlight class="normal"></highlight></codeline> |
---|
154 | <codeline lineno="87"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>pom=zeros<sp/>(<sp/>(<sp/>Coms<sp/>(<sp/>0<sp/>)-><ref refid="classBM_1126bd2595c48e311fc2a7ab72876092a" kindref="member" tooltip="access function">_rv</ref>()<sp/>).count()<sp/>);</highlight></codeline> |
---|
155 | <codeline lineno="88"><highlight class="normal"></highlight></codeline> |
---|
156 | <codeline lineno="89"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i=0;<sp/>i<<ref refid="classPF_15c87aba508df321ff26536ced64dbb3a" kindref="member" tooltip="pointer into eEmp ">_w</ref>.length();<sp/>i++<sp/>)<sp/>{pom<sp/>+=<sp/>Coms<sp/>(<sp/>i<sp/>)->mean()<sp/>*<sp/><ref refid="classPF_15c87aba508df321ff26536ced64dbb3a" kindref="member" tooltip="pointer into eEmp ">_w</ref><sp/>(<sp/>i<sp/>);}</highlight></codeline> |
---|
157 | <codeline lineno="90"><highlight class="normal"></highlight></codeline> |
---|
158 | <codeline lineno="91"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>concat<sp/>(<sp/>E.mean(),pom<sp/>);</highlight></codeline> |
---|
159 | <codeline lineno="92"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline> |
---|
160 | <codeline lineno="93"><highlight class="normal"></highlight></codeline> |
---|
161 | <codeline lineno="94"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>sample()</highlight><highlight class="keyword"><sp/>const<sp/></highlight><highlight class="normal">{it_error<sp/>(<sp/></highlight><highlight class="stringliteral">"Not<sp/>implemented"</highlight><highlight class="normal"><sp/>);</highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;}</highlight></codeline> |
---|
162 | <codeline lineno="95"><highlight class="normal"></highlight></codeline> |
---|
163 | <codeline lineno="96"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>evalpdflog<sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>vec<sp/>&val<sp/>)</highlight><highlight class="keyword"><sp/>const<sp/></highlight><highlight class="normal">{it_error<sp/>(<sp/></highlight><highlight class="stringliteral">"not<sp/>implemented"</highlight><highlight class="normal"><sp/>);<sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0.0;}</highlight></codeline> |
---|
164 | <codeline lineno="97"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>};</highlight></codeline> |
---|
165 | <codeline lineno="98"><highlight class="normal"></highlight></codeline> |
---|
166 | <codeline lineno="100"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>mpfepdf<sp/>jest;</highlight></codeline> |
---|
167 | <codeline lineno="101"><highlight class="normal"></highlight></codeline> |
---|
168 | <codeline lineno="102"><highlight class="normal"></highlight><highlight class="keyword">public</highlight><highlight class="normal">:</highlight></codeline> |
---|
169 | <codeline lineno="104" refid="classMPF_1fc5e11e11eec3195e3c6503937bf02bd" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classMPF_1fc5e11e11eec3195e3c6503937bf02bd" kindref="member" tooltip="Default constructor.">MPF</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="classRV" kindref="compound" tooltip="Class representing variables, most often random variables.">RV</ref><sp/>&rvlin,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="classRV" kindref="compound" tooltip="Class representing variables, most often random variables.">RV</ref><sp/>&rvpf,<sp/><ref refid="classmpdf" kindref="compound" tooltip="Conditional probability density, e.g. modeling some dependencies.">mpdf</ref><sp/>&par0,<sp/><ref refid="classmpdf" kindref="compound" tooltip="Conditional probability density, e.g. modeling some dependencies.">mpdf</ref><sp/>&obs0,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/><ref refid="classPF_12c2f44ed7a4eaa42e07bdb58d503f280" kindref="member" tooltip="number of particles;">n</ref>,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>BM_T<sp/>&BMcond0<sp/>)<sp/>:<sp/><ref refid="classPF" kindref="compound" tooltip="Trivial particle filter with proposal density equal to parameter evolution model...">PF</ref><sp/>(<sp/>rvpf<sp/>,par0,obs0,n<sp/>),jest<sp/>(<sp/><ref refid="classPF_11a0a09e309da997f63ae8e30d1e9806b" kindref="member" tooltip="posterior density">est</ref>,rvlin<sp/>)<sp/>{</highlight></codeline> |
---|
170 | <codeline lineno="105"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//</highlight><highlight class="normal"></highlight></codeline> |
---|
171 | <codeline lineno="106"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//TODO<sp/>test<sp/>if<sp/>rv<sp/>and<sp/>BMcond.rv<sp/>are<sp/>compatible.</highlight><highlight class="normal"></highlight></codeline> |
---|
172 | <codeline lineno="107"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classBM_1af00f0612fabe66241dd507188cdbf88" kindref="member" tooltip="Random variable of the posterior.">rv</ref>.<ref refid="classRV_1935790526b630dec4ffefa9ec0c2b6fb" kindref="member" tooltip="Add (concat) another variable to the current one,.">add</ref><sp/>(<sp/>rvlin<sp/>);</highlight></codeline> |
---|
173 | <codeline lineno="108"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//</highlight><highlight class="normal"></highlight></codeline> |
---|
174 | <codeline lineno="109"><highlight class="normal"></highlight></codeline> |
---|
175 | <codeline lineno="110"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<sp/>n>10000<sp/>)<sp/>{it_error<sp/>(<sp/></highlight><highlight class="stringliteral">"increase<sp/>10000<sp/>here!"</highlight><highlight class="normal"><sp/>);}</highlight></codeline> |
---|
176 | <codeline lineno="111"><highlight class="normal"></highlight></codeline> |
---|
177 | <codeline lineno="112"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i=0;i<n;i++<sp/>)<sp/>{</highlight></codeline> |
---|
178 | <codeline lineno="113"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Bms[i]<sp/>=<sp/></highlight><highlight class="keyword">new</highlight><highlight class="normal"><sp/>BM_T<sp/>(<sp/>BMcond0<sp/>);<sp/></highlight><highlight class="comment">//copy<sp/>constructor</highlight><highlight class="normal"></highlight></codeline> |
---|
179 | <codeline lineno="114"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classepdf" kindref="compound" tooltip="Probability density function with numerical statistics, e.g. posterior density.">epdf</ref>&<sp/>pom=Bms[i]->_epdf();</highlight></codeline> |
---|
180 | <codeline lineno="115"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>jest.set_elements<sp/>(<sp/>i,1.0/n,&pom<sp/>);</highlight></codeline> |
---|
181 | <codeline lineno="116"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline> |
---|
182 | <codeline lineno="117"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>};</highlight></codeline> |
---|
183 | <codeline lineno="118"><highlight class="normal"></highlight></codeline> |
---|
184 | <codeline lineno="119"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>~<ref refid="classMPF" kindref="compound" tooltip="Marginalized Particle filter.">MPF</ref>()<sp/>{</highlight></codeline> |
---|
185 | <codeline lineno="120"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline> |
---|
186 | <codeline lineno="121"><highlight class="normal"></highlight></codeline> |
---|
187 | <codeline lineno="122"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="classMPF_155daf8e4b6553dd9f47c692de7931623" kindref="member" tooltip="Incremental Bayes rule.">bayes</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>vec<sp/>&dt<sp/>);</highlight></codeline> |
---|
188 | <codeline lineno="123" refid="classMPF_1549e08268a46a250f21a33d06f19276a" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classepdf" kindref="compound" tooltip="Probability density function with numerical statistics, e.g. posterior density.">epdf</ref>&<sp/><ref refid="classMPF_1549e08268a46a250f21a33d06f19276a" kindref="member" tooltip="Returns a pointer to the epdf representing posterior density on parameters. Use with...">_epdf</ref>()<sp/>{</highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>jest;}</highlight></codeline> |
---|
189 | <codeline lineno="125" refid="classMPF_17c66e1c1c0e45fc4ae765133cb3a1553" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="classMPF_17c66e1c1c0e45fc4ae765133cb3a1553" kindref="member" tooltip="Set postrior of rvc to samples from epdf0. Statistics of Bms are not re-computed!...">set_est</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="classepdf" kindref="compound" tooltip="Probability density function with numerical statistics, e.g. posterior density.">epdf</ref>&<sp/>epdf0<sp/>)<sp/>{</highlight></codeline> |
---|
190 | <codeline lineno="126"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classPF_104d38fbcc0348b558212f530d9ec183e" kindref="member" tooltip="Set posterior density by sampling from epdf0.">PF::set_est</ref><sp/>(<sp/>epdf0<sp/>);<sp/><sp/></highlight><highlight class="comment">//<sp/>sample<sp/>params<sp/>in<sp/>condition</highlight><highlight class="normal"></highlight></codeline> |
---|
191 | <codeline lineno="127"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>copy<sp/>conditions<sp/>to<sp/>BMs</highlight><highlight class="normal"></highlight></codeline> |
---|
192 | <codeline lineno="128"><highlight class="normal"></highlight></codeline> |
---|
193 | <codeline lineno="129"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i=0;i<<ref refid="classPF_12c2f44ed7a4eaa42e07bdb58d503f280" kindref="member" tooltip="number of particles;">n</ref>;i++<sp/>)<sp/>{Bms[i]->condition<sp/>(<sp/><ref refid="classPF_1cf7dad75e31215780a746c30e71ad9c5" kindref="member" tooltip="pointer into eEmp ">_samples</ref><sp/>(<sp/>i<sp/>)<sp/>);}</highlight></codeline> |
---|
194 | <codeline lineno="130"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline> |
---|
195 | <codeline lineno="131"><highlight class="normal"></highlight></codeline> |
---|
196 | <codeline lineno="132"><highlight class="normal"></highlight><highlight class="comment">//SimStr:</highlight><highlight class="normal"></highlight></codeline> |
---|
197 | <codeline lineno="133"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>SSAT;</highlight></codeline> |
---|
198 | <codeline lineno="134"><highlight class="normal">};</highlight></codeline> |
---|
199 | <codeline lineno="135"><highlight class="normal"></highlight></codeline> |
---|
200 | <codeline lineno="136"><highlight class="normal"></highlight><highlight class="keyword">template</highlight><highlight class="normal"><</highlight><highlight class="keyword">class</highlight><highlight class="normal"><sp/>BM_T></highlight></codeline> |
---|
201 | <codeline lineno="137" refid="classMPF_155daf8e4b6553dd9f47c692de7931623" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="classMPF_155daf8e4b6553dd9f47c692de7931623" kindref="member" tooltip="Incremental Bayes rule.">MPF<BM_T>::bayes</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>vec<sp/>&dt<sp/>)<sp/>{</highlight></codeline> |
---|
202 | <codeline lineno="138"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;</highlight></codeline> |
---|
203 | <codeline lineno="139"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>lls<sp/>(<sp/><ref refid="classPF_12c2f44ed7a4eaa42e07bdb58d503f280" kindref="member" tooltip="number of particles;">n</ref><sp/>);</highlight></codeline> |
---|
204 | <codeline lineno="140"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>llsP<sp/>(<sp/><ref refid="classPF_12c2f44ed7a4eaa42e07bdb58d503f280" kindref="member" tooltip="number of particles;">n</ref><sp/>);</highlight></codeline> |
---|
205 | <codeline lineno="141"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ivec<sp/>ind;</highlight></codeline> |
---|
206 | <codeline lineno="142"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>mlls=-std::numeric_limits<double>::infinity();</highlight></codeline> |
---|
207 | <codeline lineno="143"><highlight class="normal"></highlight></codeline> |
---|
208 | <codeline lineno="144"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>StrSim:06</highlight><highlight class="normal"></highlight></codeline> |
---|
209 | <codeline lineno="145"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>sumLWL=0.0;</highlight></codeline> |
---|
210 | <codeline lineno="146"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>sumL2WL=0.0;</highlight></codeline> |
---|
211 | <codeline lineno="147"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>WL<sp/>=<sp/>0.0;</highlight></codeline> |
---|
212 | <codeline lineno="148"><highlight class="normal"></highlight></codeline> |
---|
213 | <codeline lineno="149"><highlight class="normal"></highlight><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>#pragma<sp/>omp<sp/>parallel<sp/>for</highlight></codeline> |
---|
214 | <codeline lineno="150"><highlight class="preprocessor"></highlight><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/>i=0;i<<ref refid="classPF_12c2f44ed7a4eaa42e07bdb58d503f280" kindref="member" tooltip="number of particles;">n</ref>;i++<sp/>)<sp/>{<sp/><sp/><sp/></highlight></codeline> |
---|
215 | <codeline lineno="151"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//generate<sp/>new<sp/>samples<sp/>from<sp/>paramater<sp/>evolution<sp/>model;</highlight><highlight class="normal"></highlight></codeline> |
---|
216 | <codeline lineno="152"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classPF_1cf7dad75e31215780a746c30e71ad9c5" kindref="member" tooltip="pointer into eEmp ">_samples</ref><sp/>(<sp/>i<sp/>)<sp/>=<sp/><ref refid="classPF_1d92ac103f88f8c21e197e90af5695a09" kindref="member" tooltip="Parameter evolution model.">par</ref>.<ref refid="classmpdf_13f172b79ec4a5ebc87898a5381141f1b" kindref="member" tooltip="Returns the required moment of the epdf.">samplecond</ref><sp/>(<sp/><ref refid="classPF_1cf7dad75e31215780a746c30e71ad9c5" kindref="member" tooltip="pointer into eEmp ">_samples</ref><sp/>(<sp/>i<sp/>),<sp/>llsP<sp/>(<sp/>i<sp/>)<sp/>);</highlight></codeline> |
---|
217 | <codeline lineno="153"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Bms[i]->condition<sp/>(<sp/><ref refid="classPF_1cf7dad75e31215780a746c30e71ad9c5" kindref="member" tooltip="pointer into eEmp ">_samples</ref><sp/>(<sp/>i<sp/>)<sp/>);</highlight></codeline> |
---|
218 | <codeline lineno="154"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Bms[i]->bayes<sp/>(<sp/>dt<sp/>);</highlight></codeline> |
---|
219 | <codeline lineno="155"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>lls<sp/>(<sp/>i<sp/>)<sp/>=<sp/>Bms[i]->_ll();<sp/></highlight><highlight class="comment">//<sp/>lls<sp/>above<sp/>is<sp/>also<sp/>in<sp/>proposal<sp/>her<sp/>must<sp/>be<sp/>lls(i)<sp/>=,<sp/>not<sp/>+=!!</highlight><highlight class="normal"></highlight></codeline> |
---|
220 | <codeline lineno="156"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<sp/>lls<sp/>(<sp/>i<sp/>)<sp/>>mlls<sp/>)<sp/>mlls=lls<sp/>(<sp/>i<sp/>);<sp/></highlight><highlight class="comment">//find<sp/>maximum<sp/>likelihood<sp/>(for<sp/>numerical<sp/>stability)</highlight><highlight class="normal"></highlight></codeline> |
---|
221 | <codeline lineno="157"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline> |
---|
222 | <codeline lineno="158"><highlight class="normal"></highlight></codeline> |
---|
223 | <codeline lineno="159"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<sp/></highlight><highlight class="keyword">false</highlight><highlight class="normal">)<sp/>{</highlight></codeline> |
---|
224 | <codeline lineno="160"><highlight class="normal"></highlight><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>#pragma<sp/>omp<sp/>parallel<sp/>for<sp/>reduction(+:sumLWL,sumL2WL)<sp/>private(WL)</highlight></codeline> |
---|
225 | <codeline lineno="161"><highlight class="preprocessor"></highlight><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/>i=0;i<n;i++<sp/>)<sp/>{</highlight></codeline> |
---|
226 | <codeline lineno="162"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>WL<sp/>=<sp/><ref refid="classPF_15c87aba508df321ff26536ced64dbb3a" kindref="member" tooltip="pointer into eEmp ">_w</ref><sp/>(<sp/>i<sp/>)<sp/>*exp<sp/>(<sp/>llsP<sp/>(<sp/>i<sp/>)<sp/>);<sp/></highlight><highlight class="comment">//using<sp/>old<sp/>weights!</highlight><highlight class="normal"></highlight></codeline> |
---|
227 | <codeline lineno="163"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sumLWL<sp/>+=<sp/>exp<sp/>(<sp/>lls<sp/>(<sp/>i<sp/>)<sp/>)<sp/>*WL;</highlight></codeline> |
---|
228 | <codeline lineno="164"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sumL2WL<sp/>+=<sp/>exp<sp/>(<sp/>2*lls<sp/>(<sp/>i<sp/>)<sp/>)<sp/>*WL;</highlight></codeline> |
---|
229 | <codeline lineno="165"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline> |
---|
230 | <codeline lineno="166"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>SSAT<sp/><sp/>=<sp/>sumL2WL/<sp/>(<sp/>sumLWL*sumLWL<sp/>);</highlight></codeline> |
---|
231 | <codeline lineno="167"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline> |
---|
232 | <codeline lineno="168"><highlight class="normal"></highlight></codeline> |
---|
233 | <codeline lineno="169"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>sum_w=0.0;</highlight></codeline> |
---|
234 | <codeline lineno="170"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>compute<sp/>weights</highlight><highlight class="normal"></highlight></codeline> |
---|
235 | <codeline lineno="171"><highlight class="normal"></highlight><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>#pragma<sp/>omp<sp/>parallel<sp/>for</highlight></codeline> |
---|
236 | <codeline lineno="172"><highlight class="preprocessor"></highlight><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/>i=0;i<n;i++<sp/>)<sp/>{</highlight></codeline> |
---|
237 | <codeline lineno="173"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classPF_15c87aba508df321ff26536ced64dbb3a" kindref="member" tooltip="pointer into eEmp ">_w</ref><sp/>(<sp/>i<sp/>)<sp/>*=<sp/>exp<sp/>(<sp/>lls<sp/>(<sp/>i<sp/>)<sp/>-<sp/>mlls<sp/>);<sp/></highlight><highlight class="comment">//<sp/>multiply<sp/>w<sp/>by<sp/>likelihood</highlight><highlight class="normal"></highlight></codeline> |
---|
238 | <codeline lineno="174"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>sum_w+=<ref refid="classPF_15c87aba508df321ff26536ced64dbb3a" kindref="member" tooltip="pointer into eEmp ">_w</ref>(i);</highlight></codeline> |
---|
239 | <codeline lineno="175"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline> |
---|
240 | <codeline lineno="176"><highlight class="normal"></highlight></codeline> |
---|
241 | <codeline lineno="177"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<sp/>sum_w<sp/><sp/>>0.0<sp/>)<sp/>{</highlight></codeline> |
---|
242 | <codeline lineno="178"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classPF_15c87aba508df321ff26536ced64dbb3a" kindref="member" tooltip="pointer into eEmp ">_w</ref><sp/>/=sum_w;<sp/></highlight><highlight class="comment">//?</highlight><highlight class="normal"></highlight></codeline> |
---|
243 | <codeline lineno="179"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline> |
---|
244 | <codeline lineno="180"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>cout<<</highlight><highlight class="stringliteral">"sum(w)==0"</highlight><highlight class="normal"><<endl;</highlight></codeline> |
---|
245 | <codeline lineno="181"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline> |
---|
246 | <codeline lineno="182"><highlight class="normal"></highlight></codeline> |
---|
247 | <codeline lineno="183"><highlight class="normal"></highlight></codeline> |
---|
248 | <codeline lineno="184"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>eff<sp/>=<sp/>1.0/<sp/>(<sp/><ref refid="classPF_15c87aba508df321ff26536ced64dbb3a" kindref="member" tooltip="pointer into eEmp ">_w</ref>*<ref refid="classPF_15c87aba508df321ff26536ced64dbb3a" kindref="member" tooltip="pointer into eEmp ">_w</ref><sp/>);</highlight></codeline> |
---|
249 | <codeline lineno="185"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<sp/>eff<sp/><<sp/>(<sp/>0.3*n<sp/>)<sp/>)<sp/>{</highlight></codeline> |
---|
250 | <codeline lineno="186"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ind<sp/>=<sp/><ref refid="classPF_11a0a09e309da997f63ae8e30d1e9806b" kindref="member" tooltip="posterior density">est</ref>.<ref refid="classeEmp_177268292fc4465cb73ddbfb1f2932a59" kindref="member" tooltip="Function performs resampling, i.e. removal of low-weight samples and duplication...">resample</ref>();</highlight></codeline> |
---|
251 | <codeline lineno="187"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Resample<sp/>Bms!</highlight><highlight class="normal"></highlight></codeline> |
---|
252 | <codeline lineno="188"><highlight class="normal"></highlight></codeline> |
---|
253 | <codeline lineno="189"><highlight class="normal"></highlight><highlight class="preprocessor"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>#pragma<sp/>omp<sp/>parallel<sp/>for</highlight></codeline> |
---|
254 | <codeline lineno="190"><highlight class="preprocessor"></highlight><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/>i=0;i<n;i++<sp/>)<sp/>{</highlight></codeline> |
---|
255 | <codeline lineno="191"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<sp/>ind<sp/>(<sp/>i<sp/>)<sp/>!=i<sp/>)<sp/>{</highlight><highlight class="comment">//replace<sp/>the<sp/>current<sp/>Bm<sp/>by<sp/>a<sp/>new<sp/>one</highlight><highlight class="normal"></highlight></codeline> |
---|
256 | <codeline lineno="192"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//fixme<sp/>this<sp/>would<sp/>require<sp/>new<sp/>assignment<sp/>operator</highlight><highlight class="normal"></highlight></codeline> |
---|
257 | <codeline lineno="193"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>*Bms[i]<sp/>=<sp/>*Bms[ind<sp/>(<sp/>i<sp/>)<sp/>];</highlight><highlight class="normal"></highlight></codeline> |
---|
258 | <codeline lineno="194"><highlight class="normal"></highlight></codeline> |
---|
259 | <codeline lineno="195"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>poor-man's<sp/>solution:<sp/>replicate<sp/>constructor<sp/>here</highlight><highlight class="normal"></highlight></codeline> |
---|
260 | <codeline lineno="196"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>copied<sp/>from<sp/>MPF::MPF</highlight><highlight class="normal"></highlight></codeline> |
---|
261 | <codeline lineno="197"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">delete</highlight><highlight class="normal"><sp/>Bms[i];</highlight></codeline> |
---|
262 | <codeline lineno="198"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Bms[i]<sp/>=<sp/></highlight><highlight class="keyword">new</highlight><highlight class="normal"><sp/>BM_T<sp/>(<sp/>*Bms[ind<sp/>(<sp/>i<sp/>)<sp/>]<sp/>);<sp/></highlight><highlight class="comment">//copy<sp/>constructor</highlight><highlight class="normal"></highlight></codeline> |
---|
263 | <codeline lineno="199"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classepdf" kindref="compound" tooltip="Probability density function with numerical statistics, e.g. posterior density.">epdf</ref>&<sp/>pom=Bms[i]->_epdf();</highlight></codeline> |
---|
264 | <codeline lineno="200"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>jest.set_elements<sp/>(<sp/>i,1.0/n,&pom<sp/>);</highlight></codeline> |
---|
265 | <codeline lineno="201"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline> |
---|
266 | <codeline lineno="202"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>};</highlight></codeline> |
---|
267 | <codeline lineno="203"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>cout<sp/><<<sp/></highlight><highlight class="charliteral">'.'</highlight><highlight class="normal">;</highlight></codeline> |
---|
268 | <codeline lineno="204"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline> |
---|
269 | <codeline lineno="205"><highlight class="normal">}</highlight></codeline> |
---|
270 | <codeline lineno="206"><highlight class="normal"></highlight></codeline> |
---|
271 | <codeline lineno="207"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/>//<sp/>KF_H</highlight></codeline> |
---|
272 | <codeline lineno="208"><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline> |
---|
273 | <codeline lineno="209"><highlight class="normal"></highlight></codeline> |
---|
274 | </programlisting> |
---|
275 | <location file="/home/smidl/work/git/mixpp/bdm/estim/libPF.h"/> |
---|
276 | </compounddef> |
---|
277 | </doxygen> |
---|