84 | | <a name="l00031"></a>00031 <span class="keyword">extern</span> ivec RV_SIZES; |
85 | | <a name="l00032"></a>00032 <span class="keyword">extern</span> Array<string> RV_NAMES; |
86 | | <a name="l00033"></a>00033 |
87 | | <a name="l00035"></a><a class="code" href="classbdm_1_1str.html">00035</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1str.html" title="Structure of RV (used internally), i.e. expanded RVs - TODO tak proc je ve verejnem...">str</a> |
88 | | <a name="l00036"></a>00036 { |
89 | | <a name="l00037"></a>00037 <span class="keyword">public</span>: |
90 | | <a name="l00039"></a><a class="code" href="classbdm_1_1str.html#64675a73fc7324177175f19b3baeb0b0">00039</a> ivec <a class="code" href="classbdm_1_1str.html#64675a73fc7324177175f19b3baeb0b0" title="vector id ids (non-unique!)">ids</a>; |
91 | | <a name="l00041"></a><a class="code" href="classbdm_1_1str.html#905dc0f240e40432c103708c4a34f80a">00041</a> ivec <a class="code" href="classbdm_1_1str.html#905dc0f240e40432c103708c4a34f80a" title="vector of times">times</a>; |
92 | | <a name="l00043"></a><a class="code" href="classbdm_1_1str.html#7c6b9dccc6814d7bd1e8e2208a0d3f3f">00043</a> <a class="code" href="classbdm_1_1str.html#7c6b9dccc6814d7bd1e8e2208a0d3f3f" title="Default constructor.">str</a>(ivec ids0, ivec times0) : <a class="code" href="classbdm_1_1str.html#64675a73fc7324177175f19b3baeb0b0" title="vector id ids (non-unique!)">ids</a>(ids0), <a class="code" href="classbdm_1_1str.html#905dc0f240e40432c103708c4a34f80a" title="vector of times">times</a>(times0) { |
93 | | <a name="l00044"></a>00044 it_assert_debug(times0.length() == ids0.length(), <span class="stringliteral">"Incompatible input"</span>); |
94 | | <a name="l00045"></a>00045 }; |
95 | | <a name="l00046"></a>00046 }; |
96 | | <a name="l00047"></a>00047 |
97 | | <a name="l00086"></a><a class="code" href="classbdm_1_1RV.html">00086</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> |
98 | | <a name="l00087"></a>00087 { |
99 | | <a name="l00088"></a>00088 <span class="keyword">protected</span>: |
100 | | <a name="l00090"></a><a class="code" href="classbdm_1_1RV.html#0cfe477965243a89eb87a06b024e2fcb">00090</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1RV.html#0cfe477965243a89eb87a06b024e2fcb" title="size of the data vector">dsize</a>; |
101 | | <a name="l00092"></a><a class="code" href="classbdm_1_1RV.html#b11bfdceb831ed30d33b852dd4a6b385">00092</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1RV.html#b11bfdceb831ed30d33b852dd4a6b385" title="number of individual rvs">len</a>; |
102 | | <a name="l00094"></a><a class="code" href="classbdm_1_1RV.html#0a9a4769ab5a322495bea0cd8091500b">00094</a> ivec <a class="code" href="classbdm_1_1RV.html#0a9a4769ab5a322495bea0cd8091500b" title="Vector of unique IDs.">ids</a>; |
103 | | <a name="l00096"></a><a class="code" href="classbdm_1_1RV.html#ef6703854820bbf61736738f1bac6896">00096</a> ivec <a class="code" href="classbdm_1_1RV.html#ef6703854820bbf61736738f1bac6896" title="Vector of shifts from current time.">times</a>; |
104 | | <a name="l00097"></a>00097 |
105 | | <a name="l00098"></a>00098 <span class="keyword">private</span>: |
106 | | <a name="l00100"></a>00100 <span class="keywordtype">void</span> init(Array<std::string> in_names, ivec in_sizes, ivec in_times); |
107 | | <a name="l00101"></a>00101 <span class="keywordtype">int</span> init(<span class="keyword">const</span> <span class="keywordtype">string</span> &name, <span class="keywordtype">int</span> size); |
108 | | <a name="l00102"></a>00102 <span class="keyword">public</span>: |
109 | | <a name="l00105"></a>00105 |
110 | | <a name="l00107"></a><a class="code" href="classbdm_1_1RV.html#3d93da01a64dab31074b25b7d93e5eae">00107</a> <a class="code" href="classbdm_1_1RV.html#3d93da01a64dab31074b25b7d93e5eae" title="Full constructor.">RV</a>(Array<std::string> in_names, ivec in_sizes, ivec in_times) {init(in_names, in_sizes, in_times);}; |
111 | | <a name="l00109"></a><a class="code" href="classbdm_1_1RV.html#5bd1bd9ec51b91578ecc83a6b2398a20">00109</a> <a class="code" href="classbdm_1_1RV.html#5bd1bd9ec51b91578ecc83a6b2398a20" title="Constructor with times=0.">RV</a>(Array<std::string> in_names, ivec in_sizes) {init(in_names, in_sizes, zeros_i(in_names.length()));}; |
112 | | <a name="l00111"></a><a class="code" href="classbdm_1_1RV.html#a222dfef569e8f123180d40fde97c1cd">00111</a> <a class="code" href="classbdm_1_1RV.html#a222dfef569e8f123180d40fde97c1cd" title="Constructor with sizes=1, times=0.">RV</a>(Array<std::string> in_names) {init(in_names, ones_i(in_names.length()), zeros_i(in_names.length()));} |
113 | | <a name="l00113"></a><a class="code" href="classbdm_1_1RV.html#e319ca900261a5005a9b4b353ec16412">00113</a> <a class="code" href="classbdm_1_1RV.html#e319ca900261a5005a9b4b353ec16412" title="Constructor of empty RV.">RV</a>() : <a class="code" href="classbdm_1_1RV.html#0cfe477965243a89eb87a06b024e2fcb" title="size of the data vector">dsize</a>(0), <a class="code" href="classbdm_1_1RV.html#b11bfdceb831ed30d33b852dd4a6b385" title="number of individual rvs">len</a>(0), <a class="code" href="classbdm_1_1RV.html#0a9a4769ab5a322495bea0cd8091500b" title="Vector of unique IDs.">ids</a>(0), <a class="code" href="classbdm_1_1RV.html#ef6703854820bbf61736738f1bac6896" title="Vector of shifts from current time.">times</a>(0) {}; |
114 | | <a name="l00115"></a>00115 <a class="code" href="classbdm_1_1RV.html#e319ca900261a5005a9b4b353ec16412" title="Constructor of empty RV.">RV</a>(<span class="keywordtype">string</span> name, <span class="keywordtype">int</span> sz, <span class="keywordtype">int</span> tm = 0); |
| 83 | <a name="l00032"></a>00032 <span class="keyword">extern</span> ivec RV_SIZES; |
| 84 | <a name="l00034"></a>00034 <span class="keyword">extern</span> Array<string> RV_NAMES; |
| 85 | <a name="l00035"></a>00035 |
| 86 | <a name="l00037"></a><a class="code" href="classbdm_1_1str.html">00037</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1str.html" title="Structure of RV, i.e. RVs expanded into a flat list of IDs, used for debugging.">str</a> |
| 87 | <a name="l00038"></a>00038 { |
| 88 | <a name="l00039"></a>00039 <span class="keyword">public</span>: |
| 89 | <a name="l00041"></a><a class="code" href="classbdm_1_1str.html#64675a73fc7324177175f19b3baeb0b0">00041</a> ivec <a class="code" href="classbdm_1_1str.html#64675a73fc7324177175f19b3baeb0b0" title="vector id ids (non-unique!)">ids</a>; |
| 90 | <a name="l00043"></a><a class="code" href="classbdm_1_1str.html#905dc0f240e40432c103708c4a34f80a">00043</a> ivec <a class="code" href="classbdm_1_1str.html#905dc0f240e40432c103708c4a34f80a" title="vector of times">times</a>; |
| 91 | <a name="l00045"></a><a class="code" href="classbdm_1_1str.html#7c6b9dccc6814d7bd1e8e2208a0d3f3f">00045</a> <a class="code" href="classbdm_1_1str.html#7c6b9dccc6814d7bd1e8e2208a0d3f3f" title="Default constructor.">str</a> (ivec ids0, ivec times0) : <a class="code" href="classbdm_1_1str.html#64675a73fc7324177175f19b3baeb0b0" title="vector id ids (non-unique!)">ids</a> (ids0), <a class="code" href="classbdm_1_1str.html#905dc0f240e40432c103708c4a34f80a" title="vector of times">times</a> (times0) { |
| 92 | <a name="l00046"></a>00046 it_assert_debug (times0.length() == ids0.length(), <span class="stringliteral">"Incompatible input"</span>); |
| 93 | <a name="l00047"></a>00047 }; |
| 94 | <a name="l00048"></a>00048 }; |
| 95 | <a name="l00049"></a>00049 |
| 96 | <a name="l00088"></a><a class="code" href="classbdm_1_1RV.html">00088</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> |
| 97 | <a name="l00089"></a>00089 { |
| 98 | <a name="l00090"></a>00090 <span class="keyword">protected</span>: |
| 99 | <a name="l00092"></a><a class="code" href="classbdm_1_1RV.html#0cfe477965243a89eb87a06b024e2fcb">00092</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1RV.html#0cfe477965243a89eb87a06b024e2fcb" title="size of the data vector">dsize</a>; |
| 100 | <a name="l00094"></a><a class="code" href="classbdm_1_1RV.html#b11bfdceb831ed30d33b852dd4a6b385">00094</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1RV.html#b11bfdceb831ed30d33b852dd4a6b385" title="number of individual rvs">len</a>; |
| 101 | <a name="l00096"></a><a class="code" href="classbdm_1_1RV.html#0a9a4769ab5a322495bea0cd8091500b">00096</a> ivec <a class="code" href="classbdm_1_1RV.html#0a9a4769ab5a322495bea0cd8091500b" title="Vector of unique IDs.">ids</a>; |
| 102 | <a name="l00098"></a><a class="code" href="classbdm_1_1RV.html#ef6703854820bbf61736738f1bac6896">00098</a> ivec <a class="code" href="classbdm_1_1RV.html#ef6703854820bbf61736738f1bac6896" title="Vector of shifts from current time.">times</a>; |
| 103 | <a name="l00099"></a>00099 |
| 104 | <a name="l00100"></a>00100 <span class="keyword">private</span>: |
| 105 | <a name="l00102"></a>00102 <span class="keywordtype">void</span> init (<span class="keyword">const</span> Array<std::string> &in_names, <span class="keyword">const</span> ivec &in_sizes, <span class="keyword">const</span> ivec &in_times); |
| 106 | <a name="l00103"></a>00103 <span class="keywordtype">int</span> init (<span class="keyword">const</span> <span class="keywordtype">string</span> &name, <span class="keywordtype">int</span> size); |
| 107 | <a name="l00104"></a>00104 <span class="keyword">public</span>: |
| 108 | <a name="l00107"></a>00107 |
| 109 | <a name="l00109"></a><a class="code" href="classbdm_1_1RV.html#3fa35c2744e687c74f7742990e6aa264">00109</a> <a class="code" href="classbdm_1_1RV.html#3fa35c2744e687c74f7742990e6aa264" title="Full constructor.">RV</a> (<span class="keyword">const</span> Array<std::string> &in_names, <span class="keyword">const</span> ivec &in_sizes, <span class="keyword">const</span> ivec &in_times) { |
| 110 | <a name="l00110"></a>00110 init (in_names, in_sizes, in_times); |
| 111 | <a name="l00111"></a>00111 } |
| 112 | <a name="l00112"></a>00112 |
| 113 | <a name="l00114"></a><a class="code" href="classbdm_1_1RV.html#381f5d963bb54efd4e76815dc93d50ce">00114</a> <a class="code" href="classbdm_1_1RV.html#381f5d963bb54efd4e76815dc93d50ce" title="Constructor with times=0.">RV</a> (<span class="keyword">const</span> Array<std::string> &in_names, <span class="keyword">const</span> ivec &in_sizes) { |
| 114 | <a name="l00115"></a>00115 init (in_names, in_sizes, zeros_i (in_names.length())); |
| 115 | <a name="l00116"></a>00116 } |
148 | | <a name="l00169"></a>00169 <a class="code" href="classbdm_1_1str.html" title="Structure of RV (used internally), i.e. expanded RVs - TODO tak proc je ve verejnem...">str</a> <a class="code" href="classbdm_1_1RV.html#8bdd7f4072749c7cc864b78a418ca388" title="generate str from rv, by expanding sizes TODO to_string..">tostr</a>() <span class="keyword">const</span>; |
149 | | <a name="l00172"></a>00172 ivec <a class="code" href="classbdm_1_1RV.html#cbebdb5e0d30101a6eb63550ef701c55">dataind</a>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &crv) <span class="keyword">const</span>; |
150 | | <a name="l00175"></a>00175 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1RV.html#cbebdb5e0d30101a6eb63550ef701c55">dataind</a>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv2, ivec &selfi, ivec &rv2i) <span class="keyword">const</span>; |
151 | | <a name="l00177"></a><a class="code" href="classbdm_1_1RV.html#9a5c5aeeaf39299d07763377b05a8241">00177</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1RV.html#9a5c5aeeaf39299d07763377b05a8241" title="Minimum time-offset.">mint</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> min(<a class="code" href="classbdm_1_1RV.html#ef6703854820bbf61736738f1bac6896" title="Vector of shifts from current time.">times</a>);}; |
152 | | <a name="l00179"></a>00179 |
153 | | <a name="l00180"></a>00180 <span class="comment">// TODO aktualizovat dle soucasneho UI</span> |
154 | | <a name="l00195"></a>00195 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1RV.html#6564bdd36b6845a51446a192d33e1194" title="UI for class RV (description of data vectors).">from_setting</a>(<span class="keyword">const</span> Setting &<span class="keyword">set</span>); |
155 | | <a name="l00196"></a>00196 |
156 | | <a name="l00197"></a>00197 <span class="comment">// TODO dodelat void to_setting( Setting &set ) const;</span> |
157 | | <a name="l00198"></a>00198 }; |
158 | | <a name="l00199"></a>00199 <a class="code" href="user__info_8h.html#4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a>(RV); |
159 | | <a name="l00200"></a>00200 |
160 | | <a name="l00202"></a>00202 RV concat(<span class="keyword">const</span> RV &rv1, <span class="keyword">const</span> RV &rv2); |
161 | | <a name="l00203"></a>00203 |
162 | | <a name="l00205"></a>00205 <span class="keyword">extern</span> RV RV0; |
163 | | <a name="l00206"></a>00206 |
164 | | <a name="l00208"></a>00208 |
165 | | <a name="l00209"></a><a class="code" href="classbdm_1_1fnc.html">00209</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1fnc.html" title="Class representing function of variable represented by rv.">fnc</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> |
166 | | <a name="l00210"></a>00210 { |
167 | | <a name="l00211"></a>00211 <span class="keyword">protected</span>: |
168 | | <a name="l00213"></a><a class="code" href="classbdm_1_1fnc.html#52156cb4a52a62d51fc7455985797a62">00213</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1fnc.html#52156cb4a52a62d51fc7455985797a62" title="Length of the output vector.">dimy</a>; |
169 | | <a name="l00214"></a>00214 <span class="keyword">public</span>: |
170 | | <a name="l00216"></a><a class="code" href="classbdm_1_1fnc.html#65e9fb11f6cc7884018d8f229bcabbb7">00216</a> <a class="code" href="classbdm_1_1fnc.html#65e9fb11f6cc7884018d8f229bcabbb7" title="default constructor">fnc</a>() {}; |
171 | | <a name="l00218"></a><a class="code" href="classbdm_1_1fnc.html#6277b11d7fffc7ef8a2fa3e84ae5bad4">00218</a> <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1fnc.html#6277b11d7fffc7ef8a2fa3e84ae5bad4" title="function evaluates numerical value of at cond ">eval</a>(<span class="keyword">const</span> vec &cond) { |
172 | | <a name="l00219"></a>00219 <span class="keywordflow">return</span> vec(0); |
173 | | <a name="l00220"></a>00220 }; |
174 | | <a name="l00221"></a>00221 |
175 | | <a name="l00223"></a><a class="code" href="classbdm_1_1fnc.html#0786e40fade2663a70d654c1dda5d73e">00223</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1fnc.html#0786e40fade2663a70d654c1dda5d73e" title="function substitutes given value into an appropriate position">condition</a>(<span class="keyword">const</span> vec &val) {}; |
176 | | <a name="l00224"></a>00224 |
177 | | <a name="l00226"></a><a class="code" href="classbdm_1_1fnc.html#083832294da9d1e40804158b979c4341">00226</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1fnc.html#083832294da9d1e40804158b979c4341" title="access function">dimension</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1fnc.html#52156cb4a52a62d51fc7455985797a62" title="Length of the output vector.">dimy</a>;} |
| 156 | <a name="l00169"></a>00169 ivec <a class="code" href="classbdm_1_1RV.html#1367055b2608ad9d50d01a2da6cec869" title="Find indices of self in another rv,.">findself</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html#e319ca900261a5005a9b4b353ec16412" title="Constructor of empty RV.">RV</a> &rv2) <span class="keyword">const</span>; |
| 157 | <a name="l00171"></a>00171 <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1RV.html#3bb011af88ae98f5c97955bb2c95cfee" title="Compare if rv2 is identical to this RV.">equal</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html#e319ca900261a5005a9b4b353ec16412" title="Constructor of empty RV.">RV</a> &rv2) <span class="keyword">const</span>; |
| 158 | <a name="l00173"></a>00173 <span class="keywordtype">bool</span> <span class="keyword">add</span> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html#e319ca900261a5005a9b4b353ec16412" title="Constructor of empty RV.">RV</a> &rv2); |
| 159 | <a name="l00175"></a>00175 <a class="code" href="classbdm_1_1RV.html#e319ca900261a5005a9b4b353ec16412" title="Constructor of empty RV.">RV</a> <a class="code" href="classbdm_1_1RV.html#aec44dabdf0a6d90fbae95e1356eda39" title="Subtract another variable from the current one.">subt</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html#e319ca900261a5005a9b4b353ec16412" title="Constructor of empty RV.">RV</a> &rv2) <span class="keyword">const</span>; |
| 160 | <a name="l00177"></a>00177 <a class="code" href="classbdm_1_1RV.html#e319ca900261a5005a9b4b353ec16412" title="Constructor of empty RV.">RV</a> <a class="code" href="classbdm_1_1RV.html#c0c04ab99ded62e1e05bcefb151ebeb9" title="Select only variables at indices ind.">subselect</a> (<span class="keyword">const</span> ivec &ind) <span class="keyword">const</span>; |
| 161 | <a name="l00178"></a>00178 |
| 162 | <a name="l00180"></a><a class="code" href="classbdm_1_1RV.html#6f3daf0f857fff53a1c0a445fe160966">00180</a> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1RV.html#6f3daf0f857fff53a1c0a445fe160966" title="Select only variables at indices ind.">operator() </a>(<span class="keyword">const</span> ivec &ind)<span class="keyword"> const </span>{ |
| 163 | <a name="l00181"></a>00181 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1RV.html#c0c04ab99ded62e1e05bcefb151ebeb9" title="Select only variables at indices ind.">subselect</a> (ind); |
| 164 | <a name="l00182"></a>00182 } |
| 165 | <a name="l00183"></a>00183 |
| 166 | <a name="l00185"></a>00185 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1RV.html#6f3daf0f857fff53a1c0a445fe160966" title="Select only variables at indices ind.">operator() </a>(<span class="keywordtype">int</span> di1, <span class="keywordtype">int</span> di2) <span class="keyword">const</span>; |
| 167 | <a name="l00186"></a>00186 |
| 168 | <a name="l00188"></a>00188 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1RV.html#bd77cb0899f7fba1d0e34396137b7f1f" title="Shift time by delta.">t</a> (<span class="keywordtype">int</span> delta); |
| 169 | <a name="l00190"></a>00190 |
| 170 | <a name="l00193"></a>00193 |
| 171 | <a name="l00195"></a>00195 <a class="code" href="classbdm_1_1str.html" title="Structure of RV, i.e. RVs expanded into a flat list of IDs, used for debugging.">str</a> <a class="code" href="classbdm_1_1RV.html#8bdd7f4072749c7cc864b78a418ca388" title="generate str from rv, by expanding sizes">tostr</a>() <span class="keyword">const</span>; |
| 172 | <a name="l00198"></a>00198 ivec <a class="code" href="classbdm_1_1RV.html#cbebdb5e0d30101a6eb63550ef701c55">dataind</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &crv) <span class="keyword">const</span>; |
| 173 | <a name="l00201"></a>00201 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1RV.html#cbebdb5e0d30101a6eb63550ef701c55">dataind</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv2, ivec &selfi, ivec &rv2i) <span class="keyword">const</span>; |
| 174 | <a name="l00203"></a><a class="code" href="classbdm_1_1RV.html#9a5c5aeeaf39299d07763377b05a8241">00203</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1RV.html#9a5c5aeeaf39299d07763377b05a8241" title="Minimum time-offset.">mint</a>()<span class="keyword"> const </span>{ |
| 175 | <a name="l00204"></a>00204 <span class="keywordflow">return</span> min (<a class="code" href="classbdm_1_1RV.html#ef6703854820bbf61736738f1bac6896" title="Vector of shifts from current time.">times</a>); |
| 176 | <a name="l00205"></a>00205 } |
| 177 | <a name="l00207"></a>00207 |
| 178 | <a name="l00222"></a>00222 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1RV.html#6564bdd36b6845a51446a192d33e1194" title="UI for class RV (description of data vectors).">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>); |
| 179 | <a name="l00223"></a>00223 |
| 180 | <a name="l00224"></a>00224 <span class="comment">// TODO dodelat void to_setting( Setting &set ) const;</span> |
| 181 | <a name="l00226"></a>00226 <span class="comment"></span> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1RV.html#ab92b361335a644df654cf7cf7e5ffc0" title="Invalidate all named RVs. Use before initializing any RV instances, with care...">clear_all</a>(); |
182 | | <a name="l00232"></a>00232 |
183 | | <a name="l00233"></a><a class="code" href="classbdm_1_1epdf.html">00233</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> |
184 | | <a name="l00234"></a>00234 { |
185 | | <a name="l00235"></a>00235 <span class="keyword">protected</span>: |
186 | | <a name="l00237"></a><a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce">00237</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>; |
187 | | <a name="l00239"></a><a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8">00239</a> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>; |
188 | | <a name="l00240"></a>00240 |
189 | | <a name="l00241"></a>00241 <span class="keyword">public</span>: |
190 | | <a name="l00253"></a>00253 <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>() : <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>(0), <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>() {}; |
191 | | <a name="l00254"></a>00254 <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> &e) : <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>(e.<a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>), <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>(e.<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>) {}; |
192 | | <a name="l00255"></a>00255 epdf(<span class="keyword">const</span> RV &rv0) {<a class="code" href="classbdm_1_1epdf.html#f423e28448dbb69ef4905295ec8de8ff" title="Name its rv.">set_rv</a>(rv0);}; |
193 | | <a name="l00256"></a>00256 <span class="keywordtype">void</span> set_parameters(<span class="keywordtype">int</span> dim0) {<a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = dim0;} |
194 | | <a name="l00258"></a>00258 |
195 | | <a name="l00261"></a>00261 |
196 | | <a name="l00263"></a><a class="code" href="classbdm_1_1epdf.html#75ba57a89681a8efec488f5796c7cc1b">00263</a> <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1epdf.html#75ba57a89681a8efec488f5796c7cc1b" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{it_error(<span class="stringliteral">"not implemneted"</span>); <span class="keywordflow">return</span> vec(0);}; |
197 | | <a name="l00265"></a>00265 <span class="keyword">virtual</span> mat <a class="code" href="classbdm_1_1epdf.html#b4cf45fd83cc7573ede9fe1215256058" title="Returns N samples, from density .">sample_m</a>(<span class="keywordtype">int</span> N) <span class="keyword">const</span>; |
198 | | <a name="l00267"></a><a class="code" href="classbdm_1_1epdf.html#deab266d63c236c277538867d5c3f249">00267</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1epdf.html#deab266d63c236c277538867d5c3f249" title="Compute log-probability of argument val.">evallog</a>(<span class="keyword">const</span> vec &val)<span class="keyword"> const </span>{it_error(<span class="stringliteral">"not implemneted"</span>); <span class="keywordflow">return</span> 0.0;}; |
199 | | <a name="l00269"></a><a class="code" href="classbdm_1_1epdf.html#34956d4dd3176eeb5937cf48a1546b62">00269</a> <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1epdf.html#34956d4dd3176eeb5937cf48a1546b62" title="Compute log-probability of multiple values argument val.">evallog_m</a>(<span class="keyword">const</span> mat &Val)<span class="keyword"> const </span>{ |
200 | | <a name="l00270"></a>00270 vec x(Val.cols()); |
201 | | <a name="l00271"></a>00271 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < Val.cols(); i++) {x(i) = <a class="code" href="classbdm_1_1epdf.html#deab266d63c236c277538867d5c3f249" title="Compute log-probability of argument val.">evallog</a>(Val.get_col(i)) ;} |
202 | | <a name="l00272"></a>00272 <span class="keywordflow">return</span> x; |
203 | | <a name="l00273"></a>00273 } |
204 | | <a name="l00275"></a><a class="code" href="classbdm_1_1epdf.html#512dbf057299e871fbc61ed55acb5888">00275</a> <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1epdf.html#512dbf057299e871fbc61ed55acb5888" title="Compute log-probability of multiple values argument val.">evallog_m</a>(<span class="keyword">const</span> Array<vec> &Avec)<span class="keyword"> const </span>{ |
205 | | <a name="l00276"></a>00276 vec x(Avec.size()); |
206 | | <a name="l00277"></a>00277 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < Avec.size(); i++) {x(i) = <a class="code" href="classbdm_1_1epdf.html#deab266d63c236c277538867d5c3f249" title="Compute log-probability of argument val.">evallog</a>(Avec(i)) ;} |
207 | | <a name="l00278"></a>00278 <span class="keywordflow">return</span> x; |
208 | | <a name="l00279"></a>00279 } |
209 | | <a name="l00281"></a><a class="code" href="classbdm_1_1epdf.html#e584eac5579c1b6384947ecf66166c77">00281</a> <span class="keyword">virtual</span> <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_1epdf.html#e584eac5579c1b6384947ecf66166c77" title="Return conditional density on the given RV, the remaining rvs will be in conditioning...">condition</a>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>)<span class="keyword"> const </span>{it_warning(<span class="stringliteral">"Not implemented"</span>); <span class="keywordflow">return</span> NULL;} |
210 | | <a name="l00282"></a>00282 |
211 | | <a name="l00284"></a><a class="code" href="classbdm_1_1epdf.html#3fb2ece54f720b62ad325e61214fa0a1">00284</a> <span class="keyword">virtual</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* <a class="code" href="classbdm_1_1epdf.html#3fb2ece54f720b62ad325e61214fa0a1" title="Return marginal density on the given RV, the remainig rvs are intergrated out.">marginal</a>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>)<span class="keyword"> const </span>{it_warning(<span class="stringliteral">"Not implemented"</span>); <span class="keywordflow">return</span> NULL;} |
212 | | <a name="l00285"></a>00285 |
213 | | <a name="l00287"></a><a class="code" href="classbdm_1_1epdf.html#0c8d13d788094605b3cdab20a6e22b75">00287</a> <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1epdf.html#0c8d13d788094605b3cdab20a6e22b75" title="return expected value">mean</a>()<span class="keyword"> const </span>{it_error(<span class="stringliteral">"not implemneted"</span>); <span class="keywordflow">return</span> vec(0);}; |
214 | | <a name="l00288"></a>00288 |
215 | | <a name="l00290"></a><a class="code" href="classbdm_1_1epdf.html#4543d40ccfc5d549b0c831a57a3ed84c">00290</a> <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1epdf.html#4543d40ccfc5d549b0c831a57a3ed84c" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{it_error(<span class="stringliteral">"not implemneted"</span>); <span class="keywordflow">return</span> vec(0);}; |
216 | | <a name="l00292"></a><a class="code" href="classbdm_1_1epdf.html#0a7705e80601957f7226d333a0a6d539">00292</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1epdf.html#0a7705e80601957f7226d333a0a6d539" title="Lower and upper bounds of percentage % quantile, returns mean-2*sigma as default...">qbounds</a>(vec &lb, vec &ub, <span class="keywordtype">double</span> percentage = 0.95)<span class="keyword"> const </span>{ |
217 | | <a name="l00293"></a>00293 vec mea = <a class="code" href="classbdm_1_1epdf.html#0c8d13d788094605b3cdab20a6e22b75" title="return expected value">mean</a>(); |
218 | | <a name="l00294"></a>00294 vec std = sqrt(<a class="code" href="classbdm_1_1epdf.html#4543d40ccfc5d549b0c831a57a3ed84c" title="return expected variance (not covariance!)">variance</a>()); |
219 | | <a name="l00295"></a>00295 lb = mea - 2 * std; |
220 | | <a name="l00296"></a>00296 ub = mea + 2 * std; |
221 | | <a name="l00297"></a>00297 }; |
222 | | <a name="l00299"></a>00299 |
223 | | <a name="l00305"></a>00305 |
224 | | <a name="l00307"></a><a class="code" href="classbdm_1_1epdf.html#f423e28448dbb69ef4905295ec8de8ff">00307</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1epdf.html#f423e28448dbb69ef4905295ec8de8ff" title="Name its rv.">set_rv</a>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv0) {<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> = rv0; } <span class="comment">//it_assert_debug(isnamed(),""); };</span> |
225 | | <a name="l00309"></a><a class="code" href="classbdm_1_1epdf.html#c4b863ff84c7a4882fb3ad18556027f9">00309</a> <span class="comment"></span> <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1epdf.html#c4b863ff84c7a4882fb3ad18556027f9" title="True if rv is assigned.">isnamed</a>()<span class="keyword"> const </span>{<span class="keywordtype">bool</span> b = (<a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> == <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>()); <span class="keywordflow">return</span> b;} |
226 | | <a name="l00311"></a><a class="code" href="classbdm_1_1epdf.html#a4ab378d5e004c3ff3e2d4e64f7bba21">00311</a> <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a>& <a class="code" href="classbdm_1_1epdf.html#a4ab378d5e004c3ff3e2d4e64f7bba21" title="Return name (fails when isnamed is false).">_rv</a>()<span class="keyword"> const </span>{it_assert_debug(<a class="code" href="classbdm_1_1epdf.html#c4b863ff84c7a4882fb3ad18556027f9" title="True if rv is assigned.">isnamed</a>(), <span class="stringliteral">""</span>); <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>;} |
| 186 | <a name="l00232"></a>00232 RV concat (<span class="keyword">const</span> RV &rv1, <span class="keyword">const</span> RV &rv2); |
| 187 | <a name="l00233"></a>00233 |
| 188 | <a name="l00235"></a>00235 <span class="keyword">extern</span> RV RV0; |
| 189 | <a name="l00236"></a>00236 |
| 190 | <a name="l00238"></a>00238 |
| 191 | <a name="l00239"></a><a class="code" href="classbdm_1_1fnc.html">00239</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1fnc.html" title="Class representing function of variable represented by rv.">fnc</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> |
| 192 | <a name="l00240"></a>00240 { |
| 193 | <a name="l00241"></a>00241 <span class="keyword">protected</span>: |
| 194 | <a name="l00243"></a><a class="code" href="classbdm_1_1fnc.html#52156cb4a52a62d51fc7455985797a62">00243</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1fnc.html#52156cb4a52a62d51fc7455985797a62" title="Length of the output vector.">dimy</a>; |
| 195 | <a name="l00244"></a>00244 <span class="keyword">public</span>: |
| 196 | <a name="l00246"></a><a class="code" href="classbdm_1_1fnc.html#65e9fb11f6cc7884018d8f229bcabbb7">00246</a> <a class="code" href="classbdm_1_1fnc.html#65e9fb11f6cc7884018d8f229bcabbb7" title="default constructor">fnc</a>() {}; |
| 197 | <a name="l00248"></a><a class="code" href="classbdm_1_1fnc.html#6277b11d7fffc7ef8a2fa3e84ae5bad4">00248</a> <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1fnc.html#6277b11d7fffc7ef8a2fa3e84ae5bad4" title="function evaluates numerical value of at cond ">eval</a> (<span class="keyword">const</span> vec &cond) { |
| 198 | <a name="l00249"></a>00249 <span class="keywordflow">return</span> vec (0); |
| 199 | <a name="l00250"></a>00250 }; |
| 200 | <a name="l00251"></a>00251 |
| 201 | <a name="l00253"></a><a class="code" href="classbdm_1_1fnc.html#0786e40fade2663a70d654c1dda5d73e">00253</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1fnc.html#0786e40fade2663a70d654c1dda5d73e" title="function substitutes given value into an appropriate position">condition</a> (<span class="keyword">const</span> vec &val) {}; |
| 202 | <a name="l00254"></a>00254 |
| 203 | <a name="l00256"></a><a class="code" href="classbdm_1_1fnc.html#083832294da9d1e40804158b979c4341">00256</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1fnc.html#083832294da9d1e40804158b979c4341" title="access function">dimension</a>()<span class="keyword"> const </span>{ |
| 204 | <a name="l00257"></a>00257 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1fnc.html#52156cb4a52a62d51fc7455985797a62" title="Length of the output vector.">dimy</a>; |
| 205 | <a name="l00258"></a>00258 } |
| 206 | <a name="l00259"></a>00259 }; |
| 207 | <a name="l00260"></a>00260 |
| 208 | <a name="l00261"></a>00261 <span class="keyword">class </span>mpdf; |
| 209 | <a name="l00262"></a>00262 |
| 210 | <a name="l00264"></a>00264 |
| 211 | <a name="l00265"></a><a class="code" href="classbdm_1_1epdf.html">00265</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> |
| 212 | <a name="l00266"></a>00266 { |
| 213 | <a name="l00267"></a>00267 <span class="keyword">protected</span>: |
| 214 | <a name="l00269"></a><a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce">00269</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>; |
| 215 | <a name="l00271"></a><a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8">00271</a> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>; |
| 216 | <a name="l00272"></a>00272 |
| 217 | <a name="l00273"></a>00273 <span class="keyword">public</span>: |
| 218 | <a name="l00285"></a>00285 <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>() : <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> (0), <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>() {}; |
| 219 | <a name="l00286"></a>00286 <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> &e) : <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> (e.<a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>), <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> (e.<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>) {}; |
| 220 | <a name="l00287"></a>00287 epdf (<span class="keyword">const</span> RV &rv0) : <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> (rv0._dsize()) { |
| 221 | <a name="l00288"></a>00288 <a class="code" href="classbdm_1_1epdf.html#f423e28448dbb69ef4905295ec8de8ff" title="Name its rv.">set_rv</a> (rv0); |
| 222 | <a name="l00289"></a>00289 }; |
| 223 | <a name="l00290"></a>00290 <span class="keywordtype">void</span> set_parameters (<span class="keywordtype">int</span> dim0) { |
| 224 | <a name="l00291"></a>00291 <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = dim0; |
| 225 | <a name="l00292"></a>00292 } |
| 226 | <a name="l00294"></a>00294 |
| 227 | <a name="l00297"></a>00297 |
| 228 | <a name="l00299"></a><a class="code" href="classbdm_1_1epdf.html#75ba57a89681a8efec488f5796c7cc1b">00299</a> <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1epdf.html#75ba57a89681a8efec488f5796c7cc1b" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{ |
| 229 | <a name="l00300"></a>00300 it_error (<span class="stringliteral">"not implemented"</span>); |
| 230 | <a name="l00301"></a>00301 <span class="keywordflow">return</span> vec (0); |
| 231 | <a name="l00302"></a>00302 } |
| 232 | <a name="l00303"></a>00303 |
| 233 | <a name="l00305"></a>00305 <span class="keyword">virtual</span> mat <a class="code" href="classbdm_1_1epdf.html#b4cf45fd83cc7573ede9fe1215256058" title="Returns N samples, from density .">sample_m</a> (<span class="keywordtype">int</span> N) <span class="keyword">const</span>; |
| 234 | <a name="l00306"></a>00306 |
| 235 | <a name="l00309"></a><a class="code" href="classbdm_1_1epdf.html#deab266d63c236c277538867d5c3f249">00309</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1epdf.html#deab266d63c236c277538867d5c3f249">evallog</a> (<span class="keyword">const</span> vec &val)<span class="keyword"> const </span>{ |
| 236 | <a name="l00310"></a>00310 it_error (<span class="stringliteral">"not implemented"</span>); |
| 237 | <a name="l00311"></a>00311 <span class="keywordflow">return</span> 0.0; |
| 238 | <a name="l00312"></a>00312 } |
229 | | <a name="l00318"></a><a class="code" href="classbdm_1_1epdf.html#7083a65f7b7a0d0d13b2c516bd2ec29c">00318</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1epdf.html#7083a65f7b7a0d0d13b2c516bd2ec29c" title="Size of the random variable.">dimension</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>;} |
230 | | <a name="l00326"></a><a class="code" href="classbdm_1_1epdf.html#fa9efc98a065b31c630fe18cc418f725">00326</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1epdf.html#fa9efc98a065b31c630fe18cc418f725">from_setting</a>(<span class="keyword">const</span> Setting &<span class="keyword">set</span>){ |
231 | | <a name="l00327"></a>00327 <span class="keywordflow">if</span> (<span class="keyword">set</span>.exists(<span class="stringliteral">"rv"</span>)){ |
232 | | <a name="l00328"></a>00328 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a>* r = UI::build<RV>(<span class="keyword">set</span>,<span class="stringliteral">"rv"</span>); |
233 | | <a name="l00329"></a>00329 <a class="code" href="classbdm_1_1epdf.html#f423e28448dbb69ef4905295ec8de8ff" title="Name its rv.">set_rv</a>(*r); |
234 | | <a name="l00330"></a>00330 <span class="keyword">delete</span> r; |
235 | | <a name="l00331"></a>00331 } |
236 | | <a name="l00332"></a>00332 } |
237 | | <a name="l00333"></a>00333 |
238 | | <a name="l00334"></a>00334 }; |
239 | | <a name="l00335"></a>00335 |
240 | | <a name="l00336"></a>00336 |
241 | | <a name="l00338"></a>00338 <span class="comment">//TODO Samplecond can be generalized</span> |
242 | | <a name="l00339"></a>00339 |
243 | | <a name="l00340"></a><a class="code" href="classbdm_1_1mpdf.html">00340</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> |
244 | | <a name="l00341"></a>00341 { |
245 | | <a name="l00342"></a>00342 <span class="keyword">protected</span>: |
246 | | <a name="l00344"></a><a class="code" href="classbdm_1_1mpdf.html#7c1900976ff13dbc09c9729b3bbff9e6">00344</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1mpdf.html#7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a>; |
247 | | <a name="l00346"></a><a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288">00346</a> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a>; |
248 | | <a name="l00348"></a><a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0">00348</a> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* <a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>; |
249 | | <a name="l00349"></a>00349 <span class="keyword">public</span>: |
250 | | <a name="l00352"></a>00352 |
251 | | <a name="l00353"></a>00353 <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_1mpdf.html#7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a>(0), <a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a>() {}; |
252 | | <a name="l00355"></a><a class="code" href="classbdm_1_1mpdf.html#7089fcbd918f201fdf4256119e31f173">00355</a> <a class="code" href="classbdm_1_1mpdf.html#7089fcbd918f201fdf4256119e31f173" title="copy constructor does not set pointer ep - has to be done in offsprings!">mpdf</a>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> &m) : <a class="code" href="classbdm_1_1mpdf.html#7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a>(m.<a class="code" href="classbdm_1_1mpdf.html#7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a>), <a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a>(m.<a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a>) {}; |
253 | | <a name="l00357"></a>00357 |
254 | | <a name="l00360"></a>00360 |
255 | | <a name="l00362"></a><a class="code" href="classbdm_1_1mpdf.html#f0c1db6fcbb3aae2dd6123884457a367">00362</a> <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1mpdf.html#f0c1db6fcbb3aae2dd6123884457a367" title="Returns a sample from the density conditioned on cond, .">samplecond</a>(<span class="keyword">const</span> vec &cond) { |
256 | | <a name="l00363"></a>00363 this-><a class="code" href="classbdm_1_1mpdf.html#db94784a9aacf74c65c5a014f6743530" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a>(cond); |
257 | | <a name="l00364"></a>00364 vec temp = <a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>-><a class="code" href="classbdm_1_1epdf.html#75ba57a89681a8efec488f5796c7cc1b" title="Returns a sample, from density .">sample</a>(); |
258 | | <a name="l00365"></a>00365 <span class="keywordflow">return</span> temp; |
259 | | <a name="l00366"></a>00366 }; |
260 | | <a name="l00368"></a><a class="code" href="classbdm_1_1mpdf.html#afe4185b26baeb03688202e254d3b005">00368</a> <span class="keyword">virtual</span> mat <a class="code" href="classbdm_1_1mpdf.html#afe4185b26baeb03688202e254d3b005" title="Returns.">samplecond_m</a>(<span class="keyword">const</span> vec &cond, <span class="keywordtype">int</span> N) { |
261 | | <a name="l00369"></a>00369 this-><a class="code" href="classbdm_1_1mpdf.html#db94784a9aacf74c65c5a014f6743530" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a>(cond); |
262 | | <a name="l00370"></a>00370 mat temp(<a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>-><a class="code" href="classbdm_1_1epdf.html#7083a65f7b7a0d0d13b2c516bd2ec29c" title="Size of the random variable.">dimension</a>(), N); |
263 | | <a name="l00371"></a>00371 vec smp(<a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>-><a class="code" href="classbdm_1_1epdf.html#7083a65f7b7a0d0d13b2c516bd2ec29c" title="Size of the random variable.">dimension</a>()); |
264 | | <a name="l00372"></a>00372 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < N; i++) {smp = <a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>-><a class="code" href="classbdm_1_1epdf.html#75ba57a89681a8efec488f5796c7cc1b" title="Returns a sample, from density .">sample</a>() ; temp.set_col(i, smp);} |
265 | | <a name="l00373"></a>00373 <span class="keywordflow">return</span> temp; |
266 | | <a name="l00374"></a>00374 }; |
267 | | <a name="l00376"></a><a class="code" href="classbdm_1_1mpdf.html#db94784a9aacf74c65c5a014f6743530">00376</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mpdf.html#db94784a9aacf74c65c5a014f6743530" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a>(<span class="keyword">const</span> vec &cond) {it_error(<span class="stringliteral">"Not implemented"</span>);}; |
268 | | <a name="l00377"></a>00377 |
269 | | <a name="l00379"></a><a class="code" href="classbdm_1_1mpdf.html#6336a8a72462e2a56a3989a220f18b1b">00379</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mpdf.html#6336a8a72462e2a56a3989a220f18b1b" title="Shortcut for conditioning and evaluation of the internal epdf. In some cases, this...">evallogcond</a>(<span class="keyword">const</span> vec &dt, <span class="keyword">const</span> vec &cond) { |
270 | | <a name="l00380"></a>00380 <span class="keywordtype">double</span> tmp; |
271 | | <a name="l00381"></a>00381 this-><a class="code" href="classbdm_1_1mpdf.html#db94784a9aacf74c65c5a014f6743530" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a>(cond); |
272 | | <a name="l00382"></a>00382 tmp = <a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>-><a class="code" href="classbdm_1_1epdf.html#deab266d63c236c277538867d5c3f249" title="Compute log-probability of argument val.">evallog</a>(dt); |
273 | | <a name="l00383"></a>00383 it_assert_debug(std::isfinite(tmp), <span class="stringliteral">"Infinite value"</span>); |
274 | | <a name="l00384"></a>00384 <span class="keywordflow">return</span> tmp; |
275 | | <a name="l00385"></a>00385 }; |
276 | | <a name="l00386"></a>00386 |
277 | | <a name="l00388"></a><a class="code" href="classbdm_1_1mpdf.html#0b0ed1ed663071bb7cf4a1349eb94fcb">00388</a> <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1mpdf.html#0b0ed1ed663071bb7cf4a1349eb94fcb" title="Matrix version of evallogcond.">evallogcond_m</a>(<span class="keyword">const</span> mat &Dt, <span class="keyword">const</span> vec &cond) {this-><a class="code" href="classbdm_1_1mpdf.html#db94784a9aacf74c65c5a014f6743530" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a>(cond); <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>-><a class="code" href="classbdm_1_1epdf.html#34956d4dd3176eeb5937cf48a1546b62" title="Compute log-probability of multiple values argument val.">evallog_m</a>(Dt);}; |
278 | | <a name="l00390"></a><a class="code" href="classbdm_1_1mpdf.html#2a0d03756f59924fd038980ee60bd904">00390</a> <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1mpdf.html#2a0d03756f59924fd038980ee60bd904" title="Array&lt;vec&gt; version of evallogcond.">evallogcond_m</a>(<span class="keyword">const</span> Array<vec> &Dt, <span class="keyword">const</span> vec &cond) {this-><a class="code" href="classbdm_1_1mpdf.html#db94784a9aacf74c65c5a014f6743530" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a>(cond); <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>-><a class="code" href="classbdm_1_1epdf.html#34956d4dd3176eeb5937cf48a1546b62" title="Compute log-probability of multiple values argument val.">evallog_m</a>(Dt);}; |
| 242 | <a name="l00318"></a>00318 <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1epdf.html#d08b68a5abd461f1b6519597e344caf8" title="Compute log-probability of multiple values argument val.">evallog_m</a> (<span class="keyword">const</span> Array<vec> &Avec) <span class="keyword">const</span>; |
| 243 | <a name="l00319"></a>00319 |
| 244 | <a name="l00321"></a>00321 <span class="keyword">virtual</span> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<mpdf></a> <a class="code" href="classbdm_1_1epdf.html#1499d35b79bce0cfa64fc5cafb9c03b2" title="Return conditional density on the given RV, the remaining rvs will be in conditioning...">condition</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>) <span class="keyword">const</span>; |
| 245 | <a name="l00322"></a>00322 |
| 246 | <a name="l00324"></a>00324 <span class="keyword">virtual</span> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<epdf></a> <a class="code" href="classbdm_1_1epdf.html#a84b05f5293cab2aeb4e07faffa60906" title="Return marginal density on the given RV, the remainig rvs are intergrated out.">marginal</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>) <span class="keyword">const</span>; |
| 247 | <a name="l00325"></a>00325 |
| 248 | <a name="l00327"></a><a class="code" href="classbdm_1_1epdf.html#0c8d13d788094605b3cdab20a6e22b75">00327</a> <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1epdf.html#0c8d13d788094605b3cdab20a6e22b75" title="return expected value">mean</a>()<span class="keyword"> const </span>{ |
| 249 | <a name="l00328"></a>00328 it_error (<span class="stringliteral">"not implemneted"</span>); |
| 250 | <a name="l00329"></a>00329 <span class="keywordflow">return</span> vec (0); |
| 251 | <a name="l00330"></a>00330 }; |
| 252 | <a name="l00331"></a>00331 |
| 253 | <a name="l00333"></a><a class="code" href="classbdm_1_1epdf.html#4543d40ccfc5d549b0c831a57a3ed84c">00333</a> <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1epdf.html#4543d40ccfc5d549b0c831a57a3ed84c" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{ |
| 254 | <a name="l00334"></a>00334 it_error (<span class="stringliteral">"not implemneted"</span>); |
| 255 | <a name="l00335"></a>00335 <span class="keywordflow">return</span> vec (0); |
| 256 | <a name="l00336"></a>00336 }; |
| 257 | <a name="l00338"></a><a class="code" href="classbdm_1_1epdf.html#0a7705e80601957f7226d333a0a6d539">00338</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1epdf.html#0a7705e80601957f7226d333a0a6d539" title="Lower and upper bounds of percentage % quantile, returns mean-2*sigma as default...">qbounds</a> (vec &lb, vec &ub, <span class="keywordtype">double</span> percentage = 0.95)<span class="keyword"> const </span>{ |
| 258 | <a name="l00339"></a>00339 vec mea = <a class="code" href="classbdm_1_1epdf.html#0c8d13d788094605b3cdab20a6e22b75" title="return expected value">mean</a>(); |
| 259 | <a name="l00340"></a>00340 vec std = sqrt (<a class="code" href="classbdm_1_1epdf.html#4543d40ccfc5d549b0c831a57a3ed84c" title="return expected variance (not covariance!)">variance</a>()); |
| 260 | <a name="l00341"></a>00341 lb = mea - 2 * std; |
| 261 | <a name="l00342"></a>00342 ub = mea + 2 * std; |
| 262 | <a name="l00343"></a>00343 }; |
| 263 | <a name="l00345"></a>00345 |
| 264 | <a name="l00351"></a>00351 |
| 265 | <a name="l00353"></a><a class="code" href="classbdm_1_1epdf.html#f423e28448dbb69ef4905295ec8de8ff">00353</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1epdf.html#f423e28448dbb69ef4905295ec8de8ff" title="Name its rv.">set_rv</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv0) { |
| 266 | <a name="l00354"></a>00354 <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> = rv0; |
| 267 | <a name="l00355"></a>00355 } <span class="comment">//it_assert_debug(isnamed(),""); };</span> |
| 268 | <a name="l00357"></a><a class="code" href="classbdm_1_1epdf.html#c4b863ff84c7a4882fb3ad18556027f9">00357</a> <span class="comment"></span> <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1epdf.html#c4b863ff84c7a4882fb3ad18556027f9" title="True if rv is assigned.">isnamed</a>()<span class="keyword"> const </span>{ |
| 269 | <a name="l00358"></a>00358 <span class="keywordtype">bool</span> b = (<a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> == <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>()); |
| 270 | <a name="l00359"></a>00359 <span class="keywordflow">return</span> b; |
| 271 | <a name="l00360"></a>00360 } |
| 272 | <a name="l00362"></a><a class="code" href="classbdm_1_1epdf.html#a4ab378d5e004c3ff3e2d4e64f7bba21">00362</a> <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a>& <a class="code" href="classbdm_1_1epdf.html#a4ab378d5e004c3ff3e2d4e64f7bba21" title="Return name (fails when isnamed is false).">_rv</a>()<span class="keyword"> const </span>{ |
| 273 | <a name="l00363"></a>00363 it_assert_debug (<a class="code" href="classbdm_1_1epdf.html#c4b863ff84c7a4882fb3ad18556027f9" title="True if rv is assigned.">isnamed</a>(), <span class="stringliteral">""</span>); |
| 274 | <a name="l00364"></a>00364 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>; |
| 275 | <a name="l00365"></a>00365 } |
| 276 | <a name="l00367"></a>00367 |
| 277 | <a name="l00370"></a>00370 |
| 278 | <a name="l00372"></a><a class="code" href="classbdm_1_1epdf.html#7083a65f7b7a0d0d13b2c516bd2ec29c">00372</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1epdf.html#7083a65f7b7a0d0d13b2c516bd2ec29c" title="Size of the random variable.">dimension</a>()<span class="keyword"> const </span>{ |
| 279 | <a name="l00373"></a>00373 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>; |
| 280 | <a name="l00374"></a>00374 } |
| 281 | <a name="l00382"></a><a class="code" href="classbdm_1_1epdf.html#fa9efc98a065b31c630fe18cc418f725">00382</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1epdf.html#fa9efc98a065b31c630fe18cc418f725">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>) { |
| 282 | <a name="l00383"></a>00383 <a class="code" href="classbdm_1_1shared__ptr.html" title="A naive implementation of roughly a subset of the std::tr1:shared_ptr spec.">shared_ptr<RV></a> r = UI::build<RV> ( <span class="keyword">set</span>, <span class="stringliteral">"rv"</span>, UI::optional ); |
| 283 | <a name="l00384"></a>00384 <span class="keywordflow">if</span> (r) { |
| 284 | <a name="l00385"></a>00385 <a class="code" href="classbdm_1_1epdf.html#f423e28448dbb69ef4905295ec8de8ff" title="Name its rv.">set_rv</a> (*r); |
| 285 | <a name="l00386"></a>00386 } |
| 286 | <a name="l00387"></a>00387 } |
| 287 | <a name="l00388"></a>00388 |
| 288 | <a name="l00389"></a>00389 }; |
| 289 | <a name="l00390"></a>00390 SHAREDPTR(epdf); |
300 | | <a name="l00425"></a>00425 <span class="keywordtype">void</span> set_rvc(<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rvc0) {<a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a> = rvc0;} |
301 | | <a name="l00426"></a>00426 <span class="keywordtype">void</span> set_rv(<span class="keyword">const</span> RV &rv0) {<a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>->set_rv(rv0);} |
302 | | <a name="l00427"></a>00427 <span class="keywordtype">bool</span> isnamed() {<span class="keywordflow">return</span> (<a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>->isnamed()) && (<a class="code" href="classbdm_1_1mpdf.html#7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a> == <a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a>._dsize());} |
303 | | <a name="l00429"></a>00429 }; |
304 | | <a name="l00430"></a>00430 |
305 | | <a name="l00456"></a><a class="code" href="classbdm_1_1datalink.html">00456</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1datalink.html" title="DataLink is a connection between two data vectors Up and Down.">datalink</a> |
306 | | <a name="l00457"></a>00457 { |
307 | | <a name="l00458"></a>00458 <span class="keyword">protected</span>: |
308 | | <a name="l00460"></a><a class="code" href="classbdm_1_1datalink.html#bc8ff50395fc1066a1e486dea18d987c">00460</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1datalink.html#bc8ff50395fc1066a1e486dea18d987c" title="Remember how long val should be.">downsize</a>; |
309 | | <a name="l00462"></a><a class="code" href="classbdm_1_1datalink.html#0f0d0af6848114d96108d3a6af25a045">00462</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1datalink.html#0f0d0af6848114d96108d3a6af25a045" title="Remember how long val of &quot;Up&quot; should be.">upsize</a>; |
310 | | <a name="l00464"></a><a class="code" href="classbdm_1_1datalink.html#240b37d793c6bdc32824ed0a0541b1eb">00464</a> ivec <a class="code" href="classbdm_1_1datalink.html#240b37d793c6bdc32824ed0a0541b1eb" title="val-to-val link, indeces of the upper val">v2v_up</a>; |
311 | | <a name="l00465"></a>00465 <span class="keyword">public</span>: |
312 | | <a name="l00467"></a><a class="code" href="classbdm_1_1datalink.html#b8b5d5074fc1310a37c3713d58b900e2">00467</a> <a class="code" href="classbdm_1_1datalink.html#b8b5d5074fc1310a37c3713d58b900e2" title="Constructor.">datalink</a>() {}; |
313 | | <a name="l00468"></a>00468 <a class="code" href="classbdm_1_1datalink.html#b8b5d5074fc1310a37c3713d58b900e2" title="Constructor.">datalink</a>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv_up) {<a class="code" href="classbdm_1_1datalink.html#fb8337aac8329eb0ca96bfb3ff73ec67" title="set connection, rv must be fully present in rv_up">set_connection</a>(rv, rv_up);}; |
314 | | <a name="l00470"></a><a class="code" href="classbdm_1_1datalink.html#fb8337aac8329eb0ca96bfb3ff73ec67">00470</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1datalink.html#fb8337aac8329eb0ca96bfb3ff73ec67" title="set connection, rv must be fully present in rv_up">set_connection</a>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv_up) { |
315 | | <a name="l00471"></a>00471 <a class="code" href="classbdm_1_1datalink.html#bc8ff50395fc1066a1e486dea18d987c" title="Remember how long val should be.">downsize</a> = rv.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(); |
316 | | <a name="l00472"></a>00472 <a class="code" href="classbdm_1_1datalink.html#0f0d0af6848114d96108d3a6af25a045" title="Remember how long val of &quot;Up&quot; should be.">upsize</a> = rv_up.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(); |
317 | | <a name="l00473"></a>00473 <a class="code" href="classbdm_1_1datalink.html#240b37d793c6bdc32824ed0a0541b1eb" title="val-to-val link, indeces of the upper val">v2v_up</a> = (rv.<a class="code" href="classbdm_1_1RV.html#cbebdb5e0d30101a6eb63550ef701c55">dataind</a>(rv_up)); |
318 | | <a name="l00474"></a>00474 |
319 | | <a name="l00475"></a>00475 it_assert_debug(<a class="code" href="classbdm_1_1datalink.html#240b37d793c6bdc32824ed0a0541b1eb" title="val-to-val link, indeces of the upper val">v2v_up</a>.length() == <a class="code" href="classbdm_1_1datalink.html#bc8ff50395fc1066a1e486dea18d987c" title="Remember how long val should be.">downsize</a>, <span class="stringliteral">"rv is not fully in rv_up"</span>); |
320 | | <a name="l00476"></a>00476 } |
321 | | <a name="l00478"></a><a class="code" href="classbdm_1_1datalink.html#724486a37002e7a3a73366c3af9b82ad">00478</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1datalink.html#724486a37002e7a3a73366c3af9b82ad" title="set connection using indeces">set_connection</a>(<span class="keywordtype">int</span> ds, <span class="keywordtype">int</span> us, <span class="keyword">const</span> ivec &upind) { |
322 | | <a name="l00479"></a>00479 <a class="code" href="classbdm_1_1datalink.html#bc8ff50395fc1066a1e486dea18d987c" title="Remember how long val should be.">downsize</a> = ds; |
323 | | <a name="l00480"></a>00480 <a class="code" href="classbdm_1_1datalink.html#0f0d0af6848114d96108d3a6af25a045" title="Remember how long val of &quot;Up&quot; should be.">upsize</a> = us; |
324 | | <a name="l00481"></a>00481 <a class="code" href="classbdm_1_1datalink.html#240b37d793c6bdc32824ed0a0541b1eb" title="val-to-val link, indeces of the upper val">v2v_up</a> = upind; |
325 | | <a name="l00482"></a>00482 |
326 | | <a name="l00483"></a>00483 it_assert_debug(<a class="code" href="classbdm_1_1datalink.html#240b37d793c6bdc32824ed0a0541b1eb" title="val-to-val link, indeces of the upper val">v2v_up</a>.length() == <a class="code" href="classbdm_1_1datalink.html#bc8ff50395fc1066a1e486dea18d987c" title="Remember how long val should be.">downsize</a>, <span class="stringliteral">"rv is not fully in rv_up"</span>); |
327 | | <a name="l00484"></a>00484 } |
328 | | <a name="l00486"></a><a class="code" href="classbdm_1_1datalink.html#5b5368c3899eed2f670d09142c2548e5">00486</a> vec <a class="code" href="classbdm_1_1datalink.html#5b5368c3899eed2f670d09142c2548e5" title="Get val for myself from val of &quot;Up&quot;.">pushdown</a>(<span class="keyword">const</span> vec &val_up) { |
329 | | <a name="l00487"></a>00487 it_assert_debug(<a class="code" href="classbdm_1_1datalink.html#0f0d0af6848114d96108d3a6af25a045" title="Remember how long val of &quot;Up&quot; should be.">upsize</a> == val_up.length(), <span class="stringliteral">"Wrong val_up"</span>); |
330 | | <a name="l00488"></a>00488 <span class="keywordflow">return</span> get_vec(val_up, <a class="code" href="classbdm_1_1datalink.html#240b37d793c6bdc32824ed0a0541b1eb" title="val-to-val link, indeces of the upper val">v2v_up</a>); |
331 | | <a name="l00489"></a>00489 } |
332 | | <a name="l00491"></a><a class="code" href="classbdm_1_1datalink.html#610e966f2edb1fcd6a5b28267c571793">00491</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1datalink.html#610e966f2edb1fcd6a5b28267c571793" title="Fill val of &quot;Up&quot; by my pieces.">pushup</a>(vec &val_up, <span class="keyword">const</span> vec &val) { |
333 | | <a name="l00492"></a>00492 it_assert_debug(<a class="code" href="classbdm_1_1datalink.html#bc8ff50395fc1066a1e486dea18d987c" title="Remember how long val should be.">downsize</a> == val.length(), <span class="stringliteral">"Wrong val"</span>); |
334 | | <a name="l00493"></a>00493 it_assert_debug(<a class="code" href="classbdm_1_1datalink.html#0f0d0af6848114d96108d3a6af25a045" title="Remember how long val of &quot;Up&quot; should be.">upsize</a> == val_up.length(), <span class="stringliteral">"Wrong val_up"</span>); |
335 | | <a name="l00494"></a>00494 set_subvector(val_up, <a class="code" href="classbdm_1_1datalink.html#240b37d793c6bdc32824ed0a0541b1eb" title="val-to-val link, indeces of the upper val">v2v_up</a>, val); |
336 | | <a name="l00495"></a>00495 } |
337 | | <a name="l00496"></a>00496 }; |
338 | | <a name="l00497"></a>00497 |
339 | | <a name="l00499"></a><a class="code" href="classbdm_1_1datalink__m2e.html">00499</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1datalink__m2e.html" title="data link between">datalink_m2e</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1datalink.html" title="DataLink is a connection between two data vectors Up and Down.">datalink</a> |
340 | | <a name="l00500"></a>00500 { |
341 | | <a name="l00501"></a>00501 <span class="keyword">protected</span>: |
342 | | <a name="l00503"></a><a class="code" href="classbdm_1_1datalink__m2e.html#3fb26525e0bfa7932a37c5cd404801f9">00503</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1datalink__m2e.html#3fb26525e0bfa7932a37c5cd404801f9" title="Remember how long cond should be.">condsize</a>; |
343 | | <a name="l00505"></a><a class="code" href="classbdm_1_1datalink__m2e.html#43fe3e2d7aa04134053ec15793722783">00505</a> ivec <a class="code" href="classbdm_1_1datalink__m2e.html#43fe3e2d7aa04134053ec15793722783" title="upper_val-to-local_cond link, indeces of the upper val">v2c_up</a>; |
344 | | <a name="l00507"></a><a class="code" href="classbdm_1_1datalink__m2e.html#9e0048d87bda78e9b8d38761440c7abc">00507</a> ivec <a class="code" href="classbdm_1_1datalink__m2e.html#9e0048d87bda78e9b8d38761440c7abc" title="upper_val-to-local_cond link, ideces of the local cond">v2c_lo</a>; |
345 | | <a name="l00508"></a>00508 |
346 | | <a name="l00509"></a>00509 <span class="keyword">public</span>: |
347 | | <a name="l00510"></a>00510 <a class="code" href="classbdm_1_1datalink__m2e.html" title="data link between">datalink_m2e</a>() {}; |
348 | | <a name="l00512"></a><a class="code" href="classbdm_1_1datalink__m2e.html#add918bf877c48714cff51ee4ad989b0">00512</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1datalink__m2e.html#add918bf877c48714cff51ee4ad989b0" title="Constructor.">set_connection</a>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rvc, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv_up) { |
349 | | <a name="l00513"></a>00513 <a class="code" href="classbdm_1_1datalink__m2e.html#add918bf877c48714cff51ee4ad989b0" title="Constructor.">datalink::set_connection</a>(rv, rv_up); |
350 | | <a name="l00514"></a>00514 <a class="code" href="classbdm_1_1datalink__m2e.html#3fb26525e0bfa7932a37c5cd404801f9" title="Remember how long cond should be.">condsize</a> = rvc.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(); |
351 | | <a name="l00515"></a>00515 <span class="comment">//establish v2c connection</span> |
352 | | <a name="l00516"></a>00516 rvc.<a class="code" href="classbdm_1_1RV.html#cbebdb5e0d30101a6eb63550ef701c55">dataind</a>(rv_up, <a class="code" href="classbdm_1_1datalink__m2e.html#9e0048d87bda78e9b8d38761440c7abc" title="upper_val-to-local_cond link, ideces of the local cond">v2c_lo</a>, <a class="code" href="classbdm_1_1datalink__m2e.html#43fe3e2d7aa04134053ec15793722783" title="upper_val-to-local_cond link, indeces of the upper val">v2c_up</a>); |
353 | | <a name="l00517"></a>00517 } |
354 | | <a name="l00519"></a><a class="code" href="classbdm_1_1datalink__m2e.html#7ba850822e3cf9a4b079afc7e7c01703">00519</a> vec <a class="code" href="classbdm_1_1datalink__m2e.html#7ba850822e3cf9a4b079afc7e7c01703" title="Construct condition.">get_cond</a>(<span class="keyword">const</span> vec &val_up) { |
355 | | <a name="l00520"></a>00520 vec tmp(<a class="code" href="classbdm_1_1datalink__m2e.html#3fb26525e0bfa7932a37c5cd404801f9" title="Remember how long cond should be.">condsize</a>); |
356 | | <a name="l00521"></a>00521 set_subvector(tmp, <a class="code" href="classbdm_1_1datalink__m2e.html#9e0048d87bda78e9b8d38761440c7abc" title="upper_val-to-local_cond link, ideces of the local cond">v2c_lo</a>, val_up(<a class="code" href="classbdm_1_1datalink__m2e.html#43fe3e2d7aa04134053ec15793722783" title="upper_val-to-local_cond link, indeces of the upper val">v2c_up</a>)); |
357 | | <a name="l00522"></a>00522 <span class="keywordflow">return</span> tmp; |
358 | | <a name="l00523"></a>00523 } |
359 | | <a name="l00524"></a>00524 <span class="keywordtype">void</span> pushup_cond(vec &val_up, <span class="keyword">const</span> vec &val, <span class="keyword">const</span> vec &cond) { |
360 | | <a name="l00525"></a>00525 it_assert_debug(<a class="code" href="classbdm_1_1datalink.html#bc8ff50395fc1066a1e486dea18d987c" title="Remember how long val should be.">downsize</a> == val.length(), <span class="stringliteral">"Wrong val"</span>); |
361 | | <a name="l00526"></a>00526 it_assert_debug(<a class="code" href="classbdm_1_1datalink.html#0f0d0af6848114d96108d3a6af25a045" title="Remember how long val of &quot;Up&quot; should be.">upsize</a> == val_up.length(), <span class="stringliteral">"Wrong val_up"</span>); |
362 | | <a name="l00527"></a>00527 set_subvector(val_up, <a class="code" href="classbdm_1_1datalink.html#240b37d793c6bdc32824ed0a0541b1eb" title="val-to-val link, indeces of the upper val">v2v_up</a>, val); |
363 | | <a name="l00528"></a>00528 set_subvector(val_up, <a class="code" href="classbdm_1_1datalink__m2e.html#43fe3e2d7aa04134053ec15793722783" title="upper_val-to-local_cond link, indeces of the upper val">v2c_up</a>, cond); |
364 | | <a name="l00529"></a>00529 } |
365 | | <a name="l00530"></a>00530 }; |
366 | | <a name="l00533"></a><a class="code" href="classbdm_1_1datalink__m2m.html">00533</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1datalink__m2m.html">datalink_m2m</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1datalink__m2e.html" title="data link between">datalink_m2e</a> |
367 | | <a name="l00534"></a>00534 { |
368 | | <a name="l00535"></a>00535 <span class="keyword">protected</span>: |
369 | | <a name="l00537"></a><a class="code" href="classbdm_1_1datalink__m2m.html#d64dda6f92654628276bbcebb7600d0d">00537</a> ivec <a class="code" href="classbdm_1_1datalink__m2m.html#d64dda6f92654628276bbcebb7600d0d" title="cond-to-cond link, indeces of the upper cond">c2c_up</a>; |
370 | | <a name="l00539"></a><a class="code" href="classbdm_1_1datalink__m2m.html#0ea05c47de4538b7042ff878e6e309a5">00539</a> ivec <a class="code" href="classbdm_1_1datalink__m2m.html#0ea05c47de4538b7042ff878e6e309a5" title="cond-to-cond link, indeces of the local cond">c2c_lo</a>; |
371 | | <a name="l00540"></a>00540 <span class="keyword">public</span>: |
372 | | <a name="l00542"></a><a class="code" href="classbdm_1_1datalink__m2m.html#3baed32cb66f0e2f731032cec0a4d287">00542</a> <a class="code" href="classbdm_1_1datalink__m2m.html#3baed32cb66f0e2f731032cec0a4d287" title="Constructor.">datalink_m2m</a>() {}; |
373 | | <a name="l00543"></a>00543 <span class="keywordtype">void</span> set_connection(<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rvc, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv_up, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rvc_up) { |
374 | | <a name="l00544"></a>00544 <a class="code" href="classbdm_1_1datalink__m2e.html#add918bf877c48714cff51ee4ad989b0" title="Constructor.">datalink_m2e::set_connection</a>(rv, rvc, rv_up); |
375 | | <a name="l00545"></a>00545 <span class="comment">//establish c2c connection</span> |
376 | | <a name="l00546"></a>00546 rvc.<a class="code" href="classbdm_1_1RV.html#cbebdb5e0d30101a6eb63550ef701c55">dataind</a>(rvc_up, <a class="code" href="classbdm_1_1datalink__m2m.html#0ea05c47de4538b7042ff878e6e309a5" title="cond-to-cond link, indeces of the local cond">c2c_lo</a>, <a class="code" href="classbdm_1_1datalink__m2m.html#d64dda6f92654628276bbcebb7600d0d" title="cond-to-cond link, indeces of the upper cond">c2c_up</a>); |
377 | | <a name="l00547"></a>00547 it_assert_debug(<a class="code" href="classbdm_1_1datalink__m2m.html#0ea05c47de4538b7042ff878e6e309a5" title="cond-to-cond link, indeces of the local cond">c2c_lo</a>.length() + <a class="code" href="classbdm_1_1datalink__m2e.html#9e0048d87bda78e9b8d38761440c7abc" title="upper_val-to-local_cond link, ideces of the local cond">v2c_lo</a>.length() == <a class="code" href="classbdm_1_1datalink__m2e.html#3fb26525e0bfa7932a37c5cd404801f9" title="Remember how long cond should be.">condsize</a>, <span class="stringliteral">"cond is not fully given"</span>); |
378 | | <a name="l00548"></a>00548 } |
379 | | <a name="l00550"></a><a class="code" href="classbdm_1_1datalink__m2m.html#911fb7fcfa80d4e31db8e0cc03141a90">00550</a> vec <a class="code" href="classbdm_1_1datalink__m2m.html#911fb7fcfa80d4e31db8e0cc03141a90" title="Get cond for myself from val and cond of &quot;Up&quot;.">get_cond</a>(<span class="keyword">const</span> vec &val_up, <span class="keyword">const</span> vec &cond_up) { |
380 | | <a name="l00551"></a>00551 vec tmp(<a class="code" href="classbdm_1_1datalink__m2e.html#3fb26525e0bfa7932a37c5cd404801f9" title="Remember how long cond should be.">condsize</a>); |
381 | | <a name="l00552"></a>00552 set_subvector(tmp, <a class="code" href="classbdm_1_1datalink__m2e.html#9e0048d87bda78e9b8d38761440c7abc" title="upper_val-to-local_cond link, ideces of the local cond">v2c_lo</a>, val_up(<a class="code" href="classbdm_1_1datalink__m2e.html#43fe3e2d7aa04134053ec15793722783" title="upper_val-to-local_cond link, indeces of the upper val">v2c_up</a>)); |
382 | | <a name="l00553"></a>00553 set_subvector(tmp, <a class="code" href="classbdm_1_1datalink__m2m.html#0ea05c47de4538b7042ff878e6e309a5" title="cond-to-cond link, indeces of the local cond">c2c_lo</a>, cond_up(<a class="code" href="classbdm_1_1datalink__m2m.html#d64dda6f92654628276bbcebb7600d0d" title="cond-to-cond link, indeces of the upper cond">c2c_up</a>)); |
383 | | <a name="l00554"></a>00554 <span class="keywordflow">return</span> tmp; |
384 | | <a name="l00555"></a>00555 } |
385 | | <a name="l00557"></a>00557 |
386 | | <a name="l00558"></a>00558 }; |
387 | | <a name="l00559"></a>00559 |
388 | | <a name="l00565"></a><a class="code" href="classbdm_1_1logger.html">00565</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> |
389 | | <a name="l00566"></a>00566 { |
390 | | <a name="l00567"></a>00567 <span class="keyword">protected</span>: |
391 | | <a name="l00569"></a><a class="code" href="classbdm_1_1logger.html#c54566a4554089443a20b2a49ed1a61f">00569</a> Array<RV> <a class="code" href="classbdm_1_1logger.html#c54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a>; |
392 | | <a name="l00571"></a><a class="code" href="classbdm_1_1logger.html#68ca1f05cf3d414ba0f39211977b8d02">00571</a> Array<string> <a class="code" href="classbdm_1_1logger.html#68ca1f05cf3d414ba0f39211977b8d02" title="Names of logged quantities, e.g. names of algorithm variants.">names</a>; |
393 | | <a name="l00572"></a>00572 <span class="keyword">public</span>: |
394 | | <a name="l00574"></a><a class="code" href="classbdm_1_1logger.html#f9c2fe7db5ddbda0098a4a5bd2c29fbf">00574</a> <a class="code" href="classbdm_1_1logger.html#f9c2fe7db5ddbda0098a4a5bd2c29fbf" title="Default constructor.">logger</a>() : <a class="code" href="classbdm_1_1logger.html#c54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a>(0), <a class="code" href="classbdm_1_1logger.html#68ca1f05cf3d414ba0f39211977b8d02" title="Names of logged quantities, e.g. names of algorithm variants.">names</a>(0) {} |
395 | | <a name="l00575"></a>00575 |
396 | | <a name="l00578"></a><a class="code" href="classbdm_1_1logger.html#47aa3b098a81d02a8ffaea2c9fa09ac7">00578</a> <span class="keyword">virtual</span> <span class="keywordtype">int</span> <span class="keyword">add</span>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv, <span class="keywordtype">string</span> prefix = <span class="stringliteral">""</span>) { |
397 | | <a name="l00579"></a>00579 <span class="keywordtype">int</span> id; |
398 | | <a name="l00580"></a>00580 <span class="keywordflow">if</span> (rv.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>() > 0) { |
399 | | <a name="l00581"></a>00581 <span class="keywordtype">id</span> = <a class="code" href="classbdm_1_1logger.html#c54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a>.length(); |
400 | | <a name="l00582"></a>00582 <a class="code" href="classbdm_1_1logger.html#68ca1f05cf3d414ba0f39211977b8d02" title="Names of logged quantities, e.g. names of algorithm variants.">names</a> = concat(<a class="code" href="classbdm_1_1logger.html#68ca1f05cf3d414ba0f39211977b8d02" title="Names of logged quantities, e.g. names of algorithm variants.">names</a>, prefix); <span class="comment">// diff</span> |
401 | | <a name="l00583"></a>00583 <a class="code" href="classbdm_1_1logger.html#c54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a>.set_length(<span class="keywordtype">id</span> + 1, <span class="keyword">true</span>); |
402 | | <a name="l00584"></a>00584 <a class="code" href="classbdm_1_1logger.html#c54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a>(<span class="keywordtype">id</span>) = rv; |
403 | | <a name="l00585"></a>00585 } |
404 | | <a name="l00586"></a>00586 <span class="keywordflow">else</span> { <span class="keywordtype">id</span> = -1;} |
405 | | <a name="l00587"></a>00587 <span class="keywordflow">return</span> id; <span class="comment">// identifier of the last entry</span> |
406 | | <a name="l00588"></a>00588 } |
407 | | <a name="l00589"></a>00589 |
408 | | <a name="l00591"></a>00591 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a>(<span class="keywordtype">int</span> <span class="keywordtype">id</span>, <span class="keyword">const</span> vec &v) = 0; |
409 | | <a name="l00593"></a>00593 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a>(<span class="keywordtype">int</span> <span class="keywordtype">id</span>, <span class="keyword">const</span> <span class="keywordtype">double</span> &d) = 0; |
410 | | <a name="l00594"></a>00594 |
411 | | <a name="l00596"></a>00596 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1logger.html#4f31c03578a7b9b30d8b1f8c338a37e8" title="Shifts storage position for another time step.">step</a>() = 0; |
412 | | <a name="l00597"></a>00597 |
413 | | <a name="l00599"></a><a class="code" href="classbdm_1_1logger.html#0e3fc7d13e23a8f71fc7c8a5ea68559d">00599</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1logger.html#0e3fc7d13e23a8f71fc7c8a5ea68559d" title="Finalize storing information.">finalize</a>() {}; |
414 | | <a name="l00600"></a>00600 |
415 | | <a name="l00602"></a><a class="code" href="classbdm_1_1logger.html#cd6291a73491f755dc7bc88d022eb2fc">00602</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1logger.html#cd6291a73491f755dc7bc88d022eb2fc" title="Initialize the storage.">init</a>() {}; |
416 | | <a name="l00603"></a>00603 |
417 | | <a name="l00604"></a>00604 }; |
| 313 | <a name="l00425"></a>00425 |
| 314 | <a name="l00427"></a><a class="code" href="classbdm_1_1mpdf.html#f0c1db6fcbb3aae2dd6123884457a367">00427</a> <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1mpdf.html#f0c1db6fcbb3aae2dd6123884457a367" title="Returns a sample from the density conditioned on cond, .">samplecond</a> (<span class="keyword">const</span> vec &cond) {it_error (<span class="stringliteral">"Not implemented"</span>);<span class="keywordflow">return</span> vec (0);}; |
| 315 | <a name="l00428"></a>00428 |
| 316 | <a name="l00430"></a>00430 <span class="keyword">virtual</span> mat <a class="code" href="classbdm_1_1mpdf.html#6e497d501331057309d2fddf63259d1a" title="Returns.">samplecond_m</a> (<span class="keyword">const</span> vec &cond, <span class="keywordtype">int</span> N); |
| 317 | <a name="l00431"></a>00431 |
| 318 | <a name="l00433"></a><a class="code" href="classbdm_1_1mpdf.html#6336a8a72462e2a56a3989a220f18b1b">00433</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mpdf.html#6336a8a72462e2a56a3989a220f18b1b" title="Shortcut for conditioning and evaluation of the internal epdf. In some cases, this...">evallogcond</a> (<span class="keyword">const</span> vec &dt, <span class="keyword">const</span> vec &cond) {it_error (<span class="stringliteral">"Not implemented"</span>);<span class="keywordflow">return</span> 0.0;} |
| 319 | <a name="l00434"></a>00434 |
| 320 | <a name="l00436"></a><a class="code" href="classbdm_1_1mpdf.html#0b0ed1ed663071bb7cf4a1349eb94fcb">00436</a> <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1mpdf.html#0b0ed1ed663071bb7cf4a1349eb94fcb" title="Matrix version of evallogcond.">evallogcond_m</a> (<span class="keyword">const</span> mat &Dt, <span class="keyword">const</span> vec &cond) { |
| 321 | <a name="l00437"></a>00437 vec v(Dt.cols()); |
| 322 | <a name="l00438"></a>00438 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0;i<Dt.cols();i++){v(i)= <a class="code" href="classbdm_1_1mpdf.html#6336a8a72462e2a56a3989a220f18b1b" title="Shortcut for conditioning and evaluation of the internal epdf. In some cases, this...">evallogcond</a>(Dt.get_col(i),cond);} |
| 323 | <a name="l00439"></a>00439 <span class="keywordflow">return</span> v; |
| 324 | <a name="l00440"></a>00440 } |
| 325 | <a name="l00441"></a>00441 |
| 326 | <a name="l00443"></a><a class="code" href="classbdm_1_1mpdf.html#2a0d03756f59924fd038980ee60bd904">00443</a> <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1mpdf.html#2a0d03756f59924fd038980ee60bd904" title="Array&lt;vec&gt; version of evallogcond.">evallogcond_m</a> (<span class="keyword">const</span> Array<vec> &Dt, <span class="keyword">const</span> vec &cond) {it_error (<span class="stringliteral">"Not implemented"</span>);<span class="keywordflow">return</span> vec (0);} |
| 327 | <a name="l00444"></a>00444 |
| 328 | <a name="l00447"></a>00447 |
| 329 | <a name="l00448"></a>00448 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> _rv()<span class="keyword"> const </span>{ |
| 330 | <a name="l00449"></a>00449 <span class="keywordflow">return</span> ep-><a class="code" href="classbdm_1_1epdf.html#a4ab378d5e004c3ff3e2d4e64f7bba21" title="Return name (fails when isnamed is false).">_rv</a>(); |
| 331 | <a name="l00450"></a>00450 } |
| 332 | <a name="l00451"></a>00451 RV _rvc() { |
| 333 | <a name="l00452"></a>00452 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a>; |
| 334 | <a name="l00453"></a>00453 } |
| 335 | <a name="l00454"></a>00454 |
| 336 | <a name="l00455"></a>00455 <span class="keywordtype">int</span> dimension()<span class="keyword"> const </span>{ |
| 337 | <a name="l00456"></a>00456 <span class="keywordflow">return</span> ep->dimension(); |
| 338 | <a name="l00457"></a>00457 } |
| 339 | <a name="l00458"></a>00458 <span class="keywordtype">int</span> dimensionc() { |
| 340 | <a name="l00459"></a>00459 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1mpdf.html#7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a>; |
| 341 | <a name="l00460"></a>00460 } |
| 342 | <a name="l00461"></a>00461 |
| 343 | <a name="l00471"></a>00471 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mpdf.html#30a0bceb948e287d497c578e371b1667">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>); |
| 344 | <a name="l00473"></a>00473 |
| 345 | <a name="l00476"></a>00476 <span class="keywordtype">void</span> set_rvc (<span class="keyword">const</span> RV &rvc0) { |
| 346 | <a name="l00477"></a>00477 <a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a> = rvc0; |
| 347 | <a name="l00478"></a>00478 } |
| 348 | <a name="l00479"></a>00479 <span class="keywordtype">void</span> set_rv (<span class="keyword">const</span> RV &rv0) { |
| 349 | <a name="l00480"></a>00480 ep->set_rv (rv0); |
| 350 | <a name="l00481"></a>00481 } |
| 351 | <a name="l00482"></a>00482 <span class="keywordtype">bool</span> isnamed() { |
| 352 | <a name="l00483"></a>00483 <span class="keywordflow">return</span> (ep->isnamed()) && (<a class="code" href="classbdm_1_1mpdf.html#7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a> == <a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a>._dsize()); |
| 353 | <a name="l00484"></a>00484 } |
| 354 | <a name="l00486"></a>00486 }; |
| 355 | <a name="l00487"></a>00487 SHAREDPTR(mpdf); |
| 356 | <a name="l00488"></a>00488 |
| 357 | <a name="l00490"></a>00490 <span class="keyword">template</span> <<span class="keyword">class</span> EPDF> |
| 358 | <a name="l00491"></a><a class="code" href="classbdm_1_1mpdf__internal.html">00491</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mpdf__internal.html" title="Mpdf with internal epdf that is modified by function condition.">mpdf_internal</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling , where is random variable, rv, and...">mpdf</a> |
| 359 | <a name="l00492"></a>00492 { |
| 360 | <a name="l00493"></a>00493 <span class="keyword">protected</span> : |
| 361 | <a name="l00495"></a><a class="code" href="classbdm_1_1mpdf__internal.html#47bab632af15120c88aad647ae129468">00495</a> EPDF <a class="code" href="classbdm_1_1mpdf__internal.html#47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>; |
| 362 | <a name="l00496"></a>00496 <span class="keyword">public</span>: |
| 363 | <a name="l00498"></a><a class="code" href="classbdm_1_1mpdf__internal.html#e054b86262261abe0724f5890218689f">00498</a> <a class="code" href="classbdm_1_1mpdf__internal.html#e054b86262261abe0724f5890218689f" title="constructor">mpdf_internal</a>() : <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling , where is random variable, rv, and...">mpdf</a>(), <a class="code" href="classbdm_1_1mpdf__internal.html#47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>() {<a class="code" href="classbdm_1_1mpdf.html#147afacb393324bb3f9a7a89e33f835e" title="set internal pointer ep to point to given iepdf ">set_ep</a> (<a class="code" href="classbdm_1_1mpdf__internal.html#47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>);} |
| 364 | <a name="l00501"></a><a class="code" href="classbdm_1_1mpdf__internal.html#1ac61da081667fc54bcd050cc4f6a93e">00501</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mpdf__internal.html#1ac61da081667fc54bcd050cc4f6a93e">condition</a> (<span class="keyword">const</span> vec &cond) { |
| 365 | <a name="l00502"></a>00502 it_error (<span class="stringliteral">"Not implemented"</span>); |
| 366 | <a name="l00503"></a>00503 }; |
| 367 | <a name="l00505"></a><a class="code" href="classbdm_1_1mpdf__internal.html#6b4d1cb8d7e230e313b4f0c905874d5a">00505</a> EPDF& <a class="code" href="classbdm_1_1mpdf__internal.html#6b4d1cb8d7e230e313b4f0c905874d5a" title="access function to iepdf">e</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1mpdf__internal.html#47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>;} |
| 368 | <a name="l00506"></a>00506 |
| 369 | <a name="l00508"></a>00508 vec <a class="code" href="classbdm_1_1mpdf__internal.html#d8e547695d1cc19219b91164d825c930" title="Reimplements samplecond using condition().">samplecond</a> (<span class="keyword">const</span> vec &cond); |
| 370 | <a name="l00510"></a>00510 <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mpdf__internal.html#89076e62b8d7df7616bad68c94591948" title="Reimplements evallogcond using condition().">evallogcond</a> (<span class="keyword">const</span> vec &val, <span class="keyword">const</span> vec &cond); |
| 371 | <a name="l00512"></a>00512 <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1mpdf__internal.html#e28c214e3063733a6e4d17738941c61c" title="Efficient version of evallogcond for matrices.">evallogcond_m</a> (<span class="keyword">const</span> mat &Dt, <span class="keyword">const</span> vec &cond); |
| 372 | <a name="l00514"></a>00514 <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1mpdf__internal.html#e28c214e3063733a6e4d17738941c61c" title="Efficient version of evallogcond for matrices.">evallogcond_m</a> (<span class="keyword">const</span> Array<vec> &Dt, <span class="keyword">const</span> vec &cond); |
| 373 | <a name="l00516"></a>00516 <span class="keyword">virtual</span> mat <a class="code" href="classbdm_1_1mpdf__internal.html#9554c554054da2d22cb8e908ae9c8823" title="Efficient version of samplecond.">samplecond_m</a> (<span class="keyword">const</span> vec &cond, <span class="keywordtype">int</span> N); |
| 374 | <a name="l00517"></a>00517 }; |
| 375 | <a name="l00518"></a>00518 |
| 376 | <a name="l00544"></a><a class="code" href="classbdm_1_1datalink.html">00544</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1datalink.html" title="DataLink is a connection between two data vectors Up and Down.">datalink</a> |
| 377 | <a name="l00545"></a>00545 { |
| 378 | <a name="l00546"></a>00546 <span class="keyword">protected</span>: |
| 379 | <a name="l00548"></a><a class="code" href="classbdm_1_1datalink.html#bc8ff50395fc1066a1e486dea18d987c">00548</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1datalink.html#bc8ff50395fc1066a1e486dea18d987c" title="Remember how long val should be.">downsize</a>; |
| 380 | <a name="l00549"></a>00549 |
| 381 | <a name="l00551"></a><a class="code" href="classbdm_1_1datalink.html#0f0d0af6848114d96108d3a6af25a045">00551</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1datalink.html#0f0d0af6848114d96108d3a6af25a045" title="Remember how long val of &quot;Up&quot; should be.">upsize</a>; |
| 382 | <a name="l00552"></a>00552 |
| 383 | <a name="l00554"></a><a class="code" href="classbdm_1_1datalink.html#240b37d793c6bdc32824ed0a0541b1eb">00554</a> ivec <a class="code" href="classbdm_1_1datalink.html#240b37d793c6bdc32824ed0a0541b1eb" title="val-to-val link, indices of the upper val">v2v_up</a>; |
| 384 | <a name="l00555"></a>00555 |
| 385 | <a name="l00556"></a>00556 <span class="keyword">public</span>: |
| 386 | <a name="l00558"></a><a class="code" href="classbdm_1_1datalink.html#b8b5d5074fc1310a37c3713d58b900e2">00558</a> <a class="code" href="classbdm_1_1datalink.html#b8b5d5074fc1310a37c3713d58b900e2" title="Constructor.">datalink</a>() : <a class="code" href="classbdm_1_1datalink.html#bc8ff50395fc1066a1e486dea18d987c" title="Remember how long val should be.">downsize</a> (0), <a class="code" href="classbdm_1_1datalink.html#0f0d0af6848114d96108d3a6af25a045" title="Remember how long val of &quot;Up&quot; should be.">upsize</a> (0) { } |
| 387 | <a name="l00560"></a><a class="code" href="classbdm_1_1datalink.html#4016403730eb742462614d60393565cd">00560</a> <a class="code" href="classbdm_1_1datalink.html#4016403730eb742462614d60393565cd" title="Conevnience constructor.">datalink</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv_up) { |
| 388 | <a name="l00561"></a>00561 <a class="code" href="classbdm_1_1datalink.html#fb8337aac8329eb0ca96bfb3ff73ec67" title="set connection, rv must be fully present in rv_up">set_connection</a> (rv, rv_up); |
| 389 | <a name="l00562"></a>00562 } |
| 390 | <a name="l00563"></a>00563 |
| 391 | <a name="l00565"></a><a class="code" href="classbdm_1_1datalink.html#fb8337aac8329eb0ca96bfb3ff73ec67">00565</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1datalink.html#fb8337aac8329eb0ca96bfb3ff73ec67" title="set connection, rv must be fully present in rv_up">set_connection</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv_up) { |
| 392 | <a name="l00566"></a>00566 <a class="code" href="classbdm_1_1datalink.html#bc8ff50395fc1066a1e486dea18d987c" title="Remember how long val should be.">downsize</a> = rv.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(); |
| 393 | <a name="l00567"></a>00567 <a class="code" href="classbdm_1_1datalink.html#0f0d0af6848114d96108d3a6af25a045" title="Remember how long val of &quot;Up&quot; should be.">upsize</a> = rv_up.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(); |
| 394 | <a name="l00568"></a>00568 <a class="code" href="classbdm_1_1datalink.html#240b37d793c6bdc32824ed0a0541b1eb" title="val-to-val link, indices of the upper val">v2v_up</a> = rv.<a class="code" href="classbdm_1_1RV.html#cbebdb5e0d30101a6eb63550ef701c55">dataind</a> (rv_up); |
| 395 | <a name="l00569"></a>00569 |
| 396 | <a name="l00570"></a>00570 it_assert_debug (<a class="code" href="classbdm_1_1datalink.html#240b37d793c6bdc32824ed0a0541b1eb" title="val-to-val link, indices of the upper val">v2v_up</a>.length() == <a class="code" href="classbdm_1_1datalink.html#bc8ff50395fc1066a1e486dea18d987c" title="Remember how long val should be.">downsize</a>, <span class="stringliteral">"rv is not fully in rv_up"</span>); |
| 397 | <a name="l00571"></a>00571 } |
| 398 | <a name="l00572"></a>00572 |
| 399 | <a name="l00574"></a><a class="code" href="classbdm_1_1datalink.html#724486a37002e7a3a73366c3af9b82ad">00574</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1datalink.html#724486a37002e7a3a73366c3af9b82ad" title="set connection using indices">set_connection</a> (<span class="keywordtype">int</span> ds, <span class="keywordtype">int</span> us, <span class="keyword">const</span> ivec &upind) { |
| 400 | <a name="l00575"></a>00575 <a class="code" href="classbdm_1_1datalink.html#bc8ff50395fc1066a1e486dea18d987c" title="Remember how long val should be.">downsize</a> = ds; |
| 401 | <a name="l00576"></a>00576 <a class="code" href="classbdm_1_1datalink.html#0f0d0af6848114d96108d3a6af25a045" title="Remember how long val of &quot;Up&quot; should be.">upsize</a> = us; |
| 402 | <a name="l00577"></a>00577 <a class="code" href="classbdm_1_1datalink.html#240b37d793c6bdc32824ed0a0541b1eb" title="val-to-val link, indices of the upper val">v2v_up</a> = upind; |
| 403 | <a name="l00578"></a>00578 |
| 404 | <a name="l00579"></a>00579 it_assert_debug (<a class="code" href="classbdm_1_1datalink.html#240b37d793c6bdc32824ed0a0541b1eb" title="val-to-val link, indices of the upper val">v2v_up</a>.length() == <a class="code" href="classbdm_1_1datalink.html#bc8ff50395fc1066a1e486dea18d987c" title="Remember how long val should be.">downsize</a>, <span class="stringliteral">"rv is not fully in rv_up"</span>); |
| 405 | <a name="l00580"></a>00580 } |
| 406 | <a name="l00581"></a>00581 |
| 407 | <a name="l00583"></a><a class="code" href="classbdm_1_1datalink.html#5b5368c3899eed2f670d09142c2548e5">00583</a> vec <a class="code" href="classbdm_1_1datalink.html#5b5368c3899eed2f670d09142c2548e5" title="Get val for myself from val of &quot;Up&quot;.">pushdown</a> (<span class="keyword">const</span> vec &val_up) { |
| 408 | <a name="l00584"></a>00584 it_assert_debug (<a class="code" href="classbdm_1_1datalink.html#0f0d0af6848114d96108d3a6af25a045" title="Remember how long val of &quot;Up&quot; should be.">upsize</a> == val_up.length(), <span class="stringliteral">"Wrong val_up"</span>); |
| 409 | <a name="l00585"></a>00585 <span class="keywordflow">return</span> get_vec (val_up, <a class="code" href="classbdm_1_1datalink.html#240b37d793c6bdc32824ed0a0541b1eb" title="val-to-val link, indices of the upper val">v2v_up</a>); |
| 410 | <a name="l00586"></a>00586 } |
| 411 | <a name="l00587"></a>00587 |
| 412 | <a name="l00589"></a><a class="code" href="classbdm_1_1datalink.html#610e966f2edb1fcd6a5b28267c571793">00589</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1datalink.html#610e966f2edb1fcd6a5b28267c571793" title="Fill val of &quot;Up&quot; by my pieces.">pushup</a> (vec &val_up, <span class="keyword">const</span> vec &val) { |
| 413 | <a name="l00590"></a>00590 it_assert_debug (<a class="code" href="classbdm_1_1datalink.html#bc8ff50395fc1066a1e486dea18d987c" title="Remember how long val should be.">downsize</a> == val.length(), <span class="stringliteral">"Wrong val"</span>); |
| 414 | <a name="l00591"></a>00591 it_assert_debug (<a class="code" href="classbdm_1_1datalink.html#0f0d0af6848114d96108d3a6af25a045" title="Remember how long val of &quot;Up&quot; should be.">upsize</a> == val_up.length(), <span class="stringliteral">"Wrong val_up"</span>); |
| 415 | <a name="l00592"></a>00592 set_subvector (val_up, <a class="code" href="classbdm_1_1datalink.html#240b37d793c6bdc32824ed0a0541b1eb" title="val-to-val link, indices of the upper val">v2v_up</a>, val); |
| 416 | <a name="l00593"></a>00593 } |
| 417 | <a name="l00594"></a>00594 }; |
| 418 | <a name="l00595"></a>00595 |
| 419 | <a name="l00597"></a><a class="code" href="classbdm_1_1datalink__m2e.html">00597</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1datalink__m2e.html" title="Data link with a condition.">datalink_m2e</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1datalink.html" title="DataLink is a connection between two data vectors Up and Down.">datalink</a> |
| 420 | <a name="l00598"></a>00598 { |
| 421 | <a name="l00599"></a>00599 <span class="keyword">protected</span>: |
| 422 | <a name="l00601"></a><a class="code" href="classbdm_1_1datalink__m2e.html#3fb26525e0bfa7932a37c5cd404801f9">00601</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1datalink__m2e.html#3fb26525e0bfa7932a37c5cd404801f9" title="Remember how long cond should be.">condsize</a>; |
| 423 | <a name="l00602"></a>00602 |
| 424 | <a name="l00604"></a><a class="code" href="classbdm_1_1datalink__m2e.html#43fe3e2d7aa04134053ec15793722783">00604</a> ivec <a class="code" href="classbdm_1_1datalink__m2e.html#43fe3e2d7aa04134053ec15793722783" title="upper_val-to-local_cond link, indices of the upper val">v2c_up</a>; |
419 | | <a name="l00609"></a><a class="code" href="classbdm_1_1mepdf.html">00609</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mepdf.html" title="Unconditional mpdf, allows using epdf in the role of mpdf.">mepdf</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> { |
420 | | <a name="l00610"></a>00610 <span class="keywordtype">bool</span> owning_ep; <span class="comment">// flag trigers deleting ep by destructor</span> |
421 | | <a name="l00611"></a>00611 <span class="keyword">public</span>: |
422 | | <a name="l00613"></a><a class="code" href="classbdm_1_1mepdf.html#4a2b01e7bb510c6b8946757cae6c9155">00613</a> <a class="code" href="classbdm_1_1mepdf.html#4a2b01e7bb510c6b8946757cae6c9155" title="Default constructor.">mepdf</a>(){}; |
423 | | <a name="l00614"></a>00614 <a class="code" href="classbdm_1_1mepdf.html#4a2b01e7bb510c6b8946757cae6c9155" title="Default constructor.">mepdf</a> ( <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* em, <span class="keywordtype">bool</span> owning_ep0=<span class="keyword">false</span> ) :<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_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>= em ;owning_ep=owning_ep0;<a class="code" href="classbdm_1_1mpdf.html#7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a>=0;}; |
424 | | <a name="l00615"></a>00615 <a class="code" href="classbdm_1_1mepdf.html#4a2b01e7bb510c6b8946757cae6c9155" title="Default constructor.">mepdf</a> (<span class="keyword">const</span> epdf* em ) :mpdf ( ) {<a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>=<span class="keyword">const_cast<</span>epdf*<span class="keyword">></span>( em );}; |
425 | | <a name="l00616"></a><a class="code" href="classbdm_1_1mepdf.html#b2b898058169e7ed9a6dc7cd4e1c147c">00616</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mepdf.html#b2b898058169e7ed9a6dc7cd4e1c147c" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a> ( <span class="keyword">const</span> vec &cond ) {} |
426 | | <a name="l00617"></a>00617 ~<a class="code" href="classbdm_1_1mepdf.html" title="Unconditional mpdf, allows using epdf in the role of mpdf.">mepdf</a>(){<span class="keywordflow">if</span> (owning_ep) <span class="keyword">delete</span> <a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>;} |
427 | | <a name="l00625"></a><a class="code" href="classbdm_1_1mepdf.html#27ef18a3e3b1b5de02739d1324bf25fb">00625</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mepdf.html#27ef18a3e3b1b5de02739d1324bf25fb">from_setting</a>(<span class="keyword">const</span> Setting &<span class="keyword">set</span>){ |
428 | | <a name="l00626"></a>00626 <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* e = UI::build<epdf>(<span class="keyword">set</span>,<span class="stringliteral">"epdf"</span>); |
429 | | <a name="l00627"></a>00627 <a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>= e; |
430 | | <a name="l00628"></a>00628 owning_ep=<span class="keyword">true</span>; |
431 | | <a name="l00629"></a>00629 } |
432 | | <a name="l00630"></a>00630 }; |
433 | | <a name="l00631"></a>00631 <a class="code" href="user__info_8h.html#4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a>(mepdf); |
434 | | <a name="l00632"></a>00632 |
435 | | <a name="l00636"></a><a class="code" href="classbdm_1_1compositepdf.html">00636</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1compositepdf.html" title="Chain rule of pdfs - abstract part common for mprod and merger. this abstract class...">compositepdf</a> { |
436 | | <a name="l00637"></a>00637 <span class="keyword">protected</span>: |
437 | | <a name="l00639"></a><a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a">00639</a> Array<mpdf*> <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a>; |
438 | | <a name="l00640"></a>00640 <span class="keywordtype">bool</span> owning_mpdfs; |
439 | | <a name="l00641"></a>00641 <span class="keyword">public</span>: |
440 | | <a name="l00642"></a>00642 <a class="code" href="classbdm_1_1compositepdf.html" title="Chain rule of pdfs - abstract part common for mprod and merger. this abstract class...">compositepdf</a>():<a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a>(0){}; |
441 | | <a name="l00643"></a>00643 <a class="code" href="classbdm_1_1compositepdf.html" title="Chain rule of pdfs - abstract part common for mprod and merger. this abstract class...">compositepdf</a>(Array<mpdf*> A0, <span class="keywordtype">bool</span> own=<span class="keyword">false</span>){set_elements(A0,own);}; |
442 | | <a name="l00644"></a>00644 <span class="keywordtype">void</span> set_elements(Array<mpdf*> A0, <span class="keywordtype">bool</span> own=<span class="keyword">false</span>) {<a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a>=A0;owning_mpdfs=own;}; |
443 | | <a name="l00646"></a>00646 RV <a class="code" href="classbdm_1_1compositepdf.html#c73d39acc4378eee6a63155c3517d3c9" title="find common rv, flag">getrv</a>(<span class="keywordtype">bool</span> checkoverlap = <span class="keyword">false</span>); |
444 | | <a name="l00648"></a>00648 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1compositepdf.html#c71fc2c51f49d797e61f479f543c75ce" title="common rvc of all mpdfs is written to rvc">setrvc</a>(<span class="keyword">const</span> RV &rv, RV &rvc); |
445 | | <a name="l00649"></a>00649 ~compositepdf(){<span class="keywordflow">if</span> (owning_mpdfs) <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a>.length();i++){<span class="keyword">delete</span> <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a>(i);}}; |
446 | | <a name="l00650"></a>00650 }; |
447 | | <a name="l00651"></a>00651 |
448 | | <a name="l00659"></a><a class="code" href="classbdm_1_1DS.html">00659</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1DS.html" title="Abstract class for discrete-time sources of data.">DS</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> |
449 | | <a name="l00660"></a>00660 { |
450 | | <a name="l00661"></a>00661 <span class="keyword">protected</span>: |
451 | | <a name="l00662"></a>00662 <span class="keywordtype">int</span> dtsize; |
452 | | <a name="l00663"></a>00663 <span class="keywordtype">int</span> utsize; |
453 | | <a name="l00665"></a><a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec">00665</a> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>; |
454 | | <a name="l00667"></a><a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702">00667</a> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>; <span class="comment">//</span> |
455 | | <a name="l00669"></a><a class="code" href="classbdm_1_1DS.html#b4b7bdb9d98a11ab587aa0ad803bb867">00669</a> <span class="comment"></span> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1DS.html#b4b7bdb9d98a11ab587aa0ad803bb867" title="Remember its own index in Logger L.">L_dt</a>, L_ut; |
456 | | <a name="l00670"></a>00670 <span class="keyword">public</span>: |
457 | | <a name="l00672"></a><a class="code" href="classbdm_1_1DS.html#bedd82e08ae6686b4b1732a122c2201a">00672</a> <a class="code" href="classbdm_1_1DS.html#bedd82e08ae6686b4b1732a122c2201a" title="default constructors">DS</a>() : <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>(), <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>() {}; |
458 | | <a name="l00674"></a><a class="code" href="classbdm_1_1DS.html#c1ec862dec7164fee3284c6f9a51b0ba">00674</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1DS.html#c1ec862dec7164fee3284c6f9a51b0ba" title="Returns full vector of observed data=[output, input].">getdata</a>(vec &dt) {it_error(<span class="stringliteral">"abstract class"</span>);}; |
459 | | <a name="l00676"></a><a class="code" href="classbdm_1_1DS.html#a0bf451c7fea73ff4150ff9e83da4832">00676</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1DS.html#a0bf451c7fea73ff4150ff9e83da4832" title="Returns data records at indeces.">getdata</a>(vec &dt, <span class="keyword">const</span> ivec &indeces) {it_error(<span class="stringliteral">"abstract class"</span>);}; |
460 | | <a name="l00678"></a><a class="code" href="classbdm_1_1DS.html#f5baeee8528e5e4c5c7a344b2e3f192a">00678</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1DS.html#f5baeee8528e5e4c5c7a344b2e3f192a" title="Accepts action variable and schedule it for application.">write</a>(vec &ut) {it_error(<span class="stringliteral">"abstract class"</span>);}; |
461 | | <a name="l00680"></a><a class="code" href="classbdm_1_1DS.html#6bced13f84f6bf04449728817e049e1d">00680</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1DS.html#6bced13f84f6bf04449728817e049e1d" title="Accepts action variables at specific indeces.">write</a>(vec &ut, <span class="keyword">const</span> ivec &indeces) {it_error(<span class="stringliteral">"abstract class"</span>);}; |
462 | | <a name="l00681"></a>00681 |
463 | | <a name="l00683"></a>00683 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1DS.html#9a14c64d881e838ddc3a5617ee8a973b" title="Moves from to , i.e. perfroms the actions and reads response of the system.">step</a>() = 0; |
464 | | <a name="l00684"></a>00684 |
465 | | <a name="l00686"></a><a class="code" href="classbdm_1_1DS.html#3c9e417d85052396fe74c164857ee67e">00686</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1DS.html#3c9e417d85052396fe74c164857ee67e" title="Register DS for logging into logger L.">log_add</a>(<a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> &L) { |
466 | | <a name="l00687"></a>00687 it_assert_debug(dtsize == <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(), <span class="stringliteral">""</span>); |
467 | | <a name="l00688"></a>00688 it_assert_debug(utsize == <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(), <span class="stringliteral">""</span>); |
468 | | <a name="l00689"></a>00689 |
469 | | <a name="l00690"></a>00690 <a class="code" href="classbdm_1_1DS.html#b4b7bdb9d98a11ab587aa0ad803bb867" title="Remember its own index in Logger L.">L_dt</a> = L.<a class="code" href="classbdm_1_1logger.html#47aa3b098a81d02a8ffaea2c9fa09ac7">add</a>(<a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>, <span class="stringliteral">""</span>); |
470 | | <a name="l00691"></a>00691 L_ut = L.<a class="code" href="classbdm_1_1logger.html#47aa3b098a81d02a8ffaea2c9fa09ac7">add</a>(<a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>, <span class="stringliteral">""</span>); |
471 | | <a name="l00692"></a>00692 } |
472 | | <a name="l00694"></a><a class="code" href="classbdm_1_1DS.html#e03d2c93cddd5c3a03107ddd3ae999cf">00694</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1DS.html#e03d2c93cddd5c3a03107ddd3ae999cf" title="Register DS for logging into logger L.">logit</a>(<a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> &L) { |
473 | | <a name="l00695"></a>00695 vec tmp(<a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>() + <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>()); |
474 | | <a name="l00696"></a>00696 <a class="code" href="classbdm_1_1DS.html#c1ec862dec7164fee3284c6f9a51b0ba" title="Returns full vector of observed data=[output, input].">getdata</a>(tmp); |
475 | | <a name="l00697"></a>00697 <span class="comment">// d is first in getdata</span> |
476 | | <a name="l00698"></a>00698 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a>(<a class="code" href="classbdm_1_1DS.html#b4b7bdb9d98a11ab587aa0ad803bb867" title="Remember its own index in Logger L.">L_dt</a>, tmp.left(<a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>())); |
477 | | <a name="l00699"></a>00699 <span class="comment">// u follows after d in getdata</span> |
478 | | <a name="l00700"></a>00700 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a>(L_ut, tmp.mid(<a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(), <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>())); |
479 | | <a name="l00701"></a>00701 } |
480 | | <a name="l00703"></a><a class="code" href="classbdm_1_1DS.html#ed2113851294ed96abe60fc3f05aa660">00703</a> <span class="keyword">virtual</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1DS.html#ed2113851294ed96abe60fc3f05aa660" title="access function">_drv</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> concat(<a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>, <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>);} |
481 | | <a name="l00705"></a><a class="code" href="classbdm_1_1DS.html#a6a9a375da64c82fc227bda3418a1f33">00705</a> <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a>& <a class="code" href="classbdm_1_1DS.html#a6a9a375da64c82fc227bda3418a1f33" title="access function">_urv</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>;} |
482 | | <a name="l00707"></a><a class="code" href="classbdm_1_1DS.html#821297dfd839d68691324f024e57252f">00707</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1DS.html#821297dfd839d68691324f024e57252f" title="set random rvariables">set_drv</a>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &drv, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &urv) { <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a> = drv; <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a> = urv;} |
483 | | <a name="l00708"></a>00708 }; |
484 | | <a name="l00709"></a>00709 |
485 | | <a name="l00731"></a><a class="code" href="classbdm_1_1BM.html">00731</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of a system, i.e. all uncertainty is modeled by probabilities.">BM</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> |
486 | | <a name="l00732"></a>00732 { |
487 | | <a name="l00733"></a>00733 <span class="keyword">protected</span>: |
488 | | <a name="l00735"></a><a class="code" href="classbdm_1_1BM.html#c400357e37d27a4834b2b1d9211009ed">00735</a> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1BM.html#c400357e37d27a4834b2b1d9211009ed" title="Random variable of the data (optional).">drv</a>; |
489 | | <a name="l00737"></a><a class="code" href="classbdm_1_1BM.html#4064b6559d962633e4372b12f4cd204a">00737</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1BM.html#4064b6559d962633e4372b12f4cd204a" title="Logarithm of marginalized data likelihood.">ll</a>; |
490 | | <a name="l00739"></a><a class="code" href="classbdm_1_1BM.html#faff0ad12556fe7dc0e2807d4fd938ee">00739</a> <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1BM.html#faff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>; |
491 | | <a name="l00740"></a>00740 <span class="keyword">public</span>: |
492 | | <a name="l00743"></a>00743 |
493 | | <a name="l00744"></a>00744 <a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of a system, i.e. all uncertainty is modeled by probabilities.">BM</a>() : <a class="code" href="classbdm_1_1BM.html#4064b6559d962633e4372b12f4cd204a" title="Logarithm of marginalized data likelihood.">ll</a>(0), <a class="code" href="classbdm_1_1BM.html#faff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>(true), <a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a>(4), <a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a>(4) { |
494 | | <a name="l00745"></a>00745 <a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a> = -1;<span class="comment">/*empty IDs*/</span> |
495 | | <a name="l00746"></a>00746 <a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a> = 0; |
496 | | <a name="l00747"></a>00747 <a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a>(0) = 1;<span class="comment">/*log only mean*/</span> |
497 | | <a name="l00748"></a>00748 }; |
498 | | <a name="l00749"></a>00749 <a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of a system, i.e. all uncertainty is modeled by probabilities.">BM</a>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of a system, i.e. all uncertainty is modeled by probabilities.">BM</a> &B) : <a class="code" href="classbdm_1_1BM.html#c400357e37d27a4834b2b1d9211009ed" title="Random variable of the data (optional).">drv</a>(B.<a class="code" href="classbdm_1_1BM.html#c400357e37d27a4834b2b1d9211009ed" title="Random variable of the data (optional).">drv</a>), <a class="code" href="classbdm_1_1BM.html#4064b6559d962633e4372b12f4cd204a" title="Logarithm of marginalized data likelihood.">ll</a>(B.<a class="code" href="classbdm_1_1BM.html#4064b6559d962633e4372b12f4cd204a" title="Logarithm of marginalized data likelihood.">ll</a>), <a class="code" href="classbdm_1_1BM.html#faff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>(B.<a class="code" href="classbdm_1_1BM.html#faff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>) {} |
499 | | <a name="l00752"></a><a class="code" href="classbdm_1_1BM.html#40f01563651c1e4fe926189e41a6b8ab">00752</a> <span class="keyword">virtual</span> <a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of a system, i.e. all uncertainty is modeled by probabilities.">BM</a>* <a class="code" href="classbdm_1_1BM.html#40f01563651c1e4fe926189e41a6b8ab">_copy_</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> NULL;}; |
500 | | <a name="l00754"></a>00754 |
501 | | <a name="l00757"></a>00757 |
502 | | <a name="l00761"></a>00761 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1BM.html#60b1779a577367c369a932cabd3a6188" title="Incremental Bayes rule.">bayes</a>(<span class="keyword">const</span> vec &dt) = 0; |
503 | | <a name="l00763"></a>00763 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1BM.html#1dee3fddaf021e62d925289660a707dc" title="Batch Bayes rule (columns of Dt are observations).">bayesB</a>(<span class="keyword">const</span> mat &Dt); |
504 | | <a name="l00766"></a><a class="code" href="classbdm_1_1BM.html#50257e0c1e5b5c73153ea6e716ad8ae0">00766</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1BM.html#50257e0c1e5b5c73153ea6e716ad8ae0">logpred</a>(<span class="keyword">const</span> vec &dt)<span class="keyword"> const </span>{it_error(<span class="stringliteral">"Not implemented"</span>); <span class="keywordflow">return</span> 0.0;} |
505 | | <a name="l00768"></a><a class="code" href="classbdm_1_1BM.html#0e8ebe61fb14990abe1254bd3dda5fae">00768</a> vec <a class="code" href="classbdm_1_1BM.html#0e8ebe61fb14990abe1254bd3dda5fae" title="Matrix version of logpred.">logpred_m</a>(<span class="keyword">const</span> mat &dt)<span class="keyword"> const </span>{vec tmp(dt.cols()); <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < dt.cols(); i++) {tmp(i) = <a class="code" href="classbdm_1_1BM.html#50257e0c1e5b5c73153ea6e716ad8ae0">logpred</a>(dt.get_col(i));} <span class="keywordflow">return</span> tmp;} |
506 | | <a name="l00769"></a>00769 |
507 | | <a name="l00771"></a><a class="code" href="classbdm_1_1BM.html#688d7a2aced1e06aa1c468d73a9e5eba">00771</a> <span class="keyword">virtual</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* <a class="code" href="classbdm_1_1BM.html#688d7a2aced1e06aa1c468d73a9e5eba" title="Constructs a predictive density .">epredictor</a>()<span class="keyword"> const </span>{it_error(<span class="stringliteral">"Not implemented"</span>); <span class="keywordflow">return</span> NULL;}; |
508 | | <a name="l00773"></a><a class="code" href="classbdm_1_1BM.html#598b25e3f3d96a5bc00a5faeb5b3c912">00773</a> <span class="keyword">virtual</span> <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_1BM.html#598b25e3f3d96a5bc00a5faeb5b3c912" title="Constructs a conditional density 1-step ahead predictor.">predictor</a>()<span class="keyword"> const </span>{it_error(<span class="stringliteral">"Not implemented"</span>); <span class="keywordflow">return</span> NULL;}; |
509 | | <a name="l00775"></a>00775 |
510 | | <a name="l00780"></a>00780 |
511 | | <a name="l00782"></a><a class="code" href="classbdm_1_1BM.html#de95c590d650b2db423d53992f0906cb">00782</a> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> rvc; |
512 | | <a name="l00784"></a><a class="code" href="classbdm_1_1BM.html#b5e8e016be16e4029c789063cb3f3b33">00784</a> <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a>& <a class="code" href="classbdm_1_1BM.html#b5e8e016be16e4029c789063cb3f3b33" title="access function">_rvc</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> rvc;} |
513 | | <a name="l00785"></a>00785 |
514 | | <a name="l00787"></a><a class="code" href="classbdm_1_1BM.html#6799f4b16a6a59ed58b1d0d6e17116f4">00787</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1BM.html#6799f4b16a6a59ed58b1d0d6e17116f4" title="Substitute val for rvc.">condition</a>(<span class="keyword">const</span> vec &val) {it_error(<span class="stringliteral">"Not implemented!"</span>);}; |
515 | | <a name="l00788"></a>00788 |
| 426 | <a name="l00607"></a><a class="code" href="classbdm_1_1datalink__m2e.html#9e0048d87bda78e9b8d38761440c7abc">00607</a> ivec <a class="code" href="classbdm_1_1datalink__m2e.html#9e0048d87bda78e9b8d38761440c7abc" title="upper_val-to-local_cond link, indices of the local cond">v2c_lo</a>; |
| 427 | <a name="l00608"></a>00608 |
| 428 | <a name="l00609"></a>00609 <span class="keyword">public</span>: |
| 429 | <a name="l00611"></a><a class="code" href="classbdm_1_1datalink__m2e.html#5ad951e9cf850c9bfe4e492e91a50af6">00611</a> <a class="code" href="classbdm_1_1datalink__m2e.html#5ad951e9cf850c9bfe4e492e91a50af6" title="Constructor.">datalink_m2e</a>() : <a class="code" href="classbdm_1_1datalink__m2e.html#3fb26525e0bfa7932a37c5cd404801f9" title="Remember how long cond should be.">condsize</a> (0) { } |
| 430 | <a name="l00613"></a><a class="code" href="classbdm_1_1datalink__m2e.html#add918bf877c48714cff51ee4ad989b0">00613</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1datalink__m2e.html#add918bf877c48714cff51ee4ad989b0" title="Set connection between vectors.">set_connection</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rvc, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv_up) { |
| 431 | <a name="l00614"></a>00614 <a class="code" href="classbdm_1_1datalink__m2e.html#add918bf877c48714cff51ee4ad989b0" title="Set connection between vectors.">datalink::set_connection</a> (rv, rv_up); |
| 432 | <a name="l00615"></a>00615 <a class="code" href="classbdm_1_1datalink__m2e.html#3fb26525e0bfa7932a37c5cd404801f9" title="Remember how long cond should be.">condsize</a> = rvc.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(); |
| 433 | <a name="l00616"></a>00616 <span class="comment">//establish v2c connection</span> |
| 434 | <a name="l00617"></a>00617 rvc.<a class="code" href="classbdm_1_1RV.html#cbebdb5e0d30101a6eb63550ef701c55">dataind</a> (rv_up, <a class="code" href="classbdm_1_1datalink__m2e.html#9e0048d87bda78e9b8d38761440c7abc" title="upper_val-to-local_cond link, indices of the local cond">v2c_lo</a>, <a class="code" href="classbdm_1_1datalink__m2e.html#43fe3e2d7aa04134053ec15793722783" title="upper_val-to-local_cond link, indices of the upper val">v2c_up</a>); |
| 435 | <a name="l00618"></a>00618 } |
| 436 | <a name="l00619"></a>00619 |
| 437 | <a name="l00621"></a><a class="code" href="classbdm_1_1datalink__m2e.html#7ba850822e3cf9a4b079afc7e7c01703">00621</a> vec <a class="code" href="classbdm_1_1datalink__m2e.html#7ba850822e3cf9a4b079afc7e7c01703" title="Construct condition.">get_cond</a> (<span class="keyword">const</span> vec &val_up) { |
| 438 | <a name="l00622"></a>00622 vec tmp (<a class="code" href="classbdm_1_1datalink__m2e.html#3fb26525e0bfa7932a37c5cd404801f9" title="Remember how long cond should be.">condsize</a>); |
| 439 | <a name="l00623"></a>00623 set_subvector (tmp, <a class="code" href="classbdm_1_1datalink__m2e.html#9e0048d87bda78e9b8d38761440c7abc" title="upper_val-to-local_cond link, indices of the local cond">v2c_lo</a>, val_up (<a class="code" href="classbdm_1_1datalink__m2e.html#43fe3e2d7aa04134053ec15793722783" title="upper_val-to-local_cond link, indices of the upper val">v2c_up</a>)); |
| 440 | <a name="l00624"></a>00624 <span class="keywordflow">return</span> tmp; |
| 441 | <a name="l00625"></a>00625 } |
| 442 | <a name="l00627"></a><a class="code" href="classbdm_1_1datalink__m2e.html#b29bc3c7bf2a1d87e77ccaa793d097d5">00627</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1datalink__m2e.html#b29bc3c7bf2a1d87e77ccaa793d097d5" title="Copy corresponding values to Up.condition.">pushup_cond</a> (vec &val_up, <span class="keyword">const</span> vec &val, <span class="keyword">const</span> vec &cond) { |
| 443 | <a name="l00628"></a>00628 it_assert_debug (<a class="code" href="classbdm_1_1datalink.html#bc8ff50395fc1066a1e486dea18d987c" title="Remember how long val should be.">downsize</a> == val.length(), <span class="stringliteral">"Wrong val"</span>); |
| 444 | <a name="l00629"></a>00629 it_assert_debug (<a class="code" href="classbdm_1_1datalink.html#0f0d0af6848114d96108d3a6af25a045" title="Remember how long val of &quot;Up&quot; should be.">upsize</a> == val_up.length(), <span class="stringliteral">"Wrong val_up"</span>); |
| 445 | <a name="l00630"></a>00630 set_subvector (val_up, <a class="code" href="classbdm_1_1datalink.html#240b37d793c6bdc32824ed0a0541b1eb" title="val-to-val link, indices of the upper val">v2v_up</a>, val); |
| 446 | <a name="l00631"></a>00631 set_subvector (val_up, <a class="code" href="classbdm_1_1datalink__m2e.html#43fe3e2d7aa04134053ec15793722783" title="upper_val-to-local_cond link, indices of the upper val">v2c_up</a>, cond); |
| 447 | <a name="l00632"></a>00632 } |
| 448 | <a name="l00633"></a>00633 }; |
| 449 | <a name="l00634"></a>00634 |
| 450 | <a name="l00637"></a><a class="code" href="classbdm_1_1datalink__m2m.html">00637</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1datalink__m2m.html">datalink_m2m</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1datalink__m2e.html" title="Data link with a condition.">datalink_m2e</a> |
| 451 | <a name="l00638"></a>00638 { |
| 452 | <a name="l00639"></a>00639 <span class="keyword">protected</span>: |
| 453 | <a name="l00641"></a><a class="code" href="classbdm_1_1datalink__m2m.html#d64dda6f92654628276bbcebb7600d0d">00641</a> ivec <a class="code" href="classbdm_1_1datalink__m2m.html#d64dda6f92654628276bbcebb7600d0d" title="cond-to-cond link, indices of the upper cond">c2c_up</a>; |
| 454 | <a name="l00643"></a><a class="code" href="classbdm_1_1datalink__m2m.html#0ea05c47de4538b7042ff878e6e309a5">00643</a> ivec <a class="code" href="classbdm_1_1datalink__m2m.html#0ea05c47de4538b7042ff878e6e309a5" title="cond-to-cond link, indices of the local cond">c2c_lo</a>; |
| 455 | <a name="l00644"></a>00644 |
| 456 | <a name="l00645"></a>00645 <span class="keyword">public</span>: |
| 457 | <a name="l00647"></a><a class="code" href="classbdm_1_1datalink__m2m.html#3baed32cb66f0e2f731032cec0a4d287">00647</a> <a class="code" href="classbdm_1_1datalink__m2m.html#3baed32cb66f0e2f731032cec0a4d287" title="Constructor.">datalink_m2m</a>() {}; |
| 458 | <a name="l00649"></a><a class="code" href="classbdm_1_1datalink__m2m.html#0ed49a99e8a3be264b952558b6f515d4">00649</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1datalink__m2m.html#0ed49a99e8a3be264b952558b6f515d4" title="Set connection between the vectors.">set_connection</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rvc, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv_up, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rvc_up) { |
| 459 | <a name="l00650"></a>00650 <a class="code" href="classbdm_1_1datalink__m2m.html#0ed49a99e8a3be264b952558b6f515d4" title="Set connection between the vectors.">datalink_m2e::set_connection</a> (rv, rvc, rv_up); |
| 460 | <a name="l00651"></a>00651 <span class="comment">//establish c2c connection</span> |
| 461 | <a name="l00652"></a>00652 rvc.<a class="code" href="classbdm_1_1RV.html#cbebdb5e0d30101a6eb63550ef701c55">dataind</a> (rvc_up, <a class="code" href="classbdm_1_1datalink__m2m.html#0ea05c47de4538b7042ff878e6e309a5" title="cond-to-cond link, indices of the local cond">c2c_lo</a>, <a class="code" href="classbdm_1_1datalink__m2m.html#d64dda6f92654628276bbcebb7600d0d" title="cond-to-cond link, indices of the upper cond">c2c_up</a>); |
| 462 | <a name="l00653"></a>00653 it_assert_debug (<a class="code" href="classbdm_1_1datalink__m2m.html#0ea05c47de4538b7042ff878e6e309a5" title="cond-to-cond link, indices of the local cond">c2c_lo</a>.length() + <a class="code" href="classbdm_1_1datalink__m2e.html#9e0048d87bda78e9b8d38761440c7abc" title="upper_val-to-local_cond link, indices of the local cond">v2c_lo</a>.length() == <a class="code" href="classbdm_1_1datalink__m2e.html#3fb26525e0bfa7932a37c5cd404801f9" title="Remember how long cond should be.">condsize</a>, <span class="stringliteral">"cond is not fully given"</span>); |
| 463 | <a name="l00654"></a>00654 } |
| 464 | <a name="l00655"></a>00655 |
| 465 | <a name="l00657"></a><a class="code" href="classbdm_1_1datalink__m2m.html#911fb7fcfa80d4e31db8e0cc03141a90">00657</a> vec <a class="code" href="classbdm_1_1datalink__m2m.html#911fb7fcfa80d4e31db8e0cc03141a90" title="Get cond for myself from val and cond of &quot;Up&quot;.">get_cond</a> (<span class="keyword">const</span> vec &val_up, <span class="keyword">const</span> vec &cond_up) { |
| 466 | <a name="l00658"></a>00658 vec tmp (<a class="code" href="classbdm_1_1datalink__m2e.html#3fb26525e0bfa7932a37c5cd404801f9" title="Remember how long cond should be.">condsize</a>); |
| 467 | <a name="l00659"></a>00659 set_subvector (tmp, <a class="code" href="classbdm_1_1datalink__m2e.html#9e0048d87bda78e9b8d38761440c7abc" title="upper_val-to-local_cond link, indices of the local cond">v2c_lo</a>, val_up (<a class="code" href="classbdm_1_1datalink__m2e.html#43fe3e2d7aa04134053ec15793722783" title="upper_val-to-local_cond link, indices of the upper val">v2c_up</a>)); |
| 468 | <a name="l00660"></a>00660 set_subvector (tmp, <a class="code" href="classbdm_1_1datalink__m2m.html#0ea05c47de4538b7042ff878e6e309a5" title="cond-to-cond link, indices of the local cond">c2c_lo</a>, cond_up (<a class="code" href="classbdm_1_1datalink__m2m.html#d64dda6f92654628276bbcebb7600d0d" title="cond-to-cond link, indices of the upper cond">c2c_up</a>)); |
| 469 | <a name="l00661"></a>00661 <span class="keywordflow">return</span> tmp; |
| 470 | <a name="l00662"></a>00662 } |
| 471 | <a name="l00664"></a>00664 |
| 472 | <a name="l00665"></a>00665 }; |
| 473 | <a name="l00666"></a>00666 |
| 474 | <a name="l00672"></a><a class="code" href="classbdm_1_1logger.html">00672</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> |
| 475 | <a name="l00673"></a>00673 { |
| 476 | <a name="l00674"></a>00674 <span class="keyword">protected</span>: |
| 477 | <a name="l00676"></a><a class="code" href="classbdm_1_1logger.html#c54566a4554089443a20b2a49ed1a61f">00676</a> Array<RV> <a class="code" href="classbdm_1_1logger.html#c54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a>; |
| 478 | <a name="l00678"></a><a class="code" href="classbdm_1_1logger.html#68ca1f05cf3d414ba0f39211977b8d02">00678</a> Array<string> <a class="code" href="classbdm_1_1logger.html#68ca1f05cf3d414ba0f39211977b8d02" title="Names of logged quantities, e.g. names of algorithm variants.">names</a>; |
| 479 | <a name="l00679"></a>00679 <span class="keyword">public</span>: |
| 480 | <a name="l00681"></a><a class="code" href="classbdm_1_1logger.html#f9c2fe7db5ddbda0098a4a5bd2c29fbf">00681</a> <a class="code" href="classbdm_1_1logger.html#f9c2fe7db5ddbda0098a4a5bd2c29fbf" title="Default constructor.">logger</a>() : <a class="code" href="classbdm_1_1logger.html#c54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a> (0), <a class="code" href="classbdm_1_1logger.html#68ca1f05cf3d414ba0f39211977b8d02" title="Names of logged quantities, e.g. names of algorithm variants.">names</a> (0) {} |
| 481 | <a name="l00682"></a>00682 |
| 482 | <a name="l00685"></a><a class="code" href="classbdm_1_1logger.html#47aa3b098a81d02a8ffaea2c9fa09ac7">00685</a> <span class="keyword">virtual</span> <span class="keywordtype">int</span> <span class="keyword">add</span> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv, <span class="keywordtype">string</span> prefix = <span class="stringliteral">""</span>) { |
| 483 | <a name="l00686"></a>00686 <span class="keywordtype">int</span> id; |
| 484 | <a name="l00687"></a>00687 <span class="keywordflow">if</span> (rv._dsize() > 0) { |
| 485 | <a name="l00688"></a>00688 <span class="keywordtype">id</span> = <a class="code" href="classbdm_1_1logger.html#c54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a>.length(); |
| 486 | <a name="l00689"></a>00689 <a class="code" href="classbdm_1_1logger.html#68ca1f05cf3d414ba0f39211977b8d02" title="Names of logged quantities, e.g. names of algorithm variants.">names</a> = concat (<a class="code" href="classbdm_1_1logger.html#68ca1f05cf3d414ba0f39211977b8d02" title="Names of logged quantities, e.g. names of algorithm variants.">names</a>, prefix); <span class="comment">// diff</span> |
| 487 | <a name="l00690"></a>00690 <a class="code" href="classbdm_1_1logger.html#c54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a>.set_length (<span class="keywordtype">id</span> + 1, <span class="keyword">true</span>); |
| 488 | <a name="l00691"></a>00691 <a class="code" href="classbdm_1_1logger.html#c54566a4554089443a20b2a49ed1a61f" title="RVs of all logged variables.">entries</a> (<span class="keywordtype">id</span>) = rv; |
| 489 | <a name="l00692"></a>00692 } <span class="keywordflow">else</span> { |
| 490 | <a name="l00693"></a>00693 <span class="keywordtype">id</span> = -1; |
| 491 | <a name="l00694"></a>00694 } |
| 492 | <a name="l00695"></a>00695 <span class="keywordflow">return</span> id; <span class="comment">// identifier of the last entry</span> |
| 493 | <a name="l00696"></a>00696 } |
| 494 | <a name="l00697"></a>00697 |
| 495 | <a name="l00699"></a>00699 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> (<span class="keywordtype">int</span> <span class="keywordtype">id</span>, <span class="keyword">const</span> vec &v) = 0; |
| 496 | <a name="l00701"></a>00701 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> (<span class="keywordtype">int</span> <span class="keywordtype">id</span>, <span class="keyword">const</span> <span class="keywordtype">double</span> &d) = 0; |
| 497 | <a name="l00702"></a>00702 |
| 498 | <a name="l00704"></a>00704 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1logger.html#4f31c03578a7b9b30d8b1f8c338a37e8" title="Shifts storage position for another time step.">step</a>() = 0; |
| 499 | <a name="l00705"></a>00705 |
| 500 | <a name="l00707"></a><a class="code" href="classbdm_1_1logger.html#0e3fc7d13e23a8f71fc7c8a5ea68559d">00707</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1logger.html#0e3fc7d13e23a8f71fc7c8a5ea68559d" title="Finalize storing information.">finalize</a>() {}; |
| 501 | <a name="l00708"></a>00708 |
| 502 | <a name="l00710"></a><a class="code" href="classbdm_1_1logger.html#cd6291a73491f755dc7bc88d022eb2fc">00710</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1logger.html#cd6291a73491f755dc7bc88d022eb2fc" title="Initialize the storage.">init</a>() {}; |
| 503 | <a name="l00711"></a>00711 |
| 504 | <a name="l00712"></a>00712 }; |
| 505 | <a name="l00713"></a>00713 |
| 506 | <a name="l00717"></a><a class="code" href="classbdm_1_1mepdf.html">00717</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mepdf.html" title="Unconditional mpdf, allows using epdf in the role of mpdf.">mepdf</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling , where is random variable, rv, and...">mpdf</a> |
| 507 | <a name="l00718"></a>00718 { |
| 508 | <a name="l00720"></a>00720 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<epdf></a> iepdf; |
| 509 | <a name="l00721"></a>00721 <span class="keyword">public</span>: |
| 510 | <a name="l00723"></a><a class="code" href="classbdm_1_1mepdf.html#4a2b01e7bb510c6b8946757cae6c9155">00723</a> <a class="code" href="classbdm_1_1mepdf.html#4a2b01e7bb510c6b8946757cae6c9155" title="Default constructor.">mepdf</a>() { } |
| 511 | <a name="l00725"></a><a class="code" href="classbdm_1_1mepdf.html#1f94e70702ff676f53d95ca7ec38e25c">00725</a> <a class="code" href="classbdm_1_1mepdf.html#1f94e70702ff676f53d95ca7ec38e25c" title="Set internal shared pointer.">mepdf</a> (<a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<epdf></a> em) { |
| 512 | <a name="l00726"></a>00726 iepdf = em; |
| 513 | <a name="l00727"></a>00727 <a class="code" href="classbdm_1_1mpdf.html#147afacb393324bb3f9a7a89e33f835e" title="set internal pointer ep to point to given iepdf ">set_ep</a> (*iepdf.<a class="code" href="classbdm_1_1shared__ptr.html#37ebcfb6750dd7b5630f1d2354c07a96">get</a>()); |
| 514 | <a name="l00728"></a>00728 <a class="code" href="classbdm_1_1mpdf.html#7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a> = 0; |
| 515 | <a name="l00729"></a>00729 } |
| 516 | <a name="l00730"></a>00730 |
| 517 | <a name="l00732"></a><a class="code" href="classbdm_1_1mepdf.html#b904a90ef78294040b498717cc13015e">00732</a> vec <a class="code" href="classbdm_1_1mepdf.html#b904a90ef78294040b498717cc13015e" title="empty">samplecond</a>(<span class="keyword">const</span> vec &cond){<span class="keywordflow">return</span> iepdf->sample();} |
| 518 | <a name="l00733"></a><a class="code" href="classbdm_1_1mepdf.html#57decd7718f3789e9d1f10f19def935b">00733</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mepdf.html#57decd7718f3789e9d1f10f19def935b" title="Shortcut for conditioning and evaluation of the internal epdf. In some cases, this...">evallogcond</a>(<span class="keyword">const</span> vec &val, <span class="keyword">const</span> vec &cond){<span class="keywordflow">return</span> iepdf->evallog(val);} |
| 519 | <a name="l00734"></a>00734 |
| 520 | <a name="l00742"></a>00742 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mepdf.html#27ef18a3e3b1b5de02739d1324bf25fb">from_setting</a> (<span class="keyword">const</span> Setting &<span class="keyword">set</span>); |
| 521 | <a name="l00743"></a>00743 }; |
| 522 | <a name="l00744"></a>00744 <a class="code" href="user__info_8h.html#4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a> (mepdf); |
| 523 | <a name="l00745"></a>00745 SHAREDPTR (mepdf); |
| 524 | <a name="l00746"></a>00746 |
| 525 | <a name="l00748"></a>00748 RV get_composite_rv ( <span class="keyword">const</span> Array<shared_ptr<mpdf> > &mpdfs, <span class="keywordtype">bool</span> checkoverlap = <span class="keyword">false</span> ); |
| 526 | <a name="l00749"></a>00749 |
| 527 | <a name="l00757"></a><a class="code" href="classbdm_1_1DS.html">00757</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1DS.html" title="Abstract class for discrete-time sources of data.">DS</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> |
| 528 | <a name="l00758"></a>00758 { |
| 529 | <a name="l00759"></a>00759 <span class="keyword">protected</span>: |
| 530 | <a name="l00760"></a>00760 <span class="keywordtype">int</span> dtsize; |
| 531 | <a name="l00761"></a>00761 <span class="keywordtype">int</span> utsize; |
| 532 | <a name="l00763"></a><a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec">00763</a> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>; |
| 533 | <a name="l00765"></a><a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702">00765</a> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>; <span class="comment">//</span> |
| 534 | <a name="l00767"></a><a class="code" href="classbdm_1_1DS.html#b4b7bdb9d98a11ab587aa0ad803bb867">00767</a> <span class="comment"></span> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1DS.html#b4b7bdb9d98a11ab587aa0ad803bb867" title="Remember its own index in Logger L.">L_dt</a>, L_ut; |
| 535 | <a name="l00768"></a>00768 <span class="keyword">public</span>: |
| 536 | <a name="l00770"></a><a class="code" href="classbdm_1_1DS.html#bedd82e08ae6686b4b1732a122c2201a">00770</a> <a class="code" href="classbdm_1_1DS.html#bedd82e08ae6686b4b1732a122c2201a" title="default constructors">DS</a>() : <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>(), <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>() {}; |
| 537 | <a name="l00772"></a><a class="code" href="classbdm_1_1DS.html#c1ec862dec7164fee3284c6f9a51b0ba">00772</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1DS.html#c1ec862dec7164fee3284c6f9a51b0ba" title="Returns full vector of observed data=[output, input].">getdata</a> (vec &dt) { |
| 538 | <a name="l00773"></a>00773 it_error (<span class="stringliteral">"abstract class"</span>); |
| 539 | <a name="l00774"></a>00774 }; |
| 540 | <a name="l00776"></a><a class="code" href="classbdm_1_1DS.html#a0bf451c7fea73ff4150ff9e83da4832">00776</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1DS.html#a0bf451c7fea73ff4150ff9e83da4832" title="Returns data records at indeces.">getdata</a> (vec &dt, <span class="keyword">const</span> ivec &indeces) { |
| 541 | <a name="l00777"></a>00777 it_error (<span class="stringliteral">"abstract class"</span>); |
| 542 | <a name="l00778"></a>00778 }; |
| 543 | <a name="l00780"></a><a class="code" href="classbdm_1_1DS.html#f5baeee8528e5e4c5c7a344b2e3f192a">00780</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1DS.html#f5baeee8528e5e4c5c7a344b2e3f192a" title="Accepts action variable and schedule it for application.">write</a> (vec &ut) { |
| 544 | <a name="l00781"></a>00781 it_error (<span class="stringliteral">"abstract class"</span>); |
| 545 | <a name="l00782"></a>00782 }; |
| 546 | <a name="l00784"></a><a class="code" href="classbdm_1_1DS.html#6bced13f84f6bf04449728817e049e1d">00784</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1DS.html#6bced13f84f6bf04449728817e049e1d" title="Accepts action variables at specific indeces.">write</a> (vec &ut, <span class="keyword">const</span> ivec &indeces) { |
| 547 | <a name="l00785"></a>00785 it_error (<span class="stringliteral">"abstract class"</span>); |
| 548 | <a name="l00786"></a>00786 }; |
| 549 | <a name="l00787"></a>00787 |
| 550 | <a name="l00789"></a>00789 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1DS.html#9a14c64d881e838ddc3a5617ee8a973b" title="Moves from to , i.e. perfroms the actions and reads response of the system.">step</a>() = 0; |
517 | | <a name="l00791"></a>00791 |
518 | | <a name="l00794"></a>00794 |
519 | | <a name="l00795"></a>00795 <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a>& _drv()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1BM.html#c400357e37d27a4834b2b1d9211009ed" title="Random variable of the data (optional).">drv</a>;} |
520 | | <a name="l00796"></a>00796 <span class="keywordtype">void</span> set_drv(<span class="keyword">const</span> RV &rv) {<a class="code" href="classbdm_1_1BM.html#c400357e37d27a4834b2b1d9211009ed" title="Random variable of the data (optional).">drv</a> = rv;} |
521 | | <a name="l00797"></a>00797 <span class="keywordtype">void</span> set_rv(<span class="keyword">const</span> RV &rv) {<span class="keyword">const_cast<</span>epdf&<span class="keyword">></span>(posterior()).set_rv(rv);} |
522 | | <a name="l00798"></a>00798 <span class="keywordtype">double</span> _ll()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1BM.html#4064b6559d962633e4372b12f4cd204a" title="Logarithm of marginalized data likelihood.">ll</a>;} |
523 | | <a name="l00799"></a>00799 <span class="keywordtype">void</span> set_evalll(<span class="keywordtype">bool</span> evl0) {<a class="code" href="classbdm_1_1BM.html#faff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a> = evl0;} |
524 | | <a name="l00800"></a>00800 <span class="keyword">virtual</span> <span class="keyword">const</span> epdf& posterior() <span class="keyword">const</span> = 0; |
525 | | <a name="l00801"></a>00801 <span class="keyword">virtual</span> <span class="keyword">const</span> epdf* _e() <span class="keyword">const</span> = 0; |
526 | | <a name="l00803"></a>00803 |
527 | | <a name="l00806"></a>00806 |
528 | | <a name="l00808"></a><a class="code" href="classbdm_1_1BM.html#adb539fa2585c8a2a91c54e5aebf330e">00808</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1BM.html#adb539fa2585c8a2a91c54e5aebf330e" title="Set boolean options from a string recognized are: &quot;logbounds,logll&quot;.">set_options</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &opt) { |
529 | | <a name="l00809"></a>00809 <a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a>(0) = 1; |
530 | | <a name="l00810"></a>00810 <span class="keywordflow">if</span> (opt.find(<span class="stringliteral">"logbounds"</span>) != string::npos) {<a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a>(1) = 1; <a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a>(2) = 1;} |
531 | | <a name="l00811"></a>00811 <span class="keywordflow">if</span> (opt.find(<span class="stringliteral">"logll"</span>) != string::npos) {<a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a>(3) = 1;} |
532 | | <a name="l00812"></a>00812 } |
533 | | <a name="l00814"></a><a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca">00814</a> ivec <a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a>; |
534 | | <a name="l00815"></a>00815 |
535 | | <a name="l00817"></a><a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207">00817</a> ivec <a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a>; |
536 | | <a name="l00819"></a><a class="code" href="classbdm_1_1BM.html#2298ca6af9b13a78a4c9e18ab43f1827">00819</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1BM.html#2298ca6af9b13a78a4c9e18ab43f1827" title="Add all logged variables to a logger.">log_add</a>(<a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> &L, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span>) { |
537 | | <a name="l00820"></a>00820 <span class="comment">// internal</span> |
538 | | <a name="l00821"></a>00821 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> r; |
539 | | <a name="l00822"></a>00822 <span class="keywordflow">if</span> (posterior().isnamed()) {r = posterior().<a class="code" href="classbdm_1_1epdf.html#a4ab378d5e004c3ff3e2d4e64f7bba21" title="Return name (fails when isnamed is false).">_rv</a>();} |
540 | | <a name="l00823"></a>00823 <span class="keywordflow">else</span> {r = <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a>(<span class="stringliteral">"est"</span>, posterior().dimension());}; |
541 | | <a name="l00824"></a>00824 |
542 | | <a name="l00825"></a>00825 <span class="comment">// Add mean value</span> |
543 | | <a name="l00826"></a>00826 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a>(0)) <a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a>(0) = L.<a class="code" href="classbdm_1_1logger.html#47aa3b098a81d02a8ffaea2c9fa09ac7">add</a>(r, name + <span class="stringliteral">"mean_"</span>); |
544 | | <a name="l00827"></a>00827 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a>(1)) <a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a>(1) = L.<a class="code" href="classbdm_1_1logger.html#47aa3b098a81d02a8ffaea2c9fa09ac7">add</a>(r, name + <span class="stringliteral">"lb_"</span>); |
545 | | <a name="l00828"></a>00828 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a>(2)) <a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a>(2) = L.<a class="code" href="classbdm_1_1logger.html#47aa3b098a81d02a8ffaea2c9fa09ac7">add</a>(r, name + <span class="stringliteral">"ub_"</span>); |
546 | | <a name="l00829"></a>00829 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a>(3)) <a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a>(3) = L.<a class="code" href="classbdm_1_1logger.html#47aa3b098a81d02a8ffaea2c9fa09ac7">add</a>(<a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a>(<span class="stringliteral">"ll"</span>, 1), name); <span class="comment">//TODO: "local" RV</span> |
547 | | <a name="l00830"></a>00830 } |
548 | | <a name="l00831"></a>00831 <span class="keyword">virtual</span> <span class="keywordtype">void</span> logit(<a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> &L) { |
549 | | <a name="l00832"></a>00832 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a>(<a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a>(0), posterior().mean()); |
550 | | <a name="l00833"></a>00833 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a>(1) || <a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a>(2)) { <span class="comment">//if one of them is off, its LID==-1 and will not be stored</span> |
551 | | <a name="l00834"></a>00834 vec ub, lb; |
552 | | <a name="l00835"></a>00835 posterior().<a class="code" href="classbdm_1_1epdf.html#0a7705e80601957f7226d333a0a6d539" title="Lower and upper bounds of percentage % quantile, returns mean-2*sigma as default...">qbounds</a>(lb, ub); |
553 | | <a name="l00836"></a>00836 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a>(<a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a>(1), lb); |
554 | | <a name="l00837"></a>00837 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a>(<a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a>(2), ub); |
555 | | <a name="l00838"></a>00838 } |
556 | | <a name="l00839"></a>00839 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a>(3)) L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a>(<a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a>(3), <a class="code" href="classbdm_1_1BM.html#4064b6559d962633e4372b12f4cd204a" title="Logarithm of marginalized data likelihood.">ll</a>); |
557 | | <a name="l00840"></a>00840 } |
558 | | <a name="l00842"></a>00842 }; |
559 | | <a name="l00843"></a>00843 |
560 | | <a name="l00844"></a>00844 |
561 | | <a name="l00845"></a>00845 }; <span class="comment">//namespace</span> |
562 | | <a name="l00846"></a>00846 <span class="preprocessor">#endif // BDMBASE_H</span> |
| 552 | <a name="l00792"></a><a class="code" href="classbdm_1_1DS.html#3c9e417d85052396fe74c164857ee67e">00792</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1DS.html#3c9e417d85052396fe74c164857ee67e" title="Register DS for logging into logger L.">log_add</a> (<a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> &L) { |
| 553 | <a name="l00793"></a>00793 it_assert_debug (dtsize == <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(), <span class="stringliteral">""</span>); |
| 554 | <a name="l00794"></a>00794 it_assert_debug (utsize == <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(), <span class="stringliteral">""</span>); |
| 555 | <a name="l00795"></a>00795 |
| 556 | <a name="l00796"></a>00796 <a class="code" href="classbdm_1_1DS.html#b4b7bdb9d98a11ab587aa0ad803bb867" title="Remember its own index in Logger L.">L_dt</a> = L.<a class="code" href="classbdm_1_1logger.html#47aa3b098a81d02a8ffaea2c9fa09ac7">add</a> (<a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>, <span class="stringliteral">""</span>); |
| 557 | <a name="l00797"></a>00797 L_ut = L.<a class="code" href="classbdm_1_1logger.html#47aa3b098a81d02a8ffaea2c9fa09ac7">add</a> (<a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>, <span class="stringliteral">""</span>); |
| 558 | <a name="l00798"></a>00798 } |
| 559 | <a name="l00800"></a><a class="code" href="classbdm_1_1DS.html#e03d2c93cddd5c3a03107ddd3ae999cf">00800</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1DS.html#e03d2c93cddd5c3a03107ddd3ae999cf" title="Register DS for logging into logger L.">logit</a> (<a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> &L) { |
| 560 | <a name="l00801"></a>00801 vec tmp (<a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>() + <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>()); |
| 561 | <a name="l00802"></a>00802 <a class="code" href="classbdm_1_1DS.html#c1ec862dec7164fee3284c6f9a51b0ba" title="Returns full vector of observed data=[output, input].">getdata</a> (tmp); |
| 562 | <a name="l00803"></a>00803 <span class="comment">// d is first in getdata</span> |
| 563 | <a name="l00804"></a>00804 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> (<a class="code" href="classbdm_1_1DS.html#b4b7bdb9d98a11ab587aa0ad803bb867" title="Remember its own index in Logger L.">L_dt</a>, tmp.left (<a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>())); |
| 564 | <a name="l00805"></a>00805 <span class="comment">// u follows after d in getdata</span> |
| 565 | <a name="l00806"></a>00806 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> (L_ut, tmp.mid (<a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(), <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>())); |
| 566 | <a name="l00807"></a>00807 } |
| 567 | <a name="l00809"></a><a class="code" href="classbdm_1_1DS.html#ed2113851294ed96abe60fc3f05aa660">00809</a> <span class="keyword">virtual</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1DS.html#ed2113851294ed96abe60fc3f05aa660" title="access function">_drv</a>()<span class="keyword"> const </span>{ |
| 568 | <a name="l00810"></a>00810 <span class="keywordflow">return</span> concat (<a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a>, <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>); |
| 569 | <a name="l00811"></a>00811 } |
| 570 | <a name="l00813"></a><a class="code" href="classbdm_1_1DS.html#a6a9a375da64c82fc227bda3418a1f33">00813</a> <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a>& <a class="code" href="classbdm_1_1DS.html#a6a9a375da64c82fc227bda3418a1f33" title="access function">_urv</a>()<span class="keyword"> const </span>{ |
| 571 | <a name="l00814"></a>00814 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a>; |
| 572 | <a name="l00815"></a>00815 } |
| 573 | <a name="l00817"></a><a class="code" href="classbdm_1_1DS.html#821297dfd839d68691324f024e57252f">00817</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1DS.html#821297dfd839d68691324f024e57252f" title="set random rvariables">set_drv</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &drv, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &urv) { |
| 574 | <a name="l00818"></a>00818 <a class="code" href="classbdm_1_1DS.html#d8db125ac35f3b8eeb773fc9a4cb45ec" title="Description of data returned by getdata().">Drv</a> = drv; |
| 575 | <a name="l00819"></a>00819 <a class="code" href="classbdm_1_1DS.html#9ac5970128fd39f4f6226723cd1de702" title="Description of data witten by by write().">Urv</a> = urv; |
| 576 | <a name="l00820"></a>00820 } |
| 577 | <a name="l00821"></a>00821 }; |
| 578 | <a name="l00822"></a>00822 |
| 579 | <a name="l00844"></a><a class="code" href="classbdm_1_1BM.html">00844</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of a system, i.e. all uncertainty is modeled by probabilities.">BM</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1root.html" title="Root class of BDM objects.">root</a> |
| 580 | <a name="l00845"></a>00845 { |
| 581 | <a name="l00846"></a>00846 <span class="keyword">protected</span>: |
| 582 | <a name="l00848"></a><a class="code" href="classbdm_1_1BM.html#c400357e37d27a4834b2b1d9211009ed">00848</a> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1BM.html#c400357e37d27a4834b2b1d9211009ed" title="Random variable of the data (optional).">drv</a>; |
| 583 | <a name="l00850"></a><a class="code" href="classbdm_1_1BM.html#4064b6559d962633e4372b12f4cd204a">00850</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1BM.html#4064b6559d962633e4372b12f4cd204a" title="Logarithm of marginalized data likelihood.">ll</a>; |
| 584 | <a name="l00852"></a><a class="code" href="classbdm_1_1BM.html#faff0ad12556fe7dc0e2807d4fd938ee">00852</a> <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1BM.html#faff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>; |
| 585 | <a name="l00853"></a>00853 <span class="keyword">public</span>: |
| 586 | <a name="l00856"></a>00856 |
| 587 | <a name="l00857"></a>00857 <a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of a system, i.e. all uncertainty is modeled by probabilities.">BM</a>() : <a class="code" href="classbdm_1_1BM.html#4064b6559d962633e4372b12f4cd204a" title="Logarithm of marginalized data likelihood.">ll</a> (0), <a class="code" href="classbdm_1_1BM.html#faff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a> (true), <a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a> (4), <a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a> (4) { |
| 588 | <a name="l00858"></a>00858 <a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a> = -1;<span class="comment">/*empty IDs*/</span> |
| 589 | <a name="l00859"></a>00859 <a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a> = 0; |
| 590 | <a name="l00860"></a>00860 <a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a> (0) = 1; <span class="comment">/*log only mean*/</span> |
| 591 | <a name="l00861"></a>00861 }; |
| 592 | <a name="l00862"></a>00862 <a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of a system, i.e. all uncertainty is modeled by probabilities.">BM</a> (<span class="keyword">const</span> <a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of a system, i.e. all uncertainty is modeled by probabilities.">BM</a> &B) : <a class="code" href="classbdm_1_1BM.html#c400357e37d27a4834b2b1d9211009ed" title="Random variable of the data (optional).">drv</a> (B.<a class="code" href="classbdm_1_1BM.html#c400357e37d27a4834b2b1d9211009ed" title="Random variable of the data (optional).">drv</a>), <a class="code" href="classbdm_1_1BM.html#4064b6559d962633e4372b12f4cd204a" title="Logarithm of marginalized data likelihood.">ll</a> (B.<a class="code" href="classbdm_1_1BM.html#4064b6559d962633e4372b12f4cd204a" title="Logarithm of marginalized data likelihood.">ll</a>), <a class="code" href="classbdm_1_1BM.html#faff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a> (B.<a class="code" href="classbdm_1_1BM.html#faff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>) {} |
| 593 | <a name="l00865"></a><a class="code" href="classbdm_1_1BM.html#40f01563651c1e4fe926189e41a6b8ab">00865</a> <span class="keyword">virtual</span> <a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of a system, i.e. all uncertainty is modeled by probabilities.">BM</a>* <a class="code" href="classbdm_1_1BM.html#40f01563651c1e4fe926189e41a6b8ab">_copy_</a>()<span class="keyword"> const </span>{ |
| 594 | <a name="l00866"></a>00866 <span class="keywordflow">return</span> NULL; |
| 595 | <a name="l00867"></a>00867 }; |
| 596 | <a name="l00869"></a>00869 |
| 597 | <a name="l00872"></a>00872 |
| 598 | <a name="l00876"></a>00876 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1BM.html#60b1779a577367c369a932cabd3a6188" title="Incremental Bayes rule.">bayes</a> (<span class="keyword">const</span> vec &dt) = 0; |
| 599 | <a name="l00878"></a>00878 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1BM.html#1dee3fddaf021e62d925289660a707dc" title="Batch Bayes rule (columns of Dt are observations).">bayesB</a> (<span class="keyword">const</span> mat &Dt); |
| 600 | <a name="l00881"></a><a class="code" href="classbdm_1_1BM.html#50257e0c1e5b5c73153ea6e716ad8ae0">00881</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1BM.html#50257e0c1e5b5c73153ea6e716ad8ae0">logpred</a> (<span class="keyword">const</span> vec &dt)<span class="keyword"> const </span>{ |
| 601 | <a name="l00882"></a>00882 it_error (<span class="stringliteral">"Not implemented"</span>); |
| 602 | <a name="l00883"></a>00883 <span class="keywordflow">return</span> 0.0; |
| 603 | <a name="l00884"></a>00884 } |
| 604 | <a name="l00886"></a><a class="code" href="classbdm_1_1BM.html#0e8ebe61fb14990abe1254bd3dda5fae">00886</a> vec <a class="code" href="classbdm_1_1BM.html#0e8ebe61fb14990abe1254bd3dda5fae" title="Matrix version of logpred.">logpred_m</a> (<span class="keyword">const</span> mat &dt)<span class="keyword"> const </span>{ |
| 605 | <a name="l00887"></a>00887 vec tmp (dt.cols()); |
| 606 | <a name="l00888"></a>00888 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < dt.cols(); i++) { |
| 607 | <a name="l00889"></a>00889 tmp (i) = <a class="code" href="classbdm_1_1BM.html#50257e0c1e5b5c73153ea6e716ad8ae0">logpred</a> (dt.get_col (i)); |
| 608 | <a name="l00890"></a>00890 } |
| 609 | <a name="l00891"></a>00891 <span class="keywordflow">return</span> tmp; |
| 610 | <a name="l00892"></a>00892 } |
| 611 | <a name="l00893"></a>00893 |
| 612 | <a name="l00895"></a><a class="code" href="classbdm_1_1BM.html#688d7a2aced1e06aa1c468d73a9e5eba">00895</a> <span class="keyword">virtual</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* <a class="code" href="classbdm_1_1BM.html#688d7a2aced1e06aa1c468d73a9e5eba" title="Constructs a predictive density .">epredictor</a>()<span class="keyword"> const </span>{ |
| 613 | <a name="l00896"></a>00896 it_error (<span class="stringliteral">"Not implemented"</span>); |
| 614 | <a name="l00897"></a>00897 <span class="keywordflow">return</span> NULL; |
| 615 | <a name="l00898"></a>00898 }; |
| 616 | <a name="l00900"></a><a class="code" href="classbdm_1_1BM.html#598b25e3f3d96a5bc00a5faeb5b3c912">00900</a> <span class="keyword">virtual</span> <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling , where is random variable, rv, and...">mpdf</a>* <a class="code" href="classbdm_1_1BM.html#598b25e3f3d96a5bc00a5faeb5b3c912" title="Constructs conditional density of 1-step ahead predictor .">predictor</a>()<span class="keyword"> const </span>{ |
| 617 | <a name="l00901"></a>00901 it_error (<span class="stringliteral">"Not implemented"</span>); |
| 618 | <a name="l00902"></a>00902 <span class="keywordflow">return</span> NULL; |
| 619 | <a name="l00903"></a>00903 }; |
| 620 | <a name="l00905"></a>00905 |
| 621 | <a name="l00910"></a>00910 |
| 622 | <a name="l00912"></a><a class="code" href="classbdm_1_1BM.html#de95c590d650b2db423d53992f0906cb">00912</a> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1BM.html#de95c590d650b2db423d53992f0906cb" title="Name of extension variable.">rvc</a>; |
| 623 | <a name="l00914"></a><a class="code" href="classbdm_1_1BM.html#b5e8e016be16e4029c789063cb3f3b33">00914</a> <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a>& <a class="code" href="classbdm_1_1BM.html#b5e8e016be16e4029c789063cb3f3b33" title="access function">_rvc</a>()<span class="keyword"> const </span>{ |
| 624 | <a name="l00915"></a>00915 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1BM.html#de95c590d650b2db423d53992f0906cb" title="Name of extension variable.">rvc</a>; |
| 625 | <a name="l00916"></a>00916 } |
| 626 | <a name="l00917"></a>00917 |
| 627 | <a name="l00919"></a><a class="code" href="classbdm_1_1BM.html#6799f4b16a6a59ed58b1d0d6e17116f4">00919</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1BM.html#6799f4b16a6a59ed58b1d0d6e17116f4" title="Substitute val for rvc.">condition</a> (<span class="keyword">const</span> vec &val) { |
| 628 | <a name="l00920"></a>00920 it_error (<span class="stringliteral">"Not implemented!"</span>); |
| 629 | <a name="l00921"></a>00921 }; |
| 630 | <a name="l00922"></a>00922 |
| 631 | <a name="l00924"></a>00924 |
| 632 | <a name="l00925"></a>00925 |
| 633 | <a name="l00928"></a>00928 |
| 634 | <a name="l00929"></a>00929 <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a>& _drv()<span class="keyword"> const </span>{ |
| 635 | <a name="l00930"></a>00930 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1BM.html#c400357e37d27a4834b2b1d9211009ed" title="Random variable of the data (optional).">drv</a>; |
| 636 | <a name="l00931"></a>00931 } |
| 637 | <a name="l00932"></a>00932 <span class="keywordtype">void</span> set_drv (<span class="keyword">const</span> RV &rv) { |
| 638 | <a name="l00933"></a>00933 <a class="code" href="classbdm_1_1BM.html#c400357e37d27a4834b2b1d9211009ed" title="Random variable of the data (optional).">drv</a> = rv; |
| 639 | <a name="l00934"></a>00934 } |
| 640 | <a name="l00935"></a>00935 <span class="keywordtype">void</span> set_rv (<span class="keyword">const</span> RV &rv) { |
| 641 | <a name="l00936"></a>00936 <span class="keyword">const_cast<</span>epdf&<span class="keyword">></span> (posterior()).set_rv (rv); |
| 642 | <a name="l00937"></a>00937 } |
| 643 | <a name="l00938"></a>00938 <span class="keywordtype">double</span> _ll()<span class="keyword"> const </span>{ |
| 644 | <a name="l00939"></a>00939 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1BM.html#4064b6559d962633e4372b12f4cd204a" title="Logarithm of marginalized data likelihood.">ll</a>; |
| 645 | <a name="l00940"></a>00940 } |
| 646 | <a name="l00941"></a>00941 <span class="keywordtype">void</span> set_evalll (<span class="keywordtype">bool</span> evl0) { |
| 647 | <a name="l00942"></a>00942 <a class="code" href="classbdm_1_1BM.html#faff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a> = evl0; |
| 648 | <a name="l00943"></a>00943 } |
| 649 | <a name="l00944"></a>00944 <span class="keyword">virtual</span> <span class="keyword">const</span> epdf& posterior() <span class="keyword">const</span> = 0; |
| 650 | <a name="l00946"></a>00946 |
| 651 | <a name="l00949"></a>00949 |
| 652 | <a name="l00951"></a><a class="code" href="classbdm_1_1BM.html#adb539fa2585c8a2a91c54e5aebf330e">00951</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1BM.html#adb539fa2585c8a2a91c54e5aebf330e" title="Set boolean options from a string, recognized are: &quot;logbounds,logll&quot;.">set_options</a> (<span class="keyword">const</span> <span class="keywordtype">string</span> &opt) { |
| 653 | <a name="l00952"></a>00952 <a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a> (0) = 1; |
| 654 | <a name="l00953"></a>00953 <span class="keywordflow">if</span> (opt.find (<span class="stringliteral">"logbounds"</span>) != string::npos) { |
| 655 | <a name="l00954"></a>00954 <a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a> (1) = 1; |
| 656 | <a name="l00955"></a>00955 <a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a> (2) = 1; |
| 657 | <a name="l00956"></a>00956 } |
| 658 | <a name="l00957"></a>00957 <span class="keywordflow">if</span> (opt.find (<span class="stringliteral">"logll"</span>) != string::npos) { |
| 659 | <a name="l00958"></a>00958 <a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a> (3) = 1; |
| 660 | <a name="l00959"></a>00959 } |
| 661 | <a name="l00960"></a>00960 } |
| 662 | <a name="l00962"></a><a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca">00962</a> ivec <a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a>; |
| 663 | <a name="l00963"></a>00963 |
| 664 | <a name="l00965"></a><a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207">00965</a> ivec <a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a>; |
| 665 | <a name="l00967"></a><a class="code" href="classbdm_1_1BM.html#2298ca6af9b13a78a4c9e18ab43f1827">00967</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1BM.html#2298ca6af9b13a78a4c9e18ab43f1827" title="Add all logged variables to a logger.">log_add</a> (<a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> &L, <span class="keyword">const</span> <span class="keywordtype">string</span> &name = <span class="stringliteral">""</span>) { |
| 666 | <a name="l00968"></a>00968 <span class="comment">// internal</span> |
| 667 | <a name="l00969"></a>00969 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> r; |
| 668 | <a name="l00970"></a>00970 <span class="keywordflow">if</span> (posterior().isnamed()) { |
| 669 | <a name="l00971"></a>00971 r = posterior().<a class="code" href="classbdm_1_1epdf.html#a4ab378d5e004c3ff3e2d4e64f7bba21" title="Return name (fails when isnamed is false).">_rv</a>(); |
| 670 | <a name="l00972"></a>00972 } <span class="keywordflow">else</span> { |
| 671 | <a name="l00973"></a>00973 r = <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> (<span class="stringliteral">"est"</span>, posterior().dimension()); |
| 672 | <a name="l00974"></a>00974 }; |
| 673 | <a name="l00975"></a>00975 |
| 674 | <a name="l00976"></a>00976 <span class="comment">// Add mean value</span> |
| 675 | <a name="l00977"></a>00977 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a> (0)) <a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a> (0) = L.<a class="code" href="classbdm_1_1logger.html#47aa3b098a81d02a8ffaea2c9fa09ac7">add</a> (r, name + <span class="stringliteral">"mean_"</span>); |
| 676 | <a name="l00978"></a>00978 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a> (1)) <a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a> (1) = L.<a class="code" href="classbdm_1_1logger.html#47aa3b098a81d02a8ffaea2c9fa09ac7">add</a> (r, name + <span class="stringliteral">"lb_"</span>); |
| 677 | <a name="l00979"></a>00979 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a> (2)) <a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a> (2) = L.<a class="code" href="classbdm_1_1logger.html#47aa3b098a81d02a8ffaea2c9fa09ac7">add</a> (r, name + <span class="stringliteral">"ub_"</span>); |
| 678 | <a name="l00980"></a>00980 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a> (3)) <a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a> (3) = L.<a class="code" href="classbdm_1_1logger.html#47aa3b098a81d02a8ffaea2c9fa09ac7">add</a> (<a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> (<span class="stringliteral">"ll"</span>, 1), name); <span class="comment">//TODO: "local" RV</span> |
| 679 | <a name="l00981"></a>00981 } |
| 680 | <a name="l00982"></a>00982 <span class="keyword">virtual</span> <span class="keywordtype">void</span> logit (<a class="code" href="classbdm_1_1logger.html" title="Class for storing results (and semi-results) of an experiment.">logger</a> &L) { |
| 681 | <a name="l00983"></a>00983 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> (<a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a> (0), posterior().mean()); |
| 682 | <a name="l00984"></a>00984 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a> (1) || <a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a> (2)) { <span class="comment">//if one of them is off, its LID==-1 and will not be stored</span> |
| 683 | <a name="l00985"></a>00985 vec ub, lb; |
| 684 | <a name="l00986"></a>00986 posterior().<a class="code" href="classbdm_1_1epdf.html#0a7705e80601957f7226d333a0a6d539" title="Lower and upper bounds of percentage % quantile, returns mean-2*sigma as default...">qbounds</a> (lb, ub); |
| 685 | <a name="l00987"></a>00987 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> (<a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a> (1), lb); |
| 686 | <a name="l00988"></a>00988 L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> (<a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a> (2), ub); |
| 687 | <a name="l00989"></a>00989 } |
| 688 | <a name="l00990"></a>00990 <span class="keywordflow">if</span> (<a class="code" href="classbdm_1_1BM.html#398b7e7a162cf37d0022d6126495f207" title="Flags for logging - same size as LIDs, each entry correspond to the same in LIDs...">LFlags</a> (3)) L.<a class="code" href="classbdm_1_1logger.html#397c014b0aaf3581516e2a105d26a5c9" title="log this vector">logit</a> (<a class="code" href="classbdm_1_1BM.html#109c1a626a69031658e3a44e9e500cca" title="IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].">LIDs</a> (3), <a class="code" href="classbdm_1_1BM.html#4064b6559d962633e4372b12f4cd204a" title="Logarithm of marginalized data likelihood.">ll</a>); |
| 689 | <a name="l00991"></a>00991 } |
| 690 | <a name="l00993"></a>00993 }; |
| 691 | <a name="l00994"></a>00994 |
| 692 | <a name="l00995"></a>00995 <span class="keyword">typedef</span> Array<shared_ptr<epdf> > epdf_array; |
| 693 | <a name="l00996"></a>00996 |
| 694 | <a name="l00997"></a>00997 <span class="keyword">typedef</span> Array<shared_ptr<mpdf> > mpdf_array; |
| 695 | <a name="l00998"></a>00998 |
| 696 | <a name="l00999"></a>00999 <span class="keyword">template</span><<span class="keyword">class</span> EPDF> |
| 697 | <a name="l01000"></a><a class="code" href="classbdm_1_1mpdf__internal.html#d8e547695d1cc19219b91164d825c930">01000</a> vec <a class="code" href="classbdm_1_1mpdf__internal.html#d8e547695d1cc19219b91164d825c930" title="Reimplements samplecond using condition().">mpdf_internal<EPDF>::samplecond</a> (<span class="keyword">const</span> vec &cond) |
| 698 | <a name="l01001"></a>01001 { |
| 699 | <a name="l01002"></a>01002 <a class="code" href="classbdm_1_1mpdf__internal.html#1ac61da081667fc54bcd050cc4f6a93e">condition</a> (cond); |
| 700 | <a name="l01003"></a>01003 vec temp = <a class="code" href="classbdm_1_1mpdf__internal.html#47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.sample(); |
| 701 | <a name="l01004"></a>01004 <span class="keywordflow">return</span> temp; |
| 702 | <a name="l01005"></a>01005 } |
| 703 | <a name="l01006"></a>01006 |
| 704 | <a name="l01007"></a>01007 <span class="keyword">template</span><<span class="keyword">class</span> EPDF> |
| 705 | <a name="l01008"></a><a class="code" href="classbdm_1_1mpdf__internal.html#9554c554054da2d22cb8e908ae9c8823">01008</a> mat <a class="code" href="classbdm_1_1mpdf__internal.html#9554c554054da2d22cb8e908ae9c8823" title="Efficient version of samplecond.">mpdf_internal<EPDF>::samplecond_m</a> (<span class="keyword">const</span> vec &cond, <span class="keywordtype">int</span> N) |
| 706 | <a name="l01009"></a>01009 { |
| 707 | <a name="l01010"></a>01010 <a class="code" href="classbdm_1_1mpdf__internal.html#1ac61da081667fc54bcd050cc4f6a93e">condition</a> (cond); |
| 708 | <a name="l01011"></a>01011 mat temp (dimension(), N); |
| 709 | <a name="l01012"></a>01012 vec smp (dimension()); |
| 710 | <a name="l01013"></a>01013 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < N; i++) { |
| 711 | <a name="l01014"></a>01014 smp = <a class="code" href="classbdm_1_1mpdf__internal.html#47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.sample(); |
| 712 | <a name="l01015"></a>01015 temp.set_col (i, smp); |
| 713 | <a name="l01016"></a>01016 } |
| 714 | <a name="l01017"></a>01017 |
| 715 | <a name="l01018"></a>01018 <span class="keywordflow">return</span> temp; |
| 716 | <a name="l01019"></a>01019 } |
| 717 | <a name="l01020"></a>01020 |
| 718 | <a name="l01021"></a>01021 <span class="keyword">template</span><<span class="keyword">class</span> EPDF> |
| 719 | <a name="l01022"></a><a class="code" href="classbdm_1_1mpdf__internal.html#89076e62b8d7df7616bad68c94591948">01022</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mpdf__internal.html#89076e62b8d7df7616bad68c94591948" title="Reimplements evallogcond using condition().">mpdf_internal<EPDF>::evallogcond</a> (<span class="keyword">const</span> vec &dt, <span class="keyword">const</span> vec &cond) |
| 720 | <a name="l01023"></a>01023 { |
| 721 | <a name="l01024"></a>01024 <span class="keywordtype">double</span> tmp; |
| 722 | <a name="l01025"></a>01025 <a class="code" href="classbdm_1_1mpdf__internal.html#1ac61da081667fc54bcd050cc4f6a93e">condition</a> (cond); |
| 723 | <a name="l01026"></a>01026 tmp = <a class="code" href="classbdm_1_1mpdf__internal.html#47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.evallog (dt); |
| 724 | <a name="l01027"></a>01027 <span class="comment">// it_assert_debug(std::isfinite(tmp), "Infinite value");</span> |
| 725 | <a name="l01028"></a>01028 <span class="keywordflow">return</span> tmp; |
| 726 | <a name="l01029"></a>01029 } |
| 727 | <a name="l01030"></a>01030 |
| 728 | <a name="l01031"></a>01031 <span class="keyword">template</span><<span class="keyword">class</span> EPDF> |
| 729 | <a name="l01032"></a><a class="code" href="classbdm_1_1mpdf__internal.html#e28c214e3063733a6e4d17738941c61c">01032</a> vec <a class="code" href="classbdm_1_1mpdf__internal.html#e28c214e3063733a6e4d17738941c61c" title="Efficient version of evallogcond for matrices.">mpdf_internal<EPDF>::evallogcond_m</a> (<span class="keyword">const</span> mat &Dt, <span class="keyword">const</span> vec &cond) |
| 730 | <a name="l01033"></a>01033 { |
| 731 | <a name="l01034"></a>01034 <a class="code" href="classbdm_1_1mpdf__internal.html#1ac61da081667fc54bcd050cc4f6a93e">condition</a> (cond); |
| 732 | <a name="l01035"></a>01035 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1mpdf__internal.html#47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.evallog_m (Dt); |
| 733 | <a name="l01036"></a>01036 } |
| 734 | <a name="l01037"></a>01037 |
| 735 | <a name="l01038"></a>01038 <span class="keyword">template</span><<span class="keyword">class</span> EPDF> |
| 736 | <a name="l01039"></a><a class="code" href="classbdm_1_1mpdf__internal.html#e82db07ce8af02f29cfd81e014edb3db">01039</a> vec <a class="code" href="classbdm_1_1mpdf__internal.html#e28c214e3063733a6e4d17738941c61c" title="Efficient version of evallogcond for matrices.">mpdf_internal<EPDF>::evallogcond_m</a> (<span class="keyword">const</span> Array<vec> &Dt, <span class="keyword">const</span> vec &cond) |
| 737 | <a name="l01040"></a>01040 { |
| 738 | <a name="l01041"></a>01041 <a class="code" href="classbdm_1_1mpdf__internal.html#1ac61da081667fc54bcd050cc4f6a93e">condition</a> (cond); |
| 739 | <a name="l01042"></a>01042 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1mpdf__internal.html#47bab632af15120c88aad647ae129468" title="Internal epdf used for sampling.">iepdf</a>.evallog_m (Dt); |
| 740 | <a name="l01043"></a>01043 } |
| 741 | <a name="l01044"></a>01044 |
| 742 | <a name="l01045"></a>01045 }; <span class="comment">//namespace</span> |
| 743 | <a name="l01046"></a>01046 <span class="preprocessor">#endif // BDMBASE_H</span> |