28 | | <a name="l00024"></a>00024 ivec ids; |
29 | | <a name="l00025"></a>00025 ivec times; |
30 | | <a name="l00026"></a>00026 <a class="code" href="classstr.html" title="Structure of RV (used internally).">str</a>(ivec ids0, ivec times0):ids(ids0),times(times0){ |
31 | | <a name="l00027"></a>00027 it_assert_debug(times0.length()==ids0.length(),<span class="stringliteral">"Incompatible input"</span>); |
32 | | <a name="l00028"></a>00028 }; |
33 | | <a name="l00029"></a>00029 }; |
34 | | <a name="l00030"></a>00030 |
35 | | <a name="l00037"></a><a class="code" href="classRV.html">00037</a> <span class="keyword">class </span><a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> { |
36 | | <a name="l00038"></a>00038 <span class="keyword">protected</span>: |
37 | | <a name="l00040"></a><a class="code" href="classRV.html#f2396efe2e6d656ebe9e6f06018cbe25">00040</a> <span class="keywordtype">int</span> <a class="code" href="classRV.html#f2396efe2e6d656ebe9e6f06018cbe25" title="size = sum of sizes">tsize</a>; |
38 | | <a name="l00042"></a><a class="code" href="classRV.html#0d7b36e2bbccf880c8fcf1e8cc43c1a9">00042</a> <span class="keywordtype">int</span> <a class="code" href="classRV.html#0d7b36e2bbccf880c8fcf1e8cc43c1a9" title="len = number of individual rvs">len</a>; |
39 | | <a name="l00044"></a><a class="code" href="classRV.html#1bd7165140f4b880a7f344bbb1c433f9">00044</a> ivec <a class="code" href="classRV.html#1bd7165140f4b880a7f344bbb1c433f9" title="Vector of unique IDs.">ids</a>; |
40 | | <a name="l00046"></a><a class="code" href="classRV.html#c878aab13f34b420e1eb5b485563682b">00046</a> ivec <a class="code" href="classRV.html#c878aab13f34b420e1eb5b485563682b" title="Vector of sizes.">sizes</a>; |
41 | | <a name="l00048"></a><a class="code" href="classRV.html#646e530c47a2dd38254b778d9f11ac89">00048</a> ivec <a class="code" href="classRV.html#646e530c47a2dd38254b778d9f11ac89" title="Vector of shifts from current time.">times</a>; |
42 | | <a name="l00050"></a><a class="code" href="classRV.html#df5d0030b277a1db2f1fd5fb79152acb">00050</a> Array<std::string> <a class="code" href="classRV.html#df5d0030b277a1db2f1fd5fb79152acb" title="Array of names.">names</a>; |
43 | | <a name="l00051"></a>00051 |
44 | | <a name="l00052"></a>00052 <span class="keyword">private</span>: |
45 | | <a name="l00054"></a>00054 <span class="keywordtype">void</span> init (ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times ); |
46 | | <a name="l00055"></a>00055 <span class="keyword">public</span>: |
47 | | <a name="l00057"></a>00057 <a class="code" href="classRV.html#6a22f5c06d6403870d4e414b1993bf9e" title="Constructor of empty RV.">RV</a> ( Array<std::string> in_names, ivec in_sizes, ivec in_times ); |
48 | | <a name="l00059"></a>00059 <a class="code" href="classRV.html#6a22f5c06d6403870d4e414b1993bf9e" title="Constructor of empty RV.">RV</a> ( Array<std::string> in_names, ivec in_sizes ); |
49 | | <a name="l00061"></a>00061 <a class="code" href="classRV.html#6a22f5c06d6403870d4e414b1993bf9e" title="Constructor of empty RV.">RV</a> ( Array<std::string> in_names ); |
50 | | <a name="l00063"></a>00063 <a class="code" href="classRV.html#6a22f5c06d6403870d4e414b1993bf9e" title="Constructor of empty RV.">RV</a> (); |
51 | | <a name="l00064"></a>00064 |
52 | | <a name="l00066"></a>00066 <span class="keyword">friend</span> std::ostream &<a class="code" href="classRV.html#cad6f15535d10437f6690cb4492176a8" title="Printing output e.g. for debugging.">operator<< </a>( std::ostream &os, <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv ); |
| 28 | <a name="l00025"></a><a class="code" href="classstr.html#8c4e7241505999c272eb15e586ba7923">00025</a> ivec <a class="code" href="classstr.html#8c4e7241505999c272eb15e586ba7923" title="vector id ids (non-unique!)">ids</a>; |
| 29 | <a name="l00027"></a><a class="code" href="classstr.html#a55be419d33638dd0b2de3ecd64a4f27">00027</a> ivec <a class="code" href="classstr.html#a55be419d33638dd0b2de3ecd64a4f27" title="vector of times">times</a>; |
| 30 | <a name="l00029"></a><a class="code" href="classstr.html#11ba7967bca045fe27fab8e70b6c0598">00029</a> <a class="code" href="classstr.html#11ba7967bca045fe27fab8e70b6c0598" title="Default constructor.">str</a>(ivec ids0, ivec times0):<a class="code" href="classstr.html#8c4e7241505999c272eb15e586ba7923" title="vector id ids (non-unique!)">ids</a>(ids0),<a class="code" href="classstr.html#a55be419d33638dd0b2de3ecd64a4f27" title="vector of times">times</a>(times0){ |
| 31 | <a name="l00030"></a>00030 it_assert_debug(times0.length()==ids0.length(),<span class="stringliteral">"Incompatible input"</span>); |
| 32 | <a name="l00031"></a>00031 }; |
| 33 | <a name="l00032"></a>00032 }; |
| 34 | <a name="l00033"></a>00033 |
| 35 | <a name="l00040"></a><a class="code" href="classRV.html">00040</a> <span class="keyword">class </span><a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> { |
| 36 | <a name="l00041"></a>00041 <span class="keyword">protected</span>: |
| 37 | <a name="l00043"></a><a class="code" href="classRV.html#f2396efe2e6d656ebe9e6f06018cbe25">00043</a> <span class="keywordtype">int</span> <a class="code" href="classRV.html#f2396efe2e6d656ebe9e6f06018cbe25" title="size = sum of sizes">tsize</a>; |
| 38 | <a name="l00045"></a><a class="code" href="classRV.html#0d7b36e2bbccf880c8fcf1e8cc43c1a9">00045</a> <span class="keywordtype">int</span> <a class="code" href="classRV.html#0d7b36e2bbccf880c8fcf1e8cc43c1a9" title="len = number of individual rvs">len</a>; |
| 39 | <a name="l00047"></a><a class="code" href="classRV.html#1bd7165140f4b880a7f344bbb1c433f9">00047</a> ivec <a class="code" href="classRV.html#1bd7165140f4b880a7f344bbb1c433f9" title="Vector of unique IDs.">ids</a>; |
| 40 | <a name="l00049"></a><a class="code" href="classRV.html#c878aab13f34b420e1eb5b485563682b">00049</a> ivec <a class="code" href="classRV.html#c878aab13f34b420e1eb5b485563682b" title="Vector of sizes.">sizes</a>; |
| 41 | <a name="l00051"></a><a class="code" href="classRV.html#646e530c47a2dd38254b778d9f11ac89">00051</a> ivec <a class="code" href="classRV.html#646e530c47a2dd38254b778d9f11ac89" title="Vector of shifts from current time.">times</a>; |
| 42 | <a name="l00053"></a><a class="code" href="classRV.html#df5d0030b277a1db2f1fd5fb79152acb">00053</a> Array<std::string> <a class="code" href="classRV.html#df5d0030b277a1db2f1fd5fb79152acb" title="Array of names.">names</a>; |
| 43 | <a name="l00054"></a>00054 |
| 44 | <a name="l00055"></a>00055 <span class="keyword">private</span>: |
| 45 | <a name="l00057"></a>00057 <span class="keywordtype">void</span> init (ivec in_ids, Array<std::string> in_names, ivec in_sizes, ivec in_times ); |
| 46 | <a name="l00058"></a>00058 <span class="keyword">public</span>: |
| 47 | <a name="l00060"></a>00060 <a class="code" href="classRV.html#6a22f5c06d6403870d4e414b1993bf9e" title="Constructor of empty RV.">RV</a> ( Array<std::string> in_names, ivec in_sizes, ivec in_times ); |
| 48 | <a name="l00062"></a>00062 <a class="code" href="classRV.html#6a22f5c06d6403870d4e414b1993bf9e" title="Constructor of empty RV.">RV</a> ( Array<std::string> in_names, ivec in_sizes ); |
| 49 | <a name="l00064"></a>00064 <a class="code" href="classRV.html#6a22f5c06d6403870d4e414b1993bf9e" title="Constructor of empty RV.">RV</a> ( Array<std::string> in_names ); |
| 50 | <a name="l00066"></a>00066 <a class="code" href="classRV.html#6a22f5c06d6403870d4e414b1993bf9e" title="Constructor of empty RV.">RV</a> (); |
54 | | <a name="l00069"></a><a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0">00069</a> <span class="keywordtype">int</span> <a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classRV.html#f2396efe2e6d656ebe9e6f06018cbe25" title="size = sum of sizes">tsize</a>;} ; |
55 | | <a name="l00071"></a><a class="code" href="classRV.html#c114a6f3ff06796cc2f4dacba74291eb">00071</a> <span class="keywordtype">int</span> <a class="code" href="classRV.html#c114a6f3ff06796cc2f4dacba74291eb" title="Return length (number of entries) of the RV.">length</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classRV.html#0d7b36e2bbccf880c8fcf1e8cc43c1a9" title="len = number of individual rvs">len</a>;} ; |
56 | | <a name="l00072"></a>00072 |
57 | | <a name="l00073"></a>00073 <span class="comment">//TODO why not inline and later??</span> |
58 | | <a name="l00074"></a>00074 |
59 | | <a name="l00076"></a>00076 ivec <a class="code" href="classRV.html#0c493a7a897f4d75682f4264e40779a1" title="Find indexes of self in another rv,.">findself</a> (<span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv2 ) <span class="keyword">const</span>; |
60 | | <a name="l00078"></a>00078 <span class="keywordtype">bool</span> <a class="code" href="classRV.html#82cc7fa22ce91cf461a522ad62014c65" title="Compare if rv2 is identical to this RV.">equal</a> (<span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv2 ) <span class="keyword">const</span>; |
61 | | <a name="l00080"></a>00080 <span class="keywordtype">bool</span> <span class="keyword">add</span> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv2 ); |
62 | | <a name="l00082"></a>00082 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classRV.html#b9d175c327c21488b1e2fb756a84e149" title="Subtract another variable from the current one.">subt</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv2 ) <span class="keyword">const</span>; |
63 | | <a name="l00084"></a>00084 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classRV.html#b26d25a122be3303806af7726a625a0f" title="Select only variables at indeces ind.">subselect</a> ( <span class="keyword">const</span> ivec &ind ) <span class="keyword">const</span>; |
64 | | <a name="l00086"></a>00086 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classRV.html#248dfb2387976db2658489347669278c" title="Select only variables at indeces ind.">operator() </a>( <span class="keyword">const</span> ivec &ind ) <span class="keyword">const</span>; |
65 | | <a name="l00088"></a>00088 <span class="keywordtype">void</span> <a class="code" href="classRV.html#e0a158d53ab9430627241f844f4c9a60" title="Shift time shifted by delta.">t</a> ( <span class="keywordtype">int</span> delta ); |
66 | | <a name="l00090"></a>00090 <a class="code" href="classstr.html" title="Structure of RV (used internally).">str</a> <a class="code" href="classRV.html#52f3ade796814da627ff5a44d00986be" title="generate str from rv, by expanding sizes">tostr</a>() <span class="keyword">const</span>; |
67 | | <a name="l00092"></a>00092 ivec <a class="code" href="classRV.html#bb724fa4e2d9ed7bfd0993b5975018a4" title="generate indeces into">dataind</a>(<span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &crv) <span class="keyword">const</span>; |
68 | | <a name="l00093"></a>00093 |
69 | | <a name="l00095"></a><a class="code" href="classRV.html#b88ef5124713c9e30fd9446846b3f044">00095</a> Array<std::string>& <a class="code" href="classRV.html#b88ef5124713c9e30fd9446846b3f044" title="access function">_names</a>() {<span class="keywordflow">return</span> <a class="code" href="classRV.html#df5d0030b277a1db2f1fd5fb79152acb" title="Array of names.">names</a>;}; |
| 52 | <a name="l00069"></a>00069 <span class="keyword">friend</span> std::ostream &<a class="code" href="classRV.html#cad6f15535d10437f6690cb4492176a8" title="Printing output e.g. for debugging.">operator<< </a>( std::ostream &os, <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv ); |
| 53 | <a name="l00070"></a>00070 |
| 54 | <a name="l00072"></a><a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0">00072</a> <span class="keywordtype">int</span> <a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classRV.html#f2396efe2e6d656ebe9e6f06018cbe25" title="size = sum of sizes">tsize</a>;} ; |
| 55 | <a name="l00074"></a><a class="code" href="classRV.html#c114a6f3ff06796cc2f4dacba74291eb">00074</a> <span class="keywordtype">int</span> <a class="code" href="classRV.html#c114a6f3ff06796cc2f4dacba74291eb" title="Return length (number of entries) of the RV.">length</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classRV.html#0d7b36e2bbccf880c8fcf1e8cc43c1a9" title="len = number of individual rvs">len</a>;} ; |
| 56 | <a name="l00075"></a>00075 |
| 57 | <a name="l00076"></a>00076 <span class="comment">//TODO why not inline and later??</span> |
| 58 | <a name="l00077"></a>00077 |
| 59 | <a name="l00079"></a>00079 ivec <a class="code" href="classRV.html#0c493a7a897f4d75682f4264e40779a1" title="Find indexes of self in another rv,.">findself</a> (<span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv2 ) <span class="keyword">const</span>; |
| 60 | <a name="l00081"></a>00081 <span class="keywordtype">bool</span> <a class="code" href="classRV.html#82cc7fa22ce91cf461a522ad62014c65" title="Compare if rv2 is identical to this RV.">equal</a> (<span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv2 ) <span class="keyword">const</span>; |
| 61 | <a name="l00083"></a>00083 <span class="keywordtype">bool</span> <span class="keyword">add</span> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv2 ); |
| 62 | <a name="l00085"></a>00085 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classRV.html#b9d175c327c21488b1e2fb756a84e149" title="Subtract another variable from the current one.">subt</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv2 ) <span class="keyword">const</span>; |
| 63 | <a name="l00087"></a>00087 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classRV.html#b26d25a122be3303806af7726a625a0f" title="Select only variables at indeces ind.">subselect</a> ( <span class="keyword">const</span> ivec &ind ) <span class="keyword">const</span>; |
| 64 | <a name="l00089"></a>00089 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classRV.html#248dfb2387976db2658489347669278c" title="Select only variables at indeces ind.">operator() </a>( <span class="keyword">const</span> ivec &ind ) <span class="keyword">const</span>; |
| 65 | <a name="l00091"></a>00091 <span class="keywordtype">void</span> <a class="code" href="classRV.html#e0a158d53ab9430627241f844f4c9a60" title="Shift time shifted by delta.">t</a> ( <span class="keywordtype">int</span> delta ); |
| 66 | <a name="l00093"></a>00093 <a class="code" href="classstr.html" title="Structure of RV (used internally), i.e. expanded RVs.">str</a> <a class="code" href="classRV.html#52f3ade796814da627ff5a44d00986be" title="generate str from rv, by expanding sizes">tostr</a>() <span class="keyword">const</span>; |
| 67 | <a name="l00095"></a>00095 ivec <a class="code" href="classRV.html#bb724fa4e2d9ed7bfd0993b5975018a4" title="generate indeces into">dataind</a>(<span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &crv) <span class="keyword">const</span>; |
103 | | <a name="l00145"></a><a class="code" href="classepdf.html">00145</a> <span class="keyword">class </span><a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> { |
104 | | <a name="l00146"></a>00146 <span class="keyword">protected</span>: |
105 | | <a name="l00148"></a><a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9">00148</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>; |
106 | | <a name="l00149"></a>00149 <span class="keyword">public</span>: |
107 | | <a name="l00151"></a><a class="code" href="classepdf.html#d8eb760037b3bad5a0d64081606697cd">00151</a> <a class="code" href="classepdf.html#d8eb760037b3bad5a0d64081606697cd" title="default constructor">epdf</a>() :<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ( ) {}; |
108 | | <a name="l00152"></a>00152 |
109 | | <a name="l00154"></a><a class="code" href="classepdf.html#c95b1a27a8dd9507bb9a5a3cb2809c7a">00154</a> <a class="code" href="classepdf.html#d8eb760037b3bad5a0d64081606697cd" title="default constructor">epdf</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv0 ) :<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ( rv0 ) {}; |
110 | | <a name="l00155"></a>00155 |
111 | | <a name="l00156"></a>00156 <span class="comment">// //! Returns the required moment of the epdf</span> |
112 | | <a name="l00157"></a>00157 <span class="comment">// virtual vec moment ( const int order = 1 );</span> |
113 | | <a name="l00158"></a>00158 |
114 | | <a name="l00160"></a>00160 <span class="keyword">virtual</span> vec <a class="code" href="classepdf.html#8019654e494bf5e458f6fb947e11b262" title="Returns a sample, from density .">sample</a> () <span class="keyword">const</span> =0; |
115 | | <a name="l00162"></a>00162 <span class="keyword">virtual</span> mat <a class="code" href="classepdf.html#54d7dd53a641b618771cd9bee135181f" title="Returns N samples from density .">sampleN</a> ( <span class="keywordtype">int</span> N ) <span class="keyword">const</span>; |
116 | | <a name="l00164"></a><a class="code" href="classepdf.html#3ea597362e11a0040fe7c990269d072c">00164</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classepdf.html#3ea597362e11a0040fe7c990269d072c" title="Compute probability of argument val.">eval</a> ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{<span class="keywordflow">return</span> exp ( this-><a class="code" href="classepdf.html#6aef3eca74899692503769c18add1a4c" title="Compute log-probability of argument val.">evalpdflog</a> ( val ) );}; |
117 | | <a name="l00165"></a>00165 |
118 | | <a name="l00167"></a>00167 <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classepdf.html#6aef3eca74899692503769c18add1a4c" title="Compute log-probability of argument val.">evalpdflog</a> ( <span class="keyword">const</span> vec &val ) <span class="keyword">const</span> =0; |
119 | | <a name="l00168"></a>00168 |
120 | | <a name="l00170"></a><a class="code" href="classepdf.html#cebbdd7a85e6328f7358fc0ba8eee06c">00170</a> <span class="keyword">virtual</span> vec <a class="code" href="classepdf.html#cebbdd7a85e6328f7358fc0ba8eee06c" title="Compute log-probability of multiple values argument val.">evalpdflog_m</a> ( <span class="keyword">const</span> mat &Val )<span class="keyword"> const </span>{ |
121 | | <a name="l00171"></a>00171 vec x ( Val.cols() ); |
122 | | <a name="l00172"></a>00172 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<Val.cols();i++ ) {x ( i ) =<a class="code" href="classepdf.html#6aef3eca74899692503769c18add1a4c" title="Compute log-probability of argument val.">evalpdflog</a>( Val.get_col(i) ) ;} |
123 | | <a name="l00173"></a>00173 <span class="keywordflow">return</span> x; |
124 | | <a name="l00174"></a>00174 } |
125 | | <a name="l00175"></a>00175 |
126 | | <a name="l00177"></a>00177 <span class="keyword">virtual</span> vec <a class="code" href="classepdf.html#bf0a070a8f3e67a93604ca724638b870" title="return expected value">mean</a>() <span class="keyword">const</span> =0; |
127 | | <a name="l00178"></a>00178 |
128 | | <a name="l00180"></a><a class="code" href="classepdf.html#0a322dd106f04c0a2915e3d4f4227396">00180</a> <span class="keyword">virtual</span> <a class="code" href="classepdf.html#0a322dd106f04c0a2915e3d4f4227396" title="Destructor for future use;.">~epdf</a>() {}; |
129 | | <a name="l00182"></a><a class="code" href="classepdf.html#ca0d32aabb4cbba347e0c37fe8607562">00182</a> <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a>& <a class="code" href="classepdf.html#ca0d32aabb4cbba347e0c37fe8607562" title="access function, possibly dangerous!">_rv</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>;} |
130 | | <a name="l00184"></a><a class="code" href="classepdf.html#7fb94ce90d1ac7077d29f7d6a6c3e0a5">00184</a> <span class="keywordtype">void</span> <a class="code" href="classepdf.html#7fb94ce90d1ac7077d29f7d6a6c3e0a5" title="modifier function - useful when copying epdfs">_renewrv</a>(<span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &in_rv){<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>=in_rv;} |
131 | | <a name="l00185"></a>00185 }; |
| 101 | <a name="l00145"></a>00145 <span class="keyword">class </span><a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a>; |
| 102 | <a name="l00146"></a>00146 |
| 103 | <a name="l00148"></a>00148 |
| 104 | <a name="l00149"></a><a class="code" href="classepdf.html">00149</a> <span class="keyword">class </span><a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> { |
| 105 | <a name="l00150"></a>00150 <span class="keyword">protected</span>: |
| 106 | <a name="l00152"></a><a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9">00152</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>; |
| 107 | <a name="l00153"></a>00153 <span class="keyword">public</span>: |
| 108 | <a name="l00155"></a><a class="code" href="classepdf.html#d8eb760037b3bad5a0d64081606697cd">00155</a> <a class="code" href="classepdf.html#d8eb760037b3bad5a0d64081606697cd" title="default constructor">epdf</a>() :<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ( ) {}; |
| 109 | <a name="l00156"></a>00156 |
| 110 | <a name="l00158"></a><a class="code" href="classepdf.html#c95b1a27a8dd9507bb9a5a3cb2809c7a">00158</a> <a class="code" href="classepdf.html#d8eb760037b3bad5a0d64081606697cd" title="default constructor">epdf</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv0 ) :<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ( rv0 ) {}; |
| 111 | <a name="l00159"></a>00159 |
| 112 | <a name="l00160"></a>00160 <span class="comment">// //! Returns the required moment of the epdf</span> |
| 113 | <a name="l00161"></a>00161 <span class="comment">// virtual vec moment ( const int order = 1 );</span> |
| 114 | <a name="l00162"></a>00162 |
| 115 | <a name="l00164"></a>00164 <span class="keyword">virtual</span> vec <a class="code" href="classepdf.html#8019654e494bf5e458f6fb947e11b262" title="Returns a sample, from density .">sample</a> () <span class="keyword">const</span> =0; |
| 116 | <a name="l00166"></a>00166 <span class="keyword">virtual</span> mat <a class="code" href="classepdf.html#54d7dd53a641b618771cd9bee135181f" title="Returns N samples from density .">sampleN</a> ( <span class="keywordtype">int</span> N ) <span class="keyword">const</span>; |
| 117 | <a name="l00168"></a><a class="code" href="classepdf.html#3ea597362e11a0040fe7c990269d072c">00168</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classepdf.html#3ea597362e11a0040fe7c990269d072c" title="Compute probability of argument val.">eval</a> ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{<span class="keywordflow">return</span> exp ( this-><a class="code" href="classepdf.html#6aef3eca74899692503769c18add1a4c" title="Compute log-probability of argument val.">evalpdflog</a> ( val ) );}; |
| 118 | <a name="l00169"></a>00169 |
| 119 | <a name="l00171"></a>00171 <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classepdf.html#6aef3eca74899692503769c18add1a4c" title="Compute log-probability of argument val.">evalpdflog</a> ( <span class="keyword">const</span> vec &val ) <span class="keyword">const</span> =0; |
| 120 | <a name="l00172"></a>00172 |
| 121 | <a name="l00174"></a><a class="code" href="classepdf.html#cebbdd7a85e6328f7358fc0ba8eee06c">00174</a> <span class="keyword">virtual</span> vec <a class="code" href="classepdf.html#cebbdd7a85e6328f7358fc0ba8eee06c" title="Compute log-probability of multiple values argument val.">evalpdflog_m</a> ( <span class="keyword">const</span> mat &Val )<span class="keyword"> const </span>{ |
| 122 | <a name="l00175"></a>00175 vec x ( Val.cols() ); |
| 123 | <a name="l00176"></a>00176 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<Val.cols();i++ ) {x ( i ) =<a class="code" href="classepdf.html#6aef3eca74899692503769c18add1a4c" title="Compute log-probability of argument val.">evalpdflog</a>( Val.get_col(i) ) ;} |
| 124 | <a name="l00177"></a>00177 <span class="keywordflow">return</span> x; |
| 125 | <a name="l00178"></a>00178 } |
| 126 | <a name="l00180"></a><a class="code" href="classepdf.html#3ba08c0e788deff22134c049b9269666">00180</a> <a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a>* <a class="code" href="classepdf.html#3ba08c0e788deff22134c049b9269666" 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="classRV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>){it_warning(<span class="stringliteral">"Not implemented"</span>); <span class="keywordflow">return</span> NULL;} |
| 127 | <a name="l00182"></a><a class="code" href="classepdf.html#bc0c171b6dafacd78d26263913b1d0c0">00182</a> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* <a class="code" href="classepdf.html#bc0c171b6dafacd78d26263913b1d0c0" 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="classRV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>){it_warning(<span class="stringliteral">"Not implemented"</span>); <span class="keywordflow">return</span> NULL;} |
| 128 | <a name="l00183"></a>00183 |
| 129 | <a name="l00185"></a>00185 <span class="keyword">virtual</span> vec <a class="code" href="classepdf.html#bf0a070a8f3e67a93604ca724638b870" title="return expected value">mean</a>() <span class="keyword">const</span> =0; |
133 | | <a name="l00187"></a>00187 |
134 | | <a name="l00189"></a>00189 <span class="comment">//TODO Samplecond can be generalized</span> |
135 | | <a name="l00190"></a>00190 |
136 | | <a name="l00191"></a><a class="code" href="classmpdf.html">00191</a> <span class="keyword">class </span><a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> { |
137 | | <a name="l00192"></a>00192 <span class="keyword">protected</span>: |
138 | | <a name="l00194"></a><a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb">00194</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>; |
139 | | <a name="l00196"></a><a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab">00196</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab" title="random variable in condition">rvc</a>; |
140 | | <a name="l00198"></a><a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c">00198</a> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* <a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a>; |
141 | | <a name="l00199"></a>00199 <span class="keyword">public</span>: |
142 | | <a name="l00200"></a>00200 |
143 | | <a name="l00202"></a>00202 <span class="comment">// virtual fnc moment ( const int order = 1 );</span> |
144 | | <a name="l00204"></a><a class="code" href="classmpdf.html#3f172b79ec4a5ebc87898a5381141f1b">00204</a> <span class="comment"></span> <span class="keyword">virtual</span> vec <a class="code" href="classmpdf.html#3f172b79ec4a5ebc87898a5381141f1b" title="Returns the required moment of the epdf.">samplecond</a> (<span class="keyword">const</span> vec &cond, <span class="keywordtype">double</span> &ll ) {this-><a class="code" href="classmpdf.html#0f95a0cc6ab40611f46804682446ed83" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a> ( cond ); |
145 | | <a name="l00205"></a>00205 vec temp= <a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a>-><a class="code" href="classepdf.html#8019654e494bf5e458f6fb947e11b262" title="Returns a sample, from density .">sample</a>(); |
146 | | <a name="l00206"></a>00206 ll=<a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a>-><a class="code" href="classepdf.html#6aef3eca74899692503769c18add1a4c" title="Compute log-probability of argument val.">evalpdflog</a> ( temp );<span class="keywordflow">return</span> temp;}; |
147 | | <a name="l00208"></a><a class="code" href="classmpdf.html#0e37163660f93df2a4d723cedb1da89c">00208</a> <span class="keyword">virtual</span> mat <a class="code" href="classmpdf.html#3f172b79ec4a5ebc87898a5381141f1b" title="Returns the required moment of the epdf.">samplecond</a> (<span class="keyword">const</span> vec &cond, vec &ll, <span class="keywordtype">int</span> N ) { |
148 | | <a name="l00209"></a>00209 this-><a class="code" href="classmpdf.html#0f95a0cc6ab40611f46804682446ed83" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a> ( cond ); |
149 | | <a name="l00210"></a>00210 mat temp ( <a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>(),N ); vec smp ( <a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>() ); |
150 | | <a name="l00211"></a>00211 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<N;i++ ) {smp=<a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a>-><a class="code" href="classepdf.html#8019654e494bf5e458f6fb947e11b262" title="Returns a sample, from density .">sample</a>() ;temp.set_col ( i, smp );ll ( i ) =<a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a>-><a class="code" href="classepdf.html#6aef3eca74899692503769c18add1a4c" title="Compute log-probability of argument val.">evalpdflog</a> ( smp );} |
151 | | <a name="l00212"></a>00212 <span class="keywordflow">return</span> temp; |
152 | | <a name="l00213"></a>00213 }; |
153 | | <a name="l00215"></a><a class="code" href="classmpdf.html#0f95a0cc6ab40611f46804682446ed83">00215</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmpdf.html#0f95a0cc6ab40611f46804682446ed83" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a> ( <span class="keyword">const</span> vec &cond ) {}; |
154 | | <a name="l00216"></a>00216 |
155 | | <a name="l00218"></a><a class="code" href="classmpdf.html#80b738ece5bd4f8c4edaee4b38906f91">00218</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classmpdf.html#80b738ece5bd4f8c4edaee4b38906f91" title="Shortcut for conditioning and evaluation of the internal epdf. In some cases, this...">evalcond</a> ( <span class="keyword">const</span> vec &dt, <span class="keyword">const</span> vec &cond ) {this-><a class="code" href="classmpdf.html#0f95a0cc6ab40611f46804682446ed83" 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="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a>-><a class="code" href="classepdf.html#3ea597362e11a0040fe7c990269d072c" title="Compute probability of argument val.">eval</a> ( dt );}; |
156 | | <a name="l00219"></a>00219 |
157 | | <a name="l00221"></a><a class="code" href="classmpdf.html#6788be9f3a888796499c5293a318fcfb">00221</a> <span class="keyword">virtual</span> <a class="code" href="classmpdf.html#6788be9f3a888796499c5293a318fcfb" title="Destructor for future use;.">~mpdf</a>() {}; |
158 | | <a name="l00222"></a>00222 |
159 | | <a name="l00224"></a><a class="code" href="classmpdf.html#581ecf362185d37c08bb31cb9d046d6f">00224</a> <a class="code" href="classmpdf.html#581ecf362185d37c08bb31cb9d046d6f" title="Default constructor.">mpdf</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv0, <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rvc0 ) :<a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a> ( rv0 ),<a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab" title="random variable in condition">rvc</a> ( rvc0 ) {}; |
160 | | <a name="l00226"></a><a class="code" href="classmpdf.html#ec9c850305984582548e8deb64f0ffe8">00226</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classmpdf.html#ec9c850305984582548e8deb64f0ffe8" title="access function">_rvc</a>() {<span class="keywordflow">return</span> <a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab" title="random variable in condition">rvc</a>;} |
161 | | <a name="l00228"></a><a class="code" href="classmpdf.html#1e71ad4c66d5884c82d4a3b06b42fe32">00228</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classmpdf.html#1e71ad4c66d5884c82d4a3b06b42fe32" title="access function">_rv</a>() {<span class="keywordflow">return</span> <a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>;} |
162 | | <a name="l00230"></a><a class="code" href="classmpdf.html#e17780ee5b2cfe05922a6c56af1462f8">00230</a> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>& <a class="code" href="classmpdf.html#e17780ee5b2cfe05922a6c56af1462f8" title="access function">_epdf</a>() {<span class="keywordflow">return</span> *<a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a>;} |
163 | | <a name="l00231"></a>00231 }; |
164 | | <a name="l00232"></a>00232 |
165 | | <a name="l00237"></a><a class="code" href="classmepdf.html">00237</a> <span class="keyword">class </span><a class="code" href="classmepdf.html" title="Unconditional mpdf, allows using epdf in the role of mpdf.">mepdf</a> : <span class="keyword">public</span> <a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> { |
166 | | <a name="l00238"></a>00238 <span class="keyword">public</span>: |
167 | | <a name="l00240"></a><a class="code" href="classmepdf.html#7ab1c50f0aa16230117436dee500f2e0">00240</a> <a class="code" href="classmepdf.html#7ab1c50f0aa16230117436dee500f2e0" title="Default constructor.">mepdf</a> (<a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> &em ) :<a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> ( em.<a class="code" href="classmpdf.html#1e71ad4c66d5884c82d4a3b06b42fe32" title="access function">_rv</a>(),<a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a>() ) {<a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a>=&em;}; |
168 | | <a name="l00241"></a>00241 }; |
169 | | <a name="l00242"></a>00242 |
170 | | <a name="l00244"></a><a class="code" href="classcompositepdf.html">00244</a> <span class="keyword">class </span><a class="code" href="classcompositepdf.html" title="Abstract composition of pdfs, a base for specific classes.">compositepdf</a>{ |
171 | | <a name="l00245"></a>00245 <span class="keyword">protected</span>: |
172 | | <a name="l00247"></a><a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f">00247</a> <span class="keywordtype">int</span> <a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a>; |
173 | | <a name="l00249"></a><a class="code" href="classcompositepdf.html#637877061b917a16a0421bb5c4cd480d">00249</a> Array<mpdf*> <a class="code" href="classcompositepdf.html#637877061b917a16a0421bb5c4cd480d" title="Elements of composition.">mpdfs</a>; |
174 | | <a name="l00251"></a><a class="code" href="classcompositepdf.html#4d4a8269f9faefeca8cdc251a5a29a7f">00251</a> Array<ivec> <a class="code" href="classcompositepdf.html#4d4a8269f9faefeca8cdc251a5a29a7f" title="Indeces of rvs in common rv.">rvsinrv</a>; |
175 | | <a name="l00253"></a><a class="code" href="classcompositepdf.html#3df07bb5e3ed36a3119b145043296676">00253</a> Array<ivec> <a class="code" href="classcompositepdf.html#3df07bb5e3ed36a3119b145043296676" title="Indeces of rvc in common rv.">rvcsinrv</a>; |
176 | | <a name="l00254"></a>00254 <span class="keyword">public</span>: |
177 | | <a name="l00255"></a>00255 <a class="code" href="classcompositepdf.html" title="Abstract composition of pdfs, a base for specific classes.">compositepdf</a>(Array<mpdf*> A0): <a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a>(A0.length()), <a class="code" href="classcompositepdf.html#637877061b917a16a0421bb5c4cd480d" title="Elements of composition.">mpdfs</a>(A0), <a class="code" href="classcompositepdf.html#4d4a8269f9faefeca8cdc251a5a29a7f" title="Indeces of rvs in common rv.">rvsinrv</a>(<a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a>), <a class="code" href="classcompositepdf.html#3df07bb5e3ed36a3119b145043296676" title="Indeces of rvc in common rv.">rvcsinrv</a>(<a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a>){}; |
178 | | <a name="l00256"></a>00256 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> getrv(<span class="keywordtype">bool</span> checkoverlap=<span class="keyword">false</span>); |
179 | | <a name="l00257"></a>00257 <span class="keywordtype">void</span> setrvc(<span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rvc); |
180 | | <a name="l00258"></a>00258 <span class="keywordtype">void</span> setindices(<span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv); |
181 | | <a name="l00259"></a>00259 <span class="keywordtype">void</span> setrvcinrv(<span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rvc, Array<ivec> &rvcind); |
182 | | <a name="l00260"></a>00260 }; |
183 | | <a name="l00261"></a>00261 |
184 | | <a name="l00269"></a><a class="code" href="classDS.html">00269</a> <span class="keyword">class </span><a class="code" href="classDS.html" title="Abstract class for discrete-time sources of data.">DS</a> { |
185 | | <a name="l00270"></a>00270 <span class="keyword">protected</span>: |
186 | | <a name="l00272"></a><a class="code" href="classDS.html#1012025a1a3a1fdd24aa48698a3d3454">00272</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classDS.html#1012025a1a3a1fdd24aa48698a3d3454" title="Observed variables, returned by getdata().">Drv</a>; |
187 | | <a name="l00274"></a><a class="code" href="classDS.html#0a88ffaeb3c7c2cf30c69bc41a000629">00274</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classDS.html#0a88ffaeb3c7c2cf30c69bc41a000629" title="Action variables, accepted by write().">Urv</a>; <span class="comment">//</span> |
188 | | <a name="l00275"></a>00275 <span class="keyword">public</span>: |
189 | | <a name="l00277"></a>00277 <span class="keywordtype">void</span> <a class="code" href="classDS.html#db2dacc9e71a36eeb9c5c2ee402eeeb1" title="Returns full vector of observed data.">getdata</a> ( vec &dt ); |
190 | | <a name="l00279"></a>00279 <span class="keywordtype">void</span> <a class="code" href="classDS.html#db2dacc9e71a36eeb9c5c2ee402eeeb1" title="Returns full vector of observed data.">getdata</a> ( vec &dt, ivec &indeces ); |
191 | | <a name="l00281"></a>00281 <span class="keywordtype">void</span> <a class="code" href="classDS.html#0dfb6788b70c0d48a1f5276ed6c93039" title="Accepts action variable and schedule it for application.">write</a> ( vec &ut ); |
192 | | <a name="l00283"></a>00283 <span class="keywordtype">void</span> <a class="code" href="classDS.html#0dfb6788b70c0d48a1f5276ed6c93039" title="Accepts action variable and schedule it for application.">write</a> ( vec &ut, ivec &indeces ); |
193 | | <a name="l00289"></a>00289 <span class="keywordtype">void</span> <a class="code" href="classDS.html#9a35ca9c9321dce2bf63bf668f785b75" title="Method that assigns random variables to the datasource. Typically, the datasource...">linkrvs</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &drv, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &urv ); |
194 | | <a name="l00290"></a>00290 |
195 | | <a name="l00292"></a>00292 <span class="keywordtype">void</span> <a class="code" href="classDS.html#470ba89e8e7c3c4d830803221b4e9be6" title="Moves from to , i.e. perfroms the actions and reads response of the system.">step</a>(); |
196 | | <a name="l00293"></a>00293 |
197 | | <a name="l00294"></a>00294 }; |
198 | | <a name="l00295"></a>00295 |
199 | | <a name="l00300"></a><a class="code" href="classBM.html">00300</a> <span class="keyword">class </span><a class="code" href="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a> { |
200 | | <a name="l00301"></a>00301 <span class="keyword">protected</span>: |
201 | | <a name="l00303"></a><a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88">00303</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a>; |
202 | | <a name="l00305"></a><a class="code" href="classBM.html#5623fef6572a08c2b53b8c87b82dc979">00305</a> <span class="keywordtype">double</span> <a class="code" href="classBM.html#5623fef6572a08c2b53b8c87b82dc979" title="Logarithm of marginalized data likelihood.">ll</a>; |
203 | | <a name="l00307"></a><a class="code" href="classBM.html#bf6fb59b30141074f8ee1e2f43d03129">00307</a> <span class="keywordtype">bool</span> <a class="code" href="classBM.html#bf6fb59b30141074f8ee1e2f43d03129" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>; |
204 | | <a name="l00308"></a>00308 <span class="keyword">public</span>: |
205 | | <a name="l00309"></a>00309 |
206 | | <a name="l00311"></a><a class="code" href="classBM.html#43d2ad6a6c9f1bcd22fe8906c477e50e">00311</a> <a class="code" href="classBM.html#43d2ad6a6c9f1bcd22fe8906c477e50e" title="Default constructor.">BM</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv0, <span class="keywordtype">double</span> ll0=0,<span class="keywordtype">bool</span> evalll0=<span class="keyword">true</span> ) :<a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a> ( rv0 ), <a class="code" href="classBM.html#5623fef6572a08c2b53b8c87b82dc979" title="Logarithm of marginalized data likelihood.">ll</a> ( ll0 ),<a class="code" href="classBM.html#bf6fb59b30141074f8ee1e2f43d03129" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a> ( evalll0) {<span class="comment">//Fixme: test rv</span> |
207 | | <a name="l00312"></a>00312 }; |
208 | | <a name="l00314"></a><a class="code" href="classBM.html#e8fc5fae042f2b46d4d3827f9587d47d">00314</a> <a class="code" href="classBM.html#43d2ad6a6c9f1bcd22fe8906c477e50e" title="Default constructor.">BM</a> (<span class="keyword">const</span> <a class="code" href="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a> &B) : <a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a>(B.<a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a>), <a class="code" href="classBM.html#5623fef6572a08c2b53b8c87b82dc979" title="Logarithm of marginalized data likelihood.">ll</a>(B.<a class="code" href="classBM.html#5623fef6572a08c2b53b8c87b82dc979" title="Logarithm of marginalized data likelihood.">ll</a>), <a class="code" href="classBM.html#bf6fb59b30141074f8ee1e2f43d03129" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>(B.<a class="code" href="classBM.html#bf6fb59b30141074f8ee1e2f43d03129" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>) {} |
209 | | <a name="l00315"></a>00315 |
210 | | <a name="l00319"></a>00319 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classBM.html#a892eff438aab2dd1a9e2efcb7fb5bdf" title="Incremental Bayes rule.">bayes</a> ( <span class="keyword">const</span> vec &dt ) = 0; |
211 | | <a name="l00321"></a>00321 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classBM.html#0186270f75189677f390fe088a9947e9" title="Batch Bayes rule (columns of Dt are observations).">bayesB</a> (<span class="keyword">const</span> mat &Dt ); |
212 | | <a name="l00323"></a>00323 <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>& <a class="code" href="classBM.html#8554809fec160bee279bcd5fa14ead5c" title="Returns a pointer to the epdf representing posterior density on parameters. Use with...">_epdf</a>() <span class="keyword">const</span> =0; |
| 131 | <a name="l00188"></a><a class="code" href="classepdf.html#0a322dd106f04c0a2915e3d4f4227396">00188</a> <span class="keyword">virtual</span> <a class="code" href="classepdf.html#0a322dd106f04c0a2915e3d4f4227396" title="Destructor for future use;.">~epdf</a>() {}; |
| 132 | <a name="l00190"></a><a class="code" href="classepdf.html#ca0d32aabb4cbba347e0c37fe8607562">00190</a> <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a>& <a class="code" href="classepdf.html#ca0d32aabb4cbba347e0c37fe8607562" title="access function, possibly dangerous!">_rv</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>;} |
| 133 | <a name="l00192"></a><a class="code" href="classepdf.html#7fb94ce90d1ac7077d29f7d6a6c3e0a5">00192</a> <span class="keywordtype">void</span> <a class="code" href="classepdf.html#7fb94ce90d1ac7077d29f7d6a6c3e0a5" title="modifier function - useful when copying epdfs">_renewrv</a>(<span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &in_rv){<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>=in_rv;} |
| 134 | <a name="l00194"></a>00194 }; |
| 135 | <a name="l00195"></a>00195 |
| 136 | <a name="l00196"></a>00196 |
| 137 | <a name="l00198"></a>00198 <span class="comment">//TODO Samplecond can be generalized</span> |
| 138 | <a name="l00199"></a>00199 |
| 139 | <a name="l00200"></a><a class="code" href="classmpdf.html">00200</a> <span class="keyword">class </span><a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> { |
| 140 | <a name="l00201"></a>00201 <span class="keyword">protected</span>: |
| 141 | <a name="l00203"></a><a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb">00203</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>; |
| 142 | <a name="l00205"></a><a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab">00205</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab" title="random variable in condition">rvc</a>; |
| 143 | <a name="l00207"></a><a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c">00207</a> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* <a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a>; |
| 144 | <a name="l00208"></a>00208 <span class="keyword">public</span>: |
| 145 | <a name="l00209"></a>00209 |
| 146 | <a name="l00211"></a>00211 <span class="comment">// virtual fnc moment ( const int order = 1 );</span> |
| 147 | <a name="l00213"></a><a class="code" href="classmpdf.html#3f172b79ec4a5ebc87898a5381141f1b">00213</a> <span class="comment"></span> <span class="keyword">virtual</span> vec <a class="code" href="classmpdf.html#3f172b79ec4a5ebc87898a5381141f1b" title="Returns the required moment of the epdf.">samplecond</a> (<span class="keyword">const</span> vec &cond, <span class="keywordtype">double</span> &ll ) {this-><a class="code" href="classmpdf.html#0f95a0cc6ab40611f46804682446ed83" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a> ( cond ); |
| 148 | <a name="l00214"></a>00214 vec temp= <a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a>-><a class="code" href="classepdf.html#8019654e494bf5e458f6fb947e11b262" title="Returns a sample, from density .">sample</a>(); |
| 149 | <a name="l00215"></a>00215 ll=<a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a>-><a class="code" href="classepdf.html#6aef3eca74899692503769c18add1a4c" title="Compute log-probability of argument val.">evalpdflog</a> ( temp );<span class="keywordflow">return</span> temp;}; |
| 150 | <a name="l00217"></a><a class="code" href="classmpdf.html#0e37163660f93df2a4d723cedb1da89c">00217</a> <span class="keyword">virtual</span> mat <a class="code" href="classmpdf.html#3f172b79ec4a5ebc87898a5381141f1b" title="Returns the required moment of the epdf.">samplecond</a> (<span class="keyword">const</span> vec &cond, vec &ll, <span class="keywordtype">int</span> N ) { |
| 151 | <a name="l00218"></a>00218 this-><a class="code" href="classmpdf.html#0f95a0cc6ab40611f46804682446ed83" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a> ( cond ); |
| 152 | <a name="l00219"></a>00219 mat temp ( <a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>(),N ); vec smp ( <a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>() ); |
| 153 | <a name="l00220"></a>00220 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<N;i++ ) {smp=<a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a>-><a class="code" href="classepdf.html#8019654e494bf5e458f6fb947e11b262" title="Returns a sample, from density .">sample</a>() ;temp.set_col ( i, smp );ll ( i ) =<a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a>-><a class="code" href="classepdf.html#6aef3eca74899692503769c18add1a4c" title="Compute log-probability of argument val.">evalpdflog</a> ( smp );} |
| 154 | <a name="l00221"></a>00221 <span class="keywordflow">return</span> temp; |
| 155 | <a name="l00222"></a>00222 }; |
| 156 | <a name="l00224"></a><a class="code" href="classmpdf.html#0f95a0cc6ab40611f46804682446ed83">00224</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmpdf.html#0f95a0cc6ab40611f46804682446ed83" 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>);}; |
| 157 | <a name="l00225"></a>00225 |
| 158 | <a name="l00227"></a><a class="code" href="classmpdf.html#80b738ece5bd4f8c4edaee4b38906f91">00227</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classmpdf.html#80b738ece5bd4f8c4edaee4b38906f91" title="Shortcut for conditioning and evaluation of the internal epdf. In some cases, this...">evalcond</a> ( <span class="keyword">const</span> vec &dt, <span class="keyword">const</span> vec &cond ) {this-><a class="code" href="classmpdf.html#0f95a0cc6ab40611f46804682446ed83" 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="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a>-><a class="code" href="classepdf.html#3ea597362e11a0040fe7c990269d072c" title="Compute probability of argument val.">eval</a> ( dt );}; |
| 159 | <a name="l00228"></a>00228 |
| 160 | <a name="l00230"></a><a class="code" href="classmpdf.html#6788be9f3a888796499c5293a318fcfb">00230</a> <span class="keyword">virtual</span> <a class="code" href="classmpdf.html#6788be9f3a888796499c5293a318fcfb" title="Destructor for future use;.">~mpdf</a>() {}; |
| 161 | <a name="l00231"></a>00231 |
| 162 | <a name="l00233"></a><a class="code" href="classmpdf.html#581ecf362185d37c08bb31cb9d046d6f">00233</a> <a class="code" href="classmpdf.html#581ecf362185d37c08bb31cb9d046d6f" title="Default constructor.">mpdf</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv0, <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rvc0 ) :<a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a> ( rv0 ),<a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab" title="random variable in condition">rvc</a> ( rvc0 ) {}; |
| 163 | <a name="l00235"></a><a class="code" href="classmpdf.html#ec9c850305984582548e8deb64f0ffe8">00235</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classmpdf.html#ec9c850305984582548e8deb64f0ffe8" title="access function">_rvc</a>() {<span class="keywordflow">return</span> <a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab" title="random variable in condition">rvc</a>;} |
| 164 | <a name="l00237"></a><a class="code" href="classmpdf.html#1e71ad4c66d5884c82d4a3b06b42fe32">00237</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classmpdf.html#1e71ad4c66d5884c82d4a3b06b42fe32" title="access function">_rv</a>() {<span class="keywordflow">return</span> <a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>;} |
| 165 | <a name="l00239"></a><a class="code" href="classmpdf.html#e17780ee5b2cfe05922a6c56af1462f8">00239</a> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>& <a class="code" href="classmpdf.html#e17780ee5b2cfe05922a6c56af1462f8" title="access function">_epdf</a>() {<span class="keywordflow">return</span> *<a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a>;} |
| 166 | <a name="l00240"></a>00240 }; |
| 167 | <a name="l00241"></a>00241 |
| 168 | <a name="l00246"></a><a class="code" href="classmepdf.html">00246</a> <span class="keyword">class </span><a class="code" href="classmepdf.html" title="Unconditional mpdf, allows using epdf in the role of mpdf.">mepdf</a> : <span class="keyword">public</span> <a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> { |
| 169 | <a name="l00247"></a>00247 <span class="keyword">public</span>: |
| 170 | <a name="l00249"></a><a class="code" href="classmepdf.html#7ab1c50f0aa16230117436dee500f2e0">00249</a> <a class="code" href="classmepdf.html#7ab1c50f0aa16230117436dee500f2e0" title="Default constructor.">mepdf</a> (<a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> &em ) :<a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> ( em.<a class="code" href="classmpdf.html#1e71ad4c66d5884c82d4a3b06b42fe32" title="access function">_rv</a>(),<a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a>() ) {<a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a>=&em;}; |
| 171 | <a name="l00250"></a>00250 }; |
| 172 | <a name="l00251"></a>00251 |
| 173 | <a name="l00253"></a><a class="code" href="classcompositepdf.html">00253</a> <span class="keyword">class </span><a class="code" href="classcompositepdf.html" title="Abstract composition of pdfs, a base for specific classes.">compositepdf</a>{ |
| 174 | <a name="l00254"></a>00254 <span class="keyword">protected</span>: |
| 175 | <a name="l00256"></a><a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f">00256</a> <span class="keywordtype">int</span> <a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a>; |
| 176 | <a name="l00258"></a><a class="code" href="classcompositepdf.html#637877061b917a16a0421bb5c4cd480d">00258</a> Array<mpdf*> <a class="code" href="classcompositepdf.html#637877061b917a16a0421bb5c4cd480d" title="Elements of composition.">mpdfs</a>; |
| 177 | <a name="l00260"></a><a class="code" href="classcompositepdf.html#4d4a8269f9faefeca8cdc251a5a29a7f">00260</a> Array<ivec> <a class="code" href="classcompositepdf.html#4d4a8269f9faefeca8cdc251a5a29a7f" title="Indeces of rvs in common rv.">rvsinrv</a>; |
| 178 | <a name="l00262"></a><a class="code" href="classcompositepdf.html#3df07bb5e3ed36a3119b145043296676">00262</a> Array<ivec> <a class="code" href="classcompositepdf.html#3df07bb5e3ed36a3119b145043296676" title="Indeces of rvc in common rv.">rvcsinrv</a>; |
| 179 | <a name="l00264"></a><a class="code" href="classcompositepdf.html#de3bd289a26d5549dcf1ed19e5b13569">00264</a> Array<ivec> <a class="code" href="classcompositepdf.html#de3bd289a26d5549dcf1ed19e5b13569" title="Indeces of common rv in rvc.">rvinrvcs</a>; |
| 180 | <a name="l00265"></a>00265 <span class="keyword">public</span>: |
| 181 | <a name="l00266"></a>00266 <a class="code" href="classcompositepdf.html" title="Abstract composition of pdfs, a base for specific classes.">compositepdf</a>(Array<mpdf*> A0): <a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a>(A0.length()), <a class="code" href="classcompositepdf.html#637877061b917a16a0421bb5c4cd480d" title="Elements of composition.">mpdfs</a>(A0), <a class="code" href="classcompositepdf.html#4d4a8269f9faefeca8cdc251a5a29a7f" title="Indeces of rvs in common rv.">rvsinrv</a>(<a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a>), <a class="code" href="classcompositepdf.html#3df07bb5e3ed36a3119b145043296676" title="Indeces of rvc in common rv.">rvcsinrv</a>(<a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a>),<a class="code" href="classcompositepdf.html#de3bd289a26d5549dcf1ed19e5b13569" title="Indeces of common rv in rvc.">rvinrvcs</a>(<a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a>){}; |
| 182 | <a name="l00268"></a>00268 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classcompositepdf.html#635d219fb3e32852400d6f98aa4bdc93" title="find common rv, flag">getrv</a>(<span class="keywordtype">bool</span> checkoverlap=<span class="keyword">false</span>); |
| 183 | <a name="l00270"></a>00270 <span class="keywordtype">void</span> <a class="code" href="classcompositepdf.html#5a4479785c1fdb2cc351fbea07b899ac" title="common rvc of all mpdfs is written to rvc">setrvc</a>(<span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rvc); |
| 184 | <a name="l00272"></a>00272 <span class="keywordtype">void</span> <a class="code" href="classcompositepdf.html#08958c8f76d65de94ecc37b8d90bc77a" title="fill all rv*inrv* according to">setindices</a>(<span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv); |
| 185 | <a name="l00274"></a>00274 <span class="keywordtype">void</span> <a class="code" href="classcompositepdf.html#3bd4ada95f381ea6c4cff2dc86e957c4" title="Function fills Array by indeces of mpdfs inside given rv.">setrvcinrv</a>(<span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rvc, Array<ivec> &rvcind); |
| 186 | <a name="l00275"></a>00275 }; |
| 187 | <a name="l00276"></a>00276 |
| 188 | <a name="l00284"></a><a class="code" href="classDS.html">00284</a> <span class="keyword">class </span><a class="code" href="classDS.html" title="Abstract class for discrete-time sources of data.">DS</a> { |
| 189 | <a name="l00285"></a>00285 <span class="keyword">protected</span>: |
| 190 | <a name="l00287"></a><a class="code" href="classDS.html#1012025a1a3a1fdd24aa48698a3d3454">00287</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classDS.html#1012025a1a3a1fdd24aa48698a3d3454" title="Observed variables, returned by getdata().">Drv</a>; |
| 191 | <a name="l00289"></a><a class="code" href="classDS.html#0a88ffaeb3c7c2cf30c69bc41a000629">00289</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classDS.html#0a88ffaeb3c7c2cf30c69bc41a000629" title="Action variables, accepted by write().">Urv</a>; <span class="comment">//</span> |
| 192 | <a name="l00290"></a>00290 <span class="keyword">public</span>: |
| 193 | <a name="l00292"></a>00292 <span class="keywordtype">void</span> <a class="code" href="classDS.html#db2dacc9e71a36eeb9c5c2ee402eeeb1" title="Returns full vector of observed data.">getdata</a> ( vec &dt ); |
| 194 | <a name="l00294"></a>00294 <span class="keywordtype">void</span> <a class="code" href="classDS.html#db2dacc9e71a36eeb9c5c2ee402eeeb1" title="Returns full vector of observed data.">getdata</a> ( vec &dt, ivec &indeces ); |
| 195 | <a name="l00296"></a>00296 <span class="keywordtype">void</span> <a class="code" href="classDS.html#0dfb6788b70c0d48a1f5276ed6c93039" title="Accepts action variable and schedule it for application.">write</a> ( vec &ut ); |
| 196 | <a name="l00298"></a>00298 <span class="keywordtype">void</span> <a class="code" href="classDS.html#0dfb6788b70c0d48a1f5276ed6c93039" title="Accepts action variable and schedule it for application.">write</a> ( vec &ut, ivec &indeces ); |
| 197 | <a name="l00304"></a>00304 <span class="keywordtype">void</span> <a class="code" href="classDS.html#9a35ca9c9321dce2bf63bf668f785b75" title="Method that assigns random variables to the datasource. Typically, the datasource...">linkrvs</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &drv, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &urv ); |
| 198 | <a name="l00305"></a>00305 |
| 199 | <a name="l00307"></a>00307 <span class="keywordtype">void</span> <a class="code" href="classDS.html#470ba89e8e7c3c4d830803221b4e9be6" title="Moves from to , i.e. perfroms the actions and reads response of the system.">step</a>(); |
| 200 | <a name="l00308"></a>00308 |
| 201 | <a name="l00309"></a>00309 }; |
| 202 | <a name="l00310"></a>00310 |
| 203 | <a name="l00315"></a><a class="code" href="classBM.html">00315</a> <span class="keyword">class </span><a class="code" href="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a> { |
| 204 | <a name="l00316"></a>00316 <span class="keyword">protected</span>: |
| 205 | <a name="l00318"></a><a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88">00318</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a>; |
| 206 | <a name="l00320"></a><a class="code" href="classBM.html#5623fef6572a08c2b53b8c87b82dc979">00320</a> <span class="keywordtype">double</span> <a class="code" href="classBM.html#5623fef6572a08c2b53b8c87b82dc979" title="Logarithm of marginalized data likelihood.">ll</a>; |
| 207 | <a name="l00322"></a><a class="code" href="classBM.html#bf6fb59b30141074f8ee1e2f43d03129">00322</a> <span class="keywordtype">bool</span> <a class="code" href="classBM.html#bf6fb59b30141074f8ee1e2f43d03129" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>; |
| 208 | <a name="l00323"></a>00323 <span class="keyword">public</span>: |
214 | | <a name="l00327"></a><a class="code" href="classBM.html#8a8ce6df431689964c41cc6c849cfd06">00327</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classBM.html#8a8ce6df431689964c41cc6c849cfd06">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;} |
215 | | <a name="l00329"></a><a class="code" href="classBM.html#cd0660f2a1a344b56ac39802708ff165">00329</a> vec <a class="code" href="classBM.html#cd0660f2a1a344b56ac39802708ff165" 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="classBM.html#8a8ce6df431689964c41cc6c849cfd06">logpred</a>(dt.get_col(i));}<span class="keywordflow">return</span> tmp;} |
216 | | <a name="l00330"></a>00330 |
217 | | <a name="l00332"></a><a class="code" href="classBM.html#a627c5a79cc6f5221b7e09675525e032">00332</a> <span class="keyword">virtual</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* <a class="code" href="classBM.html#a627c5a79cc6f5221b7e09675525e032" title="Constructs a predictive density (marginal density on data).">predictor</a>(<span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a>){it_error(<span class="stringliteral">"Not implemented"</span>);<span class="keywordflow">return</span> NULL;}; |
218 | | <a name="l00333"></a>00333 |
219 | | <a name="l00335"></a><a class="code" href="classBM.html#ca0f02b3b4144e0895cc14f7e0374bdd">00335</a> <span class="keyword">virtual</span> <a class="code" href="classBM.html#ca0f02b3b4144e0895cc14f7e0374bdd" title="Destructor for future use;.">~BM</a>() {}; |
220 | | <a name="l00337"></a><a class="code" href="classBM.html#126bd2595c48e311fc2a7ab72876092a">00337</a> <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a>& <a class="code" href="classBM.html#126bd2595c48e311fc2a7ab72876092a" title="access function">_rv</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a>;} |
221 | | <a name="l00339"></a><a class="code" href="classBM.html#87f4a547d2c29180be88175e5eab9c88">00339</a> <span class="keywordtype">double</span> <a class="code" href="classBM.html#87f4a547d2c29180be88175e5eab9c88" title="access function">_ll</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classBM.html#5623fef6572a08c2b53b8c87b82dc979" title="Logarithm of marginalized data likelihood.">ll</a>;} |
222 | | <a name="l00341"></a><a class="code" href="classBM.html#1ffa9f23669aabecc3760c06c6987522">00341</a> <span class="keywordtype">void</span> <a class="code" href="classBM.html#1ffa9f23669aabecc3760c06c6987522" title="access function">set_evalll</a>(<span class="keywordtype">bool</span> evl0){<a class="code" href="classBM.html#bf6fb59b30141074f8ee1e2f43d03129" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>=evl0;} |
223 | | <a name="l00342"></a>00342 |
224 | | <a name="l00345"></a><a class="code" href="classBM.html#eb58c81d6a7b75b05fc6f276eed78887">00345</a> <span class="keyword">virtual</span> <a class="code" href="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a>* <a class="code" href="classBM.html#eb58c81d6a7b75b05fc6f276eed78887">_copy_</a>(<span class="keywordtype">bool</span> changerv=<span class="keyword">false</span>){it_error(<span class="stringliteral">"function _copy_ not implemented for this BM"</span>); <span class="keywordflow">return</span> NULL;}; |
225 | | <a name="l00346"></a>00346 }; |
226 | | <a name="l00347"></a>00347 |
227 | | <a name="l00357"></a><a class="code" href="classBMcond.html">00357</a> <span class="keyword">class </span><a class="code" href="classBMcond.html" title="Conditional Bayesian Filter.">BMcond</a> { |
228 | | <a name="l00358"></a>00358 <span class="keyword">protected</span>: |
229 | | <a name="l00360"></a><a class="code" href="classBMcond.html#9ba793c8ec453f04d372d17195ed8dec">00360</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classBMcond.html#9ba793c8ec453f04d372d17195ed8dec" title="Identificator of the conditioning variable.">rvc</a>; |
230 | | <a name="l00361"></a>00361 <span class="keyword">public</span>: |
231 | | <a name="l00363"></a>00363 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classBMcond.html#3543cfe274c35f9033c24d8036a96c4d" title="Substitute val for rvc.">condition</a> ( <span class="keyword">const</span> vec &val ) =0; |
232 | | <a name="l00365"></a><a class="code" href="classBMcond.html#9a38dcdabef902fd91da3c9fb6ac27f7">00365</a> <a class="code" href="classBMcond.html#9a38dcdabef902fd91da3c9fb6ac27f7" title="Default constructor.">BMcond</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv0 ) :<a class="code" href="classBMcond.html#9ba793c8ec453f04d372d17195ed8dec" title="Identificator of the conditioning variable.">rvc</a> ( rv0 ) {}; |
233 | | <a name="l00367"></a><a class="code" href="classBMcond.html#d40c72250cf93640f982d06de20815b2">00367</a> <span class="keyword">virtual</span> <a class="code" href="classBMcond.html#d40c72250cf93640f982d06de20815b2" title="Destructor for future use.">~BMcond</a>() {}; |
234 | | <a name="l00369"></a><a class="code" href="classBMcond.html#3fa60348b2da6b4208bb95b8d146900a">00369</a> <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a>& <a class="code" href="classBMcond.html#3fa60348b2da6b4208bb95b8d146900a" title="access function">_rvc</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classBMcond.html#9ba793c8ec453f04d372d17195ed8dec" title="Identificator of the conditioning variable.">rvc</a>;} |
235 | | <a name="l00370"></a>00370 }; |
236 | | <a name="l00371"></a>00371 |
237 | | <a name="l00372"></a>00372 <span class="preprocessor">#endif // BM_H</span> |
| 210 | <a name="l00326"></a><a class="code" href="classBM.html#43d2ad6a6c9f1bcd22fe8906c477e50e">00326</a> <a class="code" href="classBM.html#43d2ad6a6c9f1bcd22fe8906c477e50e" title="Default constructor.">BM</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv0, <span class="keywordtype">double</span> ll0=0,<span class="keywordtype">bool</span> evalll0=<span class="keyword">true</span> ) :<a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a> ( rv0 ), <a class="code" href="classBM.html#5623fef6572a08c2b53b8c87b82dc979" title="Logarithm of marginalized data likelihood.">ll</a> ( ll0 ),<a class="code" href="classBM.html#bf6fb59b30141074f8ee1e2f43d03129" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a> ( evalll0) {<span class="comment">//Fixme: test rv</span> |
| 211 | <a name="l00327"></a>00327 }; |
| 212 | <a name="l00329"></a><a class="code" href="classBM.html#e8fc5fae042f2b46d4d3827f9587d47d">00329</a> <a class="code" href="classBM.html#43d2ad6a6c9f1bcd22fe8906c477e50e" title="Default constructor.">BM</a> (<span class="keyword">const</span> <a class="code" href="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a> &B) : <a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a>(B.<a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a>), <a class="code" href="classBM.html#5623fef6572a08c2b53b8c87b82dc979" title="Logarithm of marginalized data likelihood.">ll</a>(B.<a class="code" href="classBM.html#5623fef6572a08c2b53b8c87b82dc979" title="Logarithm of marginalized data likelihood.">ll</a>), <a class="code" href="classBM.html#bf6fb59b30141074f8ee1e2f43d03129" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>(B.<a class="code" href="classBM.html#bf6fb59b30141074f8ee1e2f43d03129" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>) {} |
| 213 | <a name="l00330"></a>00330 |
| 214 | <a name="l00334"></a>00334 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classBM.html#a892eff438aab2dd1a9e2efcb7fb5bdf" title="Incremental Bayes rule.">bayes</a> ( <span class="keyword">const</span> vec &dt ) = 0; |
| 215 | <a name="l00336"></a>00336 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classBM.html#0186270f75189677f390fe088a9947e9" title="Batch Bayes rule (columns of Dt are observations).">bayesB</a> (<span class="keyword">const</span> mat &Dt ); |
| 216 | <a name="l00338"></a>00338 <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>& <a class="code" href="classBM.html#8554809fec160bee279bcd5fa14ead5c" title="Returns a pointer to the epdf representing posterior density on parameters. Use with...">_epdf</a>() <span class="keyword">const</span> =0; |
| 217 | <a name="l00339"></a>00339 |
| 218 | <a name="l00342"></a><a class="code" href="classBM.html#8a8ce6df431689964c41cc6c849cfd06">00342</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classBM.html#8a8ce6df431689964c41cc6c849cfd06">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;} |
| 219 | <a name="l00344"></a><a class="code" href="classBM.html#cd0660f2a1a344b56ac39802708ff165">00344</a> vec <a class="code" href="classBM.html#cd0660f2a1a344b56ac39802708ff165" 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="classBM.html#8a8ce6df431689964c41cc6c849cfd06">logpred</a>(dt.get_col(i));}<span class="keywordflow">return</span> tmp;} |
| 220 | <a name="l00345"></a>00345 |
| 221 | <a name="l00347"></a><a class="code" href="classBM.html#a627c5a79cc6f5221b7e09675525e032">00347</a> <span class="keyword">virtual</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* <a class="code" href="classBM.html#a627c5a79cc6f5221b7e09675525e032" title="Constructs a predictive density (marginal density on data).">predictor</a>(<span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a>){it_error(<span class="stringliteral">"Not implemented"</span>);<span class="keywordflow">return</span> NULL;}; |
| 222 | <a name="l00348"></a>00348 |
| 223 | <a name="l00350"></a><a class="code" href="classBM.html#ca0f02b3b4144e0895cc14f7e0374bdd">00350</a> <span class="keyword">virtual</span> <a class="code" href="classBM.html#ca0f02b3b4144e0895cc14f7e0374bdd" title="Destructor for future use;.">~BM</a>() {}; |
| 224 | <a name="l00352"></a><a class="code" href="classBM.html#126bd2595c48e311fc2a7ab72876092a">00352</a> <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a>& <a class="code" href="classBM.html#126bd2595c48e311fc2a7ab72876092a" title="access function">_rv</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a>;} |
| 225 | <a name="l00354"></a><a class="code" href="classBM.html#87f4a547d2c29180be88175e5eab9c88">00354</a> <span class="keywordtype">double</span> <a class="code" href="classBM.html#87f4a547d2c29180be88175e5eab9c88" title="access function">_ll</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classBM.html#5623fef6572a08c2b53b8c87b82dc979" title="Logarithm of marginalized data likelihood.">ll</a>;} |
| 226 | <a name="l00356"></a><a class="code" href="classBM.html#1ffa9f23669aabecc3760c06c6987522">00356</a> <span class="keywordtype">void</span> <a class="code" href="classBM.html#1ffa9f23669aabecc3760c06c6987522" title="access function">set_evalll</a>(<span class="keywordtype">bool</span> evl0){<a class="code" href="classBM.html#bf6fb59b30141074f8ee1e2f43d03129" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a>=evl0;} |
| 227 | <a name="l00357"></a>00357 |
| 228 | <a name="l00360"></a><a class="code" href="classBM.html#eb58c81d6a7b75b05fc6f276eed78887">00360</a> <span class="keyword">virtual</span> <a class="code" href="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a>* <a class="code" href="classBM.html#eb58c81d6a7b75b05fc6f276eed78887">_copy_</a>(<span class="keywordtype">bool</span> changerv=<span class="keyword">false</span>){it_error(<span class="stringliteral">"function _copy_ not implemented for this BM"</span>); <span class="keywordflow">return</span> NULL;}; |
| 229 | <a name="l00361"></a>00361 }; |
| 230 | <a name="l00362"></a>00362 |
| 231 | <a name="l00372"></a><a class="code" href="classBMcond.html">00372</a> <span class="keyword">class </span><a class="code" href="classBMcond.html" title="Conditional Bayesian Filter.">BMcond</a> { |
| 232 | <a name="l00373"></a>00373 <span class="keyword">protected</span>: |
| 233 | <a name="l00375"></a><a class="code" href="classBMcond.html#9ba793c8ec453f04d372d17195ed8dec">00375</a> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classBMcond.html#9ba793c8ec453f04d372d17195ed8dec" title="Identificator of the conditioning variable.">rvc</a>; |
| 234 | <a name="l00376"></a>00376 <span class="keyword">public</span>: |
| 235 | <a name="l00378"></a>00378 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classBMcond.html#3543cfe274c35f9033c24d8036a96c4d" title="Substitute val for rvc.">condition</a> ( <span class="keyword">const</span> vec &val ) =0; |
| 236 | <a name="l00380"></a><a class="code" href="classBMcond.html#9a38dcdabef902fd91da3c9fb6ac27f7">00380</a> <a class="code" href="classBMcond.html#9a38dcdabef902fd91da3c9fb6ac27f7" title="Default constructor.">BMcond</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv0 ) :<a class="code" href="classBMcond.html#9ba793c8ec453f04d372d17195ed8dec" title="Identificator of the conditioning variable.">rvc</a> ( rv0 ) {}; |
| 237 | <a name="l00382"></a><a class="code" href="classBMcond.html#d40c72250cf93640f982d06de20815b2">00382</a> <span class="keyword">virtual</span> <a class="code" href="classBMcond.html#d40c72250cf93640f982d06de20815b2" title="Destructor for future use.">~BMcond</a>() {}; |
| 238 | <a name="l00384"></a><a class="code" href="classBMcond.html#3fa60348b2da6b4208bb95b8d146900a">00384</a> <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a>& <a class="code" href="classBMcond.html#3fa60348b2da6b4208bb95b8d146900a" title="access function">_rvc</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classBMcond.html#9ba793c8ec453f04d372d17195ed8dec" title="Identificator of the conditioning variable.">rvc</a>;} |
| 239 | <a name="l00385"></a>00385 }; |
| 240 | <a name="l00386"></a>00386 |
| 241 | <a name="l00387"></a>00387 <span class="preprocessor">#endif // BM_H</span> |