Show
Ignore:
Timestamp:
04/18/08 14:03:19 (17 years ago)
Author:
smidl
Message:

oprava dokumentace

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • doc/html/libEF_8h-source.html

    r37 r79  
    5252<a name="l00073"></a><a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20">00073</a>         vec <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>; 
    5353<a name="l00075"></a><a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1">00075</a>         sq_T <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>; 
    54 <a name="l00077"></a><a class="code" href="classenorm.html#82f39ac49911d7097f4bfe385deba355">00077</a>         sq_T <a class="code" href="classenorm.html#82f39ac49911d7097f4bfe385deba355" title="Cache: _iR = inv(R);.">_iR</a>; 
    55 <a name="l00079"></a><a class="code" href="classenorm.html#ae12db77283a96e0f14a3eae93dc3bf1">00079</a>         <span class="keywordtype">bool</span> <a class="code" href="classenorm.html#ae12db77283a96e0f14a3eae93dc3bf1" title="indicator if _iR is chached">cached</a>; 
    56 <a name="l00081"></a><a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e">00081</a>         <span class="keywordtype">int</span> <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a>; 
    57 <a name="l00082"></a>00082 <span class="keyword">public</span>: 
    58 <a name="l00083"></a>00083 <span class="comment">//      enorm() :eEF() {};</span> 
    59 <a name="l00085"></a>00085 <span class="comment"></span>        <a class="code" href="classenorm.html#7b5cb487a2570e8109bfdc0df149aa06" title="Default constructor.">enorm</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ); 
    60 <a name="l00087"></a>00087         <span class="keywordtype">void</span> <a class="code" href="classenorm.html#1394a65caa6e00d42e00cc99b12227af" title="Set mean value mu and covariance R.">set_parameters</a> ( <span class="keyword">const</span> vec &amp;<a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>,<span class="keyword">const</span> sq_T &amp;<a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a> ); 
    61 <a name="l00089"></a>00089         <span class="keywordtype">void</span> <a class="code" href="classenorm.html#5b5fd142b6b17ea334597960e3fe126a" title="tupdate in exponential form (not really handy)">tupdate</a> ( <span class="keywordtype">double</span> phi, mat &amp;vbar, <span class="keywordtype">double</span> nubar ); 
    62 <a name="l00091"></a>00091         <span class="keywordtype">void</span> <a class="code" href="classenorm.html#5bf185e31e5954fceb90ada3debd2ff2" title="dupdate in exponential form (not really handy)">dupdate</a> ( mat &amp;v,<span class="keywordtype">double</span> nu=1.0 ); 
    63 <a name="l00092"></a>00092  
    64 <a name="l00093"></a>00093         vec <a class="code" href="classenorm.html#60b47544f6181ffd4530d3e415ce12c5" title="Returns the required moment of the epdf.">sample</a>() <span class="keyword">const</span>; 
    65 <a name="l00095"></a>00095         mat <a class="code" href="classenorm.html#60b47544f6181ffd4530d3e415ce12c5" title="Returns the required moment of the epdf.">sample</a> ( <span class="keywordtype">int</span> N ) <span class="keyword">const</span>; 
    66 <a name="l00096"></a>00096         <span class="keywordtype">double</span> <a class="code" href="classenorm.html#b9e1dfd33692d7b3f1a59f17b0e61bd0" title="Compute probability of argument val.">eval</a> ( <span class="keyword">const</span> vec &amp;val ) <span class="keyword">const</span> ; 
    67 <a name="l00097"></a>00097         <span class="keywordtype">double</span> <a class="code" href="classenorm.html#609a7c33dbb4fdfab050f3bdd1122401" title="Compute log-probability of argument val.">evalpdflog</a> ( <span class="keyword">const</span> vec &amp;val ) <span class="keyword">const</span>; 
    68 <a name="l00098"></a><a class="code" href="classenorm.html#50fa84da7bae02f7af17a98f37566899">00098</a>         vec <a class="code" href="classenorm.html#50fa84da7bae02f7af17a98f37566899" title="return expected value">mean</a>()<span class="keyword">const </span>{<span class="keywordflow">return</span> <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>;} 
    69 <a name="l00099"></a>00099  
    70 <a name="l00100"></a>00100 <span class="comment">//Access methods</span> 
    71 <a name="l00102"></a><a class="code" href="classenorm.html#3be0cb541ec9b88e5aa3f60307bbc753">00102</a> <span class="comment"></span>        vec* <a class="code" href="classenorm.html#3be0cb541ec9b88e5aa3f60307bbc753" title="returns a pointer to the internal mean value. Use with Care!">_mu</a>() {<span class="keywordflow">return</span> &amp;<a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>;} 
    72 <a name="l00103"></a>00103  
    73 <a name="l00105"></a><a class="code" href="classenorm.html#8725c534863c4fc2bddef0edfb95a740">00105</a>         <span class="keywordtype">void</span> <a class="code" href="classenorm.html#8725c534863c4fc2bddef0edfb95a740" title="returns pointers to the internal variance and its inverse. Use with Care!">_R</a> ( sq_T* &amp;pR, sq_T* &amp;piR ) { 
    74 <a name="l00106"></a>00106                 pR=&amp;<a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>; 
    75 <a name="l00107"></a>00107                 piR=&amp;<a class="code" href="classenorm.html#82f39ac49911d7097f4bfe385deba355" title="Cache: _iR = inv(R);.">_iR</a>; 
    76 <a name="l00108"></a>00108         } 
     54<a name="l00077"></a><a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e">00077</a>         <span class="keywordtype">int</span> <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a>; 
     55<a name="l00078"></a>00078 <span class="keyword">public</span>: 
     56<a name="l00079"></a>00079 <span class="comment">//      enorm() :eEF() {};</span> 
     57<a name="l00081"></a>00081 <span class="comment"></span>        <a class="code" href="classenorm.html#7b5cb487a2570e8109bfdc0df149aa06" title="Default constructor.">enorm</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ); 
     58<a name="l00083"></a>00083         <span class="keywordtype">void</span> <a class="code" href="classenorm.html#1394a65caa6e00d42e00cc99b12227af" title="Set mean value mu and covariance R.">set_parameters</a> ( <span class="keyword">const</span> vec &amp;<a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>,<span class="keyword">const</span> sq_T &amp;<a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a> ); 
     59<a name="l00085"></a>00085         <span class="keywordtype">void</span> <a class="code" href="classenorm.html#5b5fd142b6b17ea334597960e3fe126a" title="tupdate in exponential form (not really handy)">tupdate</a> ( <span class="keywordtype">double</span> phi, mat &amp;vbar, <span class="keywordtype">double</span> nubar ); 
     60<a name="l00087"></a>00087         <span class="keywordtype">void</span> <a class="code" href="classenorm.html#5bf185e31e5954fceb90ada3debd2ff2" title="dupdate in exponential form (not really handy)">dupdate</a> ( mat &amp;v,<span class="keywordtype">double</span> nu=1.0 ); 
     61<a name="l00088"></a>00088  
     62<a name="l00089"></a>00089         vec <a class="code" href="classenorm.html#60b47544f6181ffd4530d3e415ce12c5" title="Returns the required moment of the epdf.">sample</a>() <span class="keyword">const</span>; 
     63<a name="l00091"></a>00091         mat <a class="code" href="classenorm.html#60b47544f6181ffd4530d3e415ce12c5" title="Returns the required moment of the epdf.">sample</a> ( <span class="keywordtype">int</span> N ) <span class="keyword">const</span>; 
     64<a name="l00092"></a>00092         <span class="keywordtype">double</span> <a class="code" href="classenorm.html#b9e1dfd33692d7b3f1a59f17b0e61bd0" title="Compute probability of argument val.">eval</a> ( <span class="keyword">const</span> vec &amp;val ) <span class="keyword">const</span> ; 
     65<a name="l00093"></a>00093         <span class="keywordtype">double</span> <a class="code" href="classenorm.html#609a7c33dbb4fdfab050f3bdd1122401" title="Compute log-probability of argument val.">evalpdflog</a> ( <span class="keyword">const</span> vec &amp;val ) <span class="keyword">const</span>; 
     66<a name="l00094"></a><a class="code" href="classenorm.html#50fa84da7bae02f7af17a98f37566899">00094</a>         vec <a class="code" href="classenorm.html#50fa84da7bae02f7af17a98f37566899" title="return expected value">mean</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>;} 
     67<a name="l00095"></a>00095  
     68<a name="l00096"></a>00096 <span class="comment">//Access methods</span> 
     69<a name="l00098"></a><a class="code" href="classenorm.html#0b8cb284e5af920a1b64a21d057ec5ac">00098</a> <span class="comment"></span>        vec&amp; <a class="code" href="classenorm.html#0b8cb284e5af920a1b64a21d057ec5ac" title="returns a pointer to the internal mean value. Use with Care!">_mu</a>() {<span class="keywordflow">return</span> <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>;} 
     70<a name="l00099"></a>00099          
     71<a name="l00101"></a><a class="code" href="classenorm.html#d892a38f03be12e572ea57d9689cef6b">00101</a>         <span class="keywordtype">void</span> <a class="code" href="classenorm.html#d892a38f03be12e572ea57d9689cef6b" title="access function">set_mu</a>(<span class="keyword">const</span> vec mu0) { <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>=mu0;} 
     72<a name="l00102"></a>00102  
     73<a name="l00104"></a><a class="code" href="classenorm.html#7a5034b25771a84450a990d10fc40ac9">00104</a>         sq_T&amp; <a class="code" href="classenorm.html#7a5034b25771a84450a990d10fc40ac9" title="returns pointers to the internal variance and its inverse. Use with Care!">_R</a>() {<span class="keywordflow">return</span> <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>;} 
     74<a name="l00105"></a>00105  
     75<a name="l00107"></a><a class="code" href="classenorm.html#9b9f58dc86affa23511c246887420658">00107</a>         mat <a class="code" href="classenorm.html#9b9f58dc86affa23511c246887420658" title="access method">getR</a> () {<span class="keywordflow">return</span> <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.to_mat();} 
     76<a name="l00108"></a>00108 }; 
    7777<a name="l00109"></a>00109  
    78 <a name="l00111"></a><a class="code" href="classenorm.html#c9ca4f2ca42568e40ca146168e7f3247">00111</a>         <span class="keywordtype">void</span> <a class="code" href="classenorm.html#c9ca4f2ca42568e40ca146168e7f3247" title="set cache as inconsistent">_cached</a> ( <span class="keywordtype">bool</span> what ) {<a class="code" href="classenorm.html#ae12db77283a96e0f14a3eae93dc3bf1" title="indicator if _iR is chached">cached</a>=what;} 
    79 <a name="l00112"></a>00112 }; 
    80 <a name="l00113"></a>00113  
    81 <a name="l00123"></a><a class="code" href="classegamma.html">00123</a> <span class="keyword">class </span><a class="code" href="classegamma.html" title="Gamma posterior density.">egamma</a> : <span class="keyword">public</span> <a class="code" href="classeEF.html" title="General conjugate exponential family posterior density.">eEF</a> { 
    82 <a name="l00124"></a>00124 <span class="keyword">protected</span>: 
    83 <a name="l00126"></a><a class="code" href="classegamma.html#376cebd8932546c440f21b182910b01b">00126</a>         vec <a class="code" href="classegamma.html#376cebd8932546c440f21b182910b01b" title="Vector .">alpha</a>; 
    84 <a name="l00128"></a><a class="code" href="classegamma.html#cfc5f136467488a421ab22f886323790">00128</a>         vec <a class="code" href="classegamma.html#cfc5f136467488a421ab22f886323790" title="Vector .">beta</a>; 
    85 <a name="l00129"></a>00129 <span class="keyword">public</span> : 
    86 <a name="l00131"></a><a class="code" href="classegamma.html#4b1d34f3b244ea51a58ec10c468788c1">00131</a>         <a class="code" href="classegamma.html#4b1d34f3b244ea51a58ec10c468788c1" title="Default constructor.">egamma</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ) :<a class="code" href="classeEF.html" title="General conjugate exponential family posterior density.">eEF</a> ( rv ) {}; 
    87 <a name="l00133"></a><a class="code" href="classegamma.html#8e348b89be82b70471fe8c5630f61339">00133</a>         <span class="keywordtype">void</span> <a class="code" href="classegamma.html#8e348b89be82b70471fe8c5630f61339" title="Sets parameters.">set_parameters</a> ( <span class="keyword">const</span> vec &amp;a, <span class="keyword">const</span> vec &amp;b ) {<a class="code" href="classegamma.html#376cebd8932546c440f21b182910b01b" title="Vector .">alpha</a>=a,<a class="code" href="classegamma.html#cfc5f136467488a421ab22f886323790" title="Vector .">beta</a>=b;}; 
    88 <a name="l00134"></a>00134         vec <a class="code" href="classegamma.html#8e10c0021b5dfdd9cb62c6959b5ef425" title="Returns the required moment of the epdf.">sample</a>() <span class="keyword">const</span>; 
    89 <a name="l00136"></a>00136         mat <a class="code" href="classegamma.html#8e10c0021b5dfdd9cb62c6959b5ef425" title="Returns the required moment of the epdf.">sample</a> ( <span class="keywordtype">int</span> N ) <span class="keyword">const</span>; 
    90 <a name="l00137"></a>00137         <span class="keywordtype">double</span> <a class="code" href="classegamma.html#de84faac8f9799dfe2777ddbedf997ef" title="Compute log-probability of argument val.">evalpdflog</a> ( <span class="keyword">const</span> vec &amp;val ) <span class="keyword">const</span>; 
    91 <a name="l00139"></a><a class="code" href="classegamma.html#44445c56e60b91b377f207f8d5089790">00139</a>         <span class="keywordtype">void</span> <a class="code" href="classegamma.html#44445c56e60b91b377f207f8d5089790" title="Returns poiter to alpha and beta. Potentially dengerous: use with care!">_param</a> ( vec* &amp;a, vec* &amp;b ) {a=&amp;<a class="code" href="classegamma.html#376cebd8932546c440f21b182910b01b" title="Vector .">alpha</a>;b=&amp;<a class="code" href="classegamma.html#cfc5f136467488a421ab22f886323790" title="Vector .">beta</a>;}; 
    92 <a name="l00140"></a><a class="code" href="classegamma.html#6ab5ba56f7cdb2e5921c3e77524fa50a">00140</a>         vec <a class="code" href="classegamma.html#6ab5ba56f7cdb2e5921c3e77524fa50a" title="return expected value">mean</a>()<span class="keyword">const </span>{vec pom(<a class="code" href="classegamma.html#376cebd8932546c440f21b182910b01b" title="Vector .">alpha</a>); pom/=<a class="code" href="classegamma.html#cfc5f136467488a421ab22f886323790" title="Vector .">beta</a>; <span class="keywordflow">return</span> pom;} 
    93 <a name="l00141"></a>00141 }; 
    94 <a name="l00142"></a>00142 <span class="comment">/*</span> 
    95 <a name="l00144"></a>00144 <span class="comment">class emix : public epdf {</span> 
    96 <a name="l00145"></a>00145 <span class="comment">protected:</span> 
    97 <a name="l00146"></a>00146 <span class="comment">        int n;</span> 
    98 <a name="l00147"></a>00147 <span class="comment">        vec &amp;w;</span> 
    99 <a name="l00148"></a>00148 <span class="comment">        Array&lt;epdf*&gt; Coms;</span> 
    100 <a name="l00149"></a>00149 <span class="comment">public:</span> 
    101 <a name="l00151"></a>00151 <span class="comment">        emix ( const RV &amp;rv, vec &amp;w0): epdf(rv), n(w0.length()), w(w0), Coms(n) {};</span> 
    102 <a name="l00152"></a>00152 <span class="comment">        void set_parameters( int &amp;i, double wi, epdf* ep){w(i)=wi;Coms(i)=ep;}</span> 
    103 <a name="l00153"></a>00153 <span class="comment">        vec mean(){vec pom; for(int i=0;i&lt;n;i++){pom+=Coms(i)-&gt;mean()*w(i);} return pom;};</span> 
    104 <a name="l00154"></a>00154 <span class="comment">        vec sample() {it_error ( "Not implemented" );return 0;}</span> 
    105 <a name="l00155"></a>00155 <span class="comment">};</span> 
    106 <a name="l00156"></a>00156 <span class="comment">*/</span> 
    107 <a name="l00157"></a>00157  
    108 <a name="l00159"></a>00159  
    109 <a name="l00160"></a><a class="code" href="classeuni.html">00160</a> <span class="keyword">class </span><a class="code" href="classeuni.html" title="Uniform distributed density on a rectangular support.">euni</a>: <span class="keyword">public</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> { 
    110 <a name="l00161"></a>00161 <span class="keyword">protected</span>: 
    111 <a name="l00163"></a><a class="code" href="classeuni.html#ef42cd8d7645422048d46c46ec5cdac1">00163</a>         vec <a class="code" href="classeuni.html#ef42cd8d7645422048d46c46ec5cdac1" title="lower bound on support">low</a>; 
    112 <a name="l00165"></a><a class="code" href="classeuni.html#71b6d6b41aeb61a7f76f682b72119231">00165</a>         vec <a class="code" href="classeuni.html#71b6d6b41aeb61a7f76f682b72119231" title="upper bound on support">high</a>; 
    113 <a name="l00167"></a><a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4">00167</a>         vec <a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a>; 
    114 <a name="l00169"></a><a class="code" href="classeuni.html#63105490e946e43372d6187ad1bafdda">00169</a>         <span class="keywordtype">double</span> <a class="code" href="classeuni.html#63105490e946e43372d6187ad1bafdda" title="normalizing coefficients">nk</a>; 
    115 <a name="l00171"></a><a class="code" href="classeuni.html#f445a0ce24f39d14c1a4eed53fc8e2c3">00171</a>         <span class="keywordtype">double</span> <a class="code" href="classeuni.html#f445a0ce24f39d14c1a4eed53fc8e2c3" title="cache of log( nk )">lnk</a>; 
    116 <a name="l00172"></a>00172 <span class="keyword">public</span>: 
    117 <a name="l00174"></a><a class="code" href="classeuni.html#2537a6c239cff52e3ba814851a1116cd">00174</a>         <a class="code" href="classeuni.html#2537a6c239cff52e3ba814851a1116cd" title="Defualt constructor.">euni</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> ) :<a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( rv ) {} 
    118 <a name="l00175"></a><a class="code" href="classeuni.html#2723d4992900b5c5495bfa03628195ed">00175</a>         <span class="keywordtype">double</span> <a class="code" href="classeuni.html#2723d4992900b5c5495bfa03628195ed" title="Compute probability of argument val.">eval</a> ( <span class="keyword">const</span> vec &amp;val )<span class="keyword"> const  </span>{<span class="keywordflow">return</span> <a class="code" href="classeuni.html#63105490e946e43372d6187ad1bafdda" title="normalizing coefficients">nk</a>;} 
    119 <a name="l00176"></a><a class="code" href="classeuni.html#06af95d514a6623ad4688bd2ad50ad71">00176</a>         <span class="keywordtype">double</span> <a class="code" href="classeuni.html#06af95d514a6623ad4688bd2ad50ad71" title="Compute log-probability of argument val.">evalpdflog</a> ( <span class="keyword">const</span> vec &amp;val )<span class="keyword"> const  </span>{<span class="keywordflow">return</span> <a class="code" href="classeuni.html#f445a0ce24f39d14c1a4eed53fc8e2c3" title="cache of log( nk )">lnk</a>;} 
    120 <a name="l00177"></a><a class="code" href="classeuni.html#4a0e09392be17beaee120ba98fc038cd">00177</a>         vec <a class="code" href="classeuni.html#4a0e09392be17beaee120ba98fc038cd" title="Returns the required moment of the epdf.">sample</a>()<span class="keyword"> const </span>{ 
    121 <a name="l00178"></a>00178                 vec smp ( <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return length (number of scalars) of the RV.">count</a>() ); UniRNG.sample_vector ( <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return length (number of scalars) of the RV.">count</a>(),smp ); 
    122 <a name="l00179"></a>00179                 <span class="keywordflow">return</span> <a class="code" href="classeuni.html#ef42cd8d7645422048d46c46ec5cdac1" title="lower bound on support">low</a>+<a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a>*smp; 
    123 <a name="l00180"></a>00180         } 
    124 <a name="l00182"></a><a class="code" href="classeuni.html#4fd7c6a05100616ad16ece405cad7bf2">00182</a>         <span class="keywordtype">void</span> <a class="code" href="classeuni.html#4fd7c6a05100616ad16ece405cad7bf2" title="set values of low and high ">set_parameters</a> ( <span class="keyword">const</span> vec &amp;low0, <span class="keyword">const</span> vec &amp;high0 ) { 
    125 <a name="l00183"></a>00183                 <a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a> = high0-low0; 
    126 <a name="l00184"></a>00184                 it_assert_debug ( min ( <a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a> ) &gt;0.0,<span class="stringliteral">"bad support"</span> ); 
    127 <a name="l00185"></a>00185                 <a class="code" href="classeuni.html#ef42cd8d7645422048d46c46ec5cdac1" title="lower bound on support">low</a> = low0; 
    128 <a name="l00186"></a>00186                 <a class="code" href="classeuni.html#71b6d6b41aeb61a7f76f682b72119231" title="upper bound on support">high</a> = high0; 
    129 <a name="l00187"></a>00187                 <a class="code" href="classeuni.html#63105490e946e43372d6187ad1bafdda" title="normalizing coefficients">nk</a> = prod ( 1.0/<a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a> ); 
    130 <a name="l00188"></a>00188                 <a class="code" href="classeuni.html#f445a0ce24f39d14c1a4eed53fc8e2c3" title="cache of log( nk )">lnk</a> = log ( <a class="code" href="classeuni.html#63105490e946e43372d6187ad1bafdda" title="normalizing coefficients">nk</a> ); 
    131 <a name="l00189"></a>00189         } 
    132 <a name="l00190"></a><a class="code" href="classeuni.html#8050087e421a9cfd1b4b1f8bd33b1cc1">00190</a>         vec <a class="code" href="classeuni.html#8050087e421a9cfd1b4b1f8bd33b1cc1" title="return expected value">mean</a>()<span class="keyword"> const </span>{vec pom=<a class="code" href="classeuni.html#71b6d6b41aeb61a7f76f682b72119231" title="upper bound on support">high</a>; pom-=<a class="code" href="classeuni.html#ef42cd8d7645422048d46c46ec5cdac1" title="lower bound on support">low</a>; pom/=2.0; <span class="keywordflow">return</span> pom;} 
    133 <a name="l00191"></a>00191 }; 
    134 <a name="l00192"></a>00192  
    135 <a name="l00193"></a>00193  
    136 <a name="l00199"></a>00199 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    137 <a name="l00200"></a><a class="code" href="classmlnorm.html">00200</a> <span class="keyword">class </span><a class="code" href="classmlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm</a> : <span class="keyword">public</span> <a class="code" href="classmEF.html" title="Exponential family model.">mEF</a> { 
    138 <a name="l00202"></a>00202         <a class="code" href="classenorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm&lt;sq_T&gt;</a> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>; 
    139 <a name="l00203"></a>00203         vec* _mu; <span class="comment">//cached epdf.mu;</span> 
    140 <a name="l00204"></a>00204         mat A; 
    141 <a name="l00205"></a>00205 <span class="keyword">public</span>: 
    142 <a name="l00207"></a>00207         <a class="code" href="classmlnorm.html#f927203b3f31171c5c10ffc7caa797f5" title="Constructor.">mlnorm</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;<a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>,<a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;<a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab" title="random variable in condition">rvc</a> ); 
    143 <a name="l00209"></a>00209         <span class="keywordtype">void</span> <a class="code" href="classmlnorm.html#b6749030c5d5abcb3eb6898f74cea3c0" title="Set A and R.">set_parameters</a> ( <span class="keyword">const</span>  mat &amp;A, <span class="keyword">const</span> sq_T &amp;R ); 
    144 <a name="l00211"></a>00211         vec <a class="code" href="classmlnorm.html#decf3e3b5c8e0812e5b4dbe94fa2ae18" title="Generate one sample of the posterior.">samplecond</a> ( vec &amp;cond, <span class="keywordtype">double</span> &amp;lik ); 
    145 <a name="l00213"></a>00213         mat <a class="code" href="classmlnorm.html#decf3e3b5c8e0812e5b4dbe94fa2ae18" title="Generate one sample of the posterior.">samplecond</a> ( vec &amp;cond, vec &amp;lik, <span class="keywordtype">int</span> n ); 
    146 <a name="l00215"></a>00215         <span class="keywordtype">void</span> <a class="code" href="classmlnorm.html#5232fc7e305eceab4e2bd6a8daa44195" title="Set value of rvc . Result of this operation is stored in epdf use function _ep to...">condition</a> ( vec &amp;cond ); 
    147 <a name="l00216"></a>00216 }; 
    148 <a name="l00217"></a>00217  
    149 <a name="l00227"></a><a class="code" href="classmgamma.html">00227</a> <span class="keyword">class </span><a class="code" href="classmgamma.html" title="Gamma random walk.">mgamma</a> : <span class="keyword">public</span> <a class="code" href="classmEF.html" title="Exponential family model.">mEF</a> { 
    150 <a name="l00229"></a>00229         <a class="code" href="classegamma.html" title="Gamma posterior density.">egamma</a> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>; 
    151 <a name="l00231"></a>00231         <span class="keywordtype">double</span> k; 
    152 <a name="l00233"></a>00233         vec* _beta; 
    153 <a name="l00234"></a>00234  
    154 <a name="l00235"></a>00235 <span class="keyword">public</span>: 
    155 <a name="l00237"></a>00237         <a class="code" href="classmgamma.html#af43e61b86900c0398d5c0ffc83b94e6" title="Constructor.">mgamma</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;<a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>,<span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;<a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab" title="random variable in condition">rvc</a> ); 
    156 <a name="l00239"></a>00239         <span class="keywordtype">void</span> <a class="code" href="classmgamma.html#a9d646cf758a70126dde7c48790b6e94" title="Set value of k.">set_parameters</a> ( <span class="keywordtype">double</span> k ); 
    157 <a name="l00241"></a>00241         vec <a class="code" href="classmgamma.html#9f40dc43885085fad8e3d6652b79e139" title="Generate one sample of the posterior.">samplecond</a> ( vec &amp;cond, <span class="keywordtype">double</span> &amp;lik ); 
    158 <a name="l00243"></a>00243         mat <a class="code" href="classmgamma.html#9f40dc43885085fad8e3d6652b79e139" title="Generate one sample of the posterior.">samplecond</a> ( vec &amp;cond, vec &amp;lik, <span class="keywordtype">int</span> n ); 
    159 <a name="l00244"></a><a class="code" href="classmgamma.html#a61094c9f7a2d64ea77b130cbc031f97">00244</a>         <span class="keywordtype">void</span> <a class="code" href="classmgamma.html#a61094c9f7a2d64ea77b130cbc031f97" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a> ( <span class="keyword">const</span> vec &amp;val ) {*_beta=k/val;}; 
    160 <a name="l00245"></a>00245 }; 
    161 <a name="l00246"></a>00246  
    162 <a name="l00248"></a><a class="code" href="libEF_8h.html#99497a3ff630f761cf6bff7babd23212">00248</a> <span class="keyword">enum</span> <a class="code" href="libEF_8h.html#99497a3ff630f761cf6bff7babd23212" title="Switch between various resampling methods.">RESAMPLING_METHOD</a> { MULTINOMIAL = 0, STRATIFIED = 1, SYSTEMATIC = 3 }; 
    163 <a name="l00254"></a><a class="code" href="classeEmp.html">00254</a> <span class="keyword">class </span><a class="code" href="classeEmp.html" title="Weighted empirical density.">eEmp</a>: <span class="keyword">public</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> { 
    164 <a name="l00255"></a>00255 <span class="keyword">protected</span> : 
    165 <a name="l00257"></a><a class="code" href="classeEmp.html#8c33034de0e35f03f8bb85d3d67438fd">00257</a>         <span class="keywordtype">int</span> <a class="code" href="classeEmp.html#8c33034de0e35f03f8bb85d3d67438fd" title="Number of particles.">n</a>; 
    166 <a name="l00259"></a><a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8">00259</a>         vec <a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8" title="Sample weights $w$.">w</a>; 
    167 <a name="l00261"></a><a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a">00261</a>         Array&lt;vec&gt; <a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a" title="Samples .">samples</a>; 
    168 <a name="l00262"></a>00262 <span class="keyword">public</span>: 
    169 <a name="l00264"></a><a class="code" href="classeEmp.html#0c04b073ecd0dae3d498e680ae27e9e4">00264</a>         <a class="code" href="classeEmp.html#0c04b073ecd0dae3d498e680ae27e9e4" title="Default constructor.">eEmp</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rv0 ,<span class="keywordtype">int</span> n0) :<a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( rv0 ),<a class="code" href="classeEmp.html#8c33034de0e35f03f8bb85d3d67438fd" title="Number of particles.">n</a>(n0),<a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8" title="Sample weights $w$.">w</a>(<a class="code" href="classeEmp.html#8c33034de0e35f03f8bb85d3d67438fd" title="Number of particles.">n</a>),<a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a" title="Samples .">samples</a>(<a class="code" href="classeEmp.html#8c33034de0e35f03f8bb85d3d67438fd" title="Number of particles.">n</a>) {}; 
    170 <a name="l00266"></a>00266         <span class="keywordtype">void</span> <a class="code" href="classeEmp.html#6606a656c1b28114f7384c25aaf80e8d" title="Set sample.">set_parameters</a> ( <span class="keyword">const</span> vec &amp;w0, <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* pdf0 ); 
    171 <a name="l00268"></a><a class="code" href="classeEmp.html#31b2bfb73b72486a5c89f2ab850c7a9b">00268</a>         vec&amp; <a class="code" href="classeEmp.html#31b2bfb73b72486a5c89f2ab850c7a9b" title="Potentially dangerous, use with care.">_w</a>()  {<span class="keywordflow">return</span> <a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8" title="Sample weights $w$.">w</a>;}; 
    172 <a name="l00270"></a><a class="code" href="classeEmp.html#31b747eca73b16f30370827ba4cc3575">00270</a>         Array&lt;vec&gt;&amp; <a class="code" href="classeEmp.html#31b747eca73b16f30370827ba4cc3575" title="access function">_samples</a>() {<span class="keywordflow">return</span> <a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a" title="Samples .">samples</a>;}; 
    173 <a name="l00272"></a>00272         ivec <a class="code" href="classeEmp.html#77268292fc4465cb73ddbfb1f2932a59" title="Function performs resampling, i.e. removal of low-weight samples and duplication...">resample</a> ( <a class="code" href="libEF_8h.html#99497a3ff630f761cf6bff7babd23212" title="Switch between various resampling methods.">RESAMPLING_METHOD</a> method = SYSTEMATIC ); 
    174 <a name="l00274"></a><a class="code" href="classeEmp.html#83f9283f92b805508d896479dc1ccf12">00274</a>         vec <a class="code" href="classeEmp.html#83f9283f92b805508d896479dc1ccf12" title="inherited operation : NOT implemneted">sample</a>()<span class="keyword"> const </span>{it_error ( <span class="stringliteral">"Not implemented"</span> );<span class="keywordflow">return</span> 0;} 
    175 <a name="l00276"></a><a class="code" href="classeEmp.html#23e7358995400865ad2e278945922fb3">00276</a>         <span class="keywordtype">double</span> <a class="code" href="classeEmp.html#23e7358995400865ad2e278945922fb3" title="inherited operation : NOT implemneted">evalpdflog</a>(<span class="keyword">const</span> vec &amp;val)<span class="keyword"> const </span>{it_error ( <span class="stringliteral">"Not implemented"</span> );<span class="keywordflow">return</span> 0.0;} 
    176 <a name="l00277"></a><a class="code" href="classeEmp.html#ba055c19038cc72628d98e25197e982d">00277</a>         vec <a class="code" href="classeEmp.html#ba055c19038cc72628d98e25197e982d" title="return expected value">mean</a>()<span class="keyword">const </span>{vec pom=zeros(<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return length (number of scalars) of the RV.">count</a>());  
    177 <a name="l00278"></a>00278                 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0;i&lt;<a class="code" href="classeEmp.html#8c33034de0e35f03f8bb85d3d67438fd" title="Number of particles.">n</a>;i++){pom+=<a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a" title="Samples .">samples</a>(i)*<a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8" title="Sample weights $w$.">w</a>(i);} 
    178 <a name="l00279"></a>00279                 <span class="keywordflow">return</span> pom; 
    179 <a name="l00280"></a>00280         } 
    180 <a name="l00281"></a>00281 }; 
    181 <a name="l00282"></a>00282  
    182 <a name="l00283"></a>00283  
    183 <a name="l00285"></a>00285  
    184 <a name="l00286"></a>00286 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    185 <a name="l00287"></a><a class="code" href="classenorm.html#7b5cb487a2570e8109bfdc0df149aa06">00287</a> <a class="code" href="classenorm.html#7b5cb487a2570e8109bfdc0df149aa06" title="Default constructor.">enorm&lt;sq_T&gt;::enorm</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rv ) :<a class="code" href="classeEF.html" title="General conjugate exponential family posterior density.">eEF</a>(rv), mu ( rv.count() ),R ( rv.count() ),_iR ( rv.count() ),cached ( false ),dim ( rv.count() ) {}; 
    186 <a name="l00288"></a>00288  
    187 <a name="l00289"></a>00289 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    188 <a name="l00290"></a><a class="code" href="classenorm.html#1394a65caa6e00d42e00cc99b12227af">00290</a> <span class="keywordtype">void</span> <a class="code" href="classenorm.html#1394a65caa6e00d42e00cc99b12227af" title="Set mean value mu and covariance R.">enorm&lt;sq_T&gt;::set_parameters</a> ( <span class="keyword">const</span> vec &amp;mu0, <span class="keyword">const</span> sq_T &amp;R0 ) { 
    189 <a name="l00291"></a>00291 <span class="comment">//Fixme test dimensions of mu0 and R0;</span> 
    190 <a name="l00292"></a>00292         <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a> = mu0; 
    191 <a name="l00293"></a>00293         <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a> = R0; 
    192 <a name="l00294"></a>00294         <span class="keywordflow">if</span> ( <a class="code" href="classenorm.html#82f39ac49911d7097f4bfe385deba355" title="Cache: _iR = inv(R);.">_iR</a>.rows() !=<a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.rows() ) <a class="code" href="classenorm.html#82f39ac49911d7097f4bfe385deba355" title="Cache: _iR = inv(R);.">_iR</a>=<a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>; <span class="comment">// memory allocation!</span> 
    193 <a name="l00295"></a>00295         <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.inv ( <a class="code" href="classenorm.html#82f39ac49911d7097f4bfe385deba355" title="Cache: _iR = inv(R);.">_iR</a> ); <span class="comment">//update cache</span> 
    194 <a name="l00296"></a>00296         <a class="code" href="classenorm.html#ae12db77283a96e0f14a3eae93dc3bf1" title="indicator if _iR is chached">cached</a>=<span class="keyword">true</span>; 
    195 <a name="l00297"></a>00297 }; 
    196 <a name="l00298"></a>00298  
    197 <a name="l00299"></a>00299 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    198 <a name="l00300"></a><a class="code" href="classenorm.html#5bf185e31e5954fceb90ada3debd2ff2">00300</a> <span class="keywordtype">void</span> <a class="code" href="classenorm.html#5bf185e31e5954fceb90ada3debd2ff2" title="dupdate in exponential form (not really handy)">enorm&lt;sq_T&gt;::dupdate</a> ( mat &amp;v, <span class="keywordtype">double</span> nu ) { 
    199 <a name="l00301"></a>00301         <span class="comment">//</span> 
    200 <a name="l00302"></a>00302 }; 
    201 <a name="l00303"></a>00303  
    202 <a name="l00304"></a>00304 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    203 <a name="l00305"></a><a class="code" href="classenorm.html#5b5fd142b6b17ea334597960e3fe126a">00305</a> <span class="keywordtype">void</span> <a class="code" href="classenorm.html#5b5fd142b6b17ea334597960e3fe126a" title="tupdate in exponential form (not really handy)">enorm&lt;sq_T&gt;::tupdate</a> ( <span class="keywordtype">double</span> phi, mat &amp;vbar, <span class="keywordtype">double</span> nubar ) { 
    204 <a name="l00306"></a>00306         <span class="comment">//</span> 
    205 <a name="l00307"></a>00307 }; 
     78<a name="l00119"></a><a class="code" href="classegamma.html">00119</a> <span class="keyword">class </span><a class="code" href="classegamma.html" title="Gamma posterior density.">egamma</a> : <span class="keyword">public</span> <a class="code" href="classeEF.html" title="General conjugate exponential family posterior density.">eEF</a> { 
     79<a name="l00120"></a>00120 <span class="keyword">protected</span>: 
     80<a name="l00122"></a><a class="code" href="classegamma.html#376cebd8932546c440f21b182910b01b">00122</a>         vec <a class="code" href="classegamma.html#376cebd8932546c440f21b182910b01b" title="Vector .">alpha</a>; 
     81<a name="l00124"></a><a class="code" href="classegamma.html#cfc5f136467488a421ab22f886323790">00124</a>         vec <a class="code" href="classegamma.html#cfc5f136467488a421ab22f886323790" title="Vector .">beta</a>; 
     82<a name="l00125"></a>00125 <span class="keyword">public</span> : 
     83<a name="l00127"></a><a class="code" href="classegamma.html#4b1d34f3b244ea51a58ec10c468788c1">00127</a>         <a class="code" href="classegamma.html#4b1d34f3b244ea51a58ec10c468788c1" title="Default constructor.">egamma</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ) :<a class="code" href="classeEF.html" title="General conjugate exponential family posterior density.">eEF</a> ( rv ) {}; 
     84<a name="l00129"></a><a class="code" href="classegamma.html#8e348b89be82b70471fe8c5630f61339">00129</a>         <span class="keywordtype">void</span> <a class="code" href="classegamma.html#8e348b89be82b70471fe8c5630f61339" title="Sets parameters.">set_parameters</a> ( <span class="keyword">const</span> vec &amp;a, <span class="keyword">const</span> vec &amp;b ) {<a class="code" href="classegamma.html#376cebd8932546c440f21b182910b01b" title="Vector .">alpha</a>=a,<a class="code" href="classegamma.html#cfc5f136467488a421ab22f886323790" title="Vector .">beta</a>=b;}; 
     85<a name="l00130"></a>00130         vec <a class="code" href="classegamma.html#8e10c0021b5dfdd9cb62c6959b5ef425" title="Returns the required moment of the epdf.">sample</a>() <span class="keyword">const</span>; 
     86<a name="l00132"></a>00132         mat <a class="code" href="classegamma.html#8e10c0021b5dfdd9cb62c6959b5ef425" title="Returns the required moment of the epdf.">sample</a> ( <span class="keywordtype">int</span> N ) <span class="keyword">const</span>; 
     87<a name="l00133"></a>00133         <span class="keywordtype">double</span> <a class="code" href="classegamma.html#de84faac8f9799dfe2777ddbedf997ef" title="Compute log-probability of argument val.">evalpdflog</a> ( <span class="keyword">const</span> vec &amp;val ) <span class="keyword">const</span>; 
     88<a name="l00135"></a><a class="code" href="classegamma.html#44445c56e60b91b377f207f8d5089790">00135</a>         <span class="keywordtype">void</span> <a class="code" href="classegamma.html#44445c56e60b91b377f207f8d5089790" title="Returns poiter to alpha and beta. Potentially dengerous: use with care!">_param</a> ( vec* &amp;a, vec* &amp;b ) {a=&amp;<a class="code" href="classegamma.html#376cebd8932546c440f21b182910b01b" title="Vector .">alpha</a>;b=&amp;<a class="code" href="classegamma.html#cfc5f136467488a421ab22f886323790" title="Vector .">beta</a>;}; 
     89<a name="l00136"></a><a class="code" href="classegamma.html#6ab5ba56f7cdb2e5921c3e77524fa50a">00136</a>         vec <a class="code" href="classegamma.html#6ab5ba56f7cdb2e5921c3e77524fa50a" title="return expected value">mean</a>()<span class="keyword"> const </span>{vec pom ( <a class="code" href="classegamma.html#376cebd8932546c440f21b182910b01b" title="Vector .">alpha</a> ); pom/=<a class="code" href="classegamma.html#cfc5f136467488a421ab22f886323790" title="Vector .">beta</a>; <span class="keywordflow">return</span> pom;} 
     90<a name="l00137"></a>00137 }; 
     91<a name="l00138"></a>00138 <span class="comment">/*</span> 
     92<a name="l00140"></a>00140 <span class="comment">class emix : public epdf {</span> 
     93<a name="l00141"></a>00141 <span class="comment">protected:</span> 
     94<a name="l00142"></a>00142 <span class="comment">        int n;</span> 
     95<a name="l00143"></a>00143 <span class="comment">        vec &amp;w;</span> 
     96<a name="l00144"></a>00144 <span class="comment">        Array&lt;epdf*&gt; Coms;</span> 
     97<a name="l00145"></a>00145 <span class="comment">public:</span> 
     98<a name="l00147"></a>00147 <span class="comment">        emix ( const RV &amp;rv, vec &amp;w0): epdf(rv), n(w0.length()), w(w0), Coms(n) {};</span> 
     99<a name="l00148"></a>00148 <span class="comment">        void set_parameters( int &amp;i, double wi, epdf* ep){w(i)=wi;Coms(i)=ep;}</span> 
     100<a name="l00149"></a>00149 <span class="comment">        vec mean(){vec pom; for(int i=0;i&lt;n;i++){pom+=Coms(i)-&gt;mean()*w(i);} return pom;};</span> 
     101<a name="l00150"></a>00150 <span class="comment">        vec sample() {it_error ( "Not implemented" );return 0;}</span> 
     102<a name="l00151"></a>00151 <span class="comment">};</span> 
     103<a name="l00152"></a>00152 <span class="comment">*/</span> 
     104<a name="l00153"></a>00153  
     105<a name="l00155"></a>00155  
     106<a name="l00156"></a><a class="code" href="classeuni.html">00156</a> <span class="keyword">class </span><a class="code" href="classeuni.html" title="Uniform distributed density on a rectangular support.">euni</a>: <span class="keyword">public</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> { 
     107<a name="l00157"></a>00157 <span class="keyword">protected</span>: 
     108<a name="l00159"></a><a class="code" href="classeuni.html#ef42cd8d7645422048d46c46ec5cdac1">00159</a>         vec <a class="code" href="classeuni.html#ef42cd8d7645422048d46c46ec5cdac1" title="lower bound on support">low</a>; 
     109<a name="l00161"></a><a class="code" href="classeuni.html#71b6d6b41aeb61a7f76f682b72119231">00161</a>         vec <a class="code" href="classeuni.html#71b6d6b41aeb61a7f76f682b72119231" title="upper bound on support">high</a>; 
     110<a name="l00163"></a><a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4">00163</a>         vec <a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a>; 
     111<a name="l00165"></a><a class="code" href="classeuni.html#63105490e946e43372d6187ad1bafdda">00165</a>         <span class="keywordtype">double</span> <a class="code" href="classeuni.html#63105490e946e43372d6187ad1bafdda" title="normalizing coefficients">nk</a>; 
     112<a name="l00167"></a><a class="code" href="classeuni.html#f445a0ce24f39d14c1a4eed53fc8e2c3">00167</a>         <span class="keywordtype">double</span> <a class="code" href="classeuni.html#f445a0ce24f39d14c1a4eed53fc8e2c3" title="cache of log( nk )">lnk</a>; 
     113<a name="l00168"></a>00168 <span class="keyword">public</span>: 
     114<a name="l00170"></a><a class="code" href="classeuni.html#2537a6c239cff52e3ba814851a1116cd">00170</a>         <a class="code" href="classeuni.html#2537a6c239cff52e3ba814851a1116cd" title="Defualt constructor.">euni</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> ) :<a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( rv ) {} 
     115<a name="l00171"></a><a class="code" href="classeuni.html#2723d4992900b5c5495bfa03628195ed">00171</a>         <span class="keywordtype">double</span> <a class="code" href="classeuni.html#2723d4992900b5c5495bfa03628195ed" title="Compute probability of argument val.">eval</a> ( <span class="keyword">const</span> vec &amp;val )<span class="keyword"> const  </span>{<span class="keywordflow">return</span> <a class="code" href="classeuni.html#63105490e946e43372d6187ad1bafdda" title="normalizing coefficients">nk</a>;} 
     116<a name="l00172"></a><a class="code" href="classeuni.html#06af95d514a6623ad4688bd2ad50ad71">00172</a>         <span class="keywordtype">double</span> <a class="code" href="classeuni.html#06af95d514a6623ad4688bd2ad50ad71" title="Compute log-probability of argument val.">evalpdflog</a> ( <span class="keyword">const</span> vec &amp;val )<span class="keyword"> const  </span>{<span class="keywordflow">return</span> <a class="code" href="classeuni.html#f445a0ce24f39d14c1a4eed53fc8e2c3" title="cache of log( nk )">lnk</a>;} 
     117<a name="l00173"></a><a class="code" href="classeuni.html#4a0e09392be17beaee120ba98fc038cd">00173</a>         vec <a class="code" href="classeuni.html#4a0e09392be17beaee120ba98fc038cd" title="Returns the required moment of the epdf.">sample</a>()<span class="keyword"> const </span>{ 
     118<a name="l00174"></a>00174                 vec smp ( <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return length (number of scalars) of the RV.">count</a>() ); UniRNG.sample_vector ( <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return length (number of scalars) of the RV.">count</a>(),smp ); 
     119<a name="l00175"></a>00175                 <span class="keywordflow">return</span> <a class="code" href="classeuni.html#ef42cd8d7645422048d46c46ec5cdac1" title="lower bound on support">low</a>+<a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a>*smp; 
     120<a name="l00176"></a>00176         } 
     121<a name="l00178"></a><a class="code" href="classeuni.html#4fd7c6a05100616ad16ece405cad7bf2">00178</a>         <span class="keywordtype">void</span> <a class="code" href="classeuni.html#4fd7c6a05100616ad16ece405cad7bf2" title="set values of low and high ">set_parameters</a> ( <span class="keyword">const</span> vec &amp;low0, <span class="keyword">const</span> vec &amp;high0 ) { 
     122<a name="l00179"></a>00179                 <a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a> = high0-low0; 
     123<a name="l00180"></a>00180                 it_assert_debug ( min ( <a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a> ) &gt;0.0,<span class="stringliteral">"bad support"</span> ); 
     124<a name="l00181"></a>00181                 <a class="code" href="classeuni.html#ef42cd8d7645422048d46c46ec5cdac1" title="lower bound on support">low</a> = low0; 
     125<a name="l00182"></a>00182                 <a class="code" href="classeuni.html#71b6d6b41aeb61a7f76f682b72119231" title="upper bound on support">high</a> = high0; 
     126<a name="l00183"></a>00183                 <a class="code" href="classeuni.html#63105490e946e43372d6187ad1bafdda" title="normalizing coefficients">nk</a> = prod ( 1.0/<a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a> ); 
     127<a name="l00184"></a>00184                 <a class="code" href="classeuni.html#f445a0ce24f39d14c1a4eed53fc8e2c3" title="cache of log( nk )">lnk</a> = log ( <a class="code" href="classeuni.html#63105490e946e43372d6187ad1bafdda" title="normalizing coefficients">nk</a> ); 
     128<a name="l00185"></a>00185         } 
     129<a name="l00186"></a><a class="code" href="classeuni.html#8050087e421a9cfd1b4b1f8bd33b1cc1">00186</a>         vec <a class="code" href="classeuni.html#8050087e421a9cfd1b4b1f8bd33b1cc1" title="return expected value">mean</a>()<span class="keyword"> const </span>{vec pom=<a class="code" href="classeuni.html#71b6d6b41aeb61a7f76f682b72119231" title="upper bound on support">high</a>; pom-=<a class="code" href="classeuni.html#ef42cd8d7645422048d46c46ec5cdac1" title="lower bound on support">low</a>; pom/=2.0; <span class="keywordflow">return</span> pom;} 
     130<a name="l00187"></a>00187 }; 
     131<a name="l00188"></a>00188  
     132<a name="l00189"></a>00189  
     133<a name="l00195"></a>00195 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     134<a name="l00196"></a><a class="code" href="classmlnorm.html">00196</a> <span class="keyword">class </span><a class="code" href="classmlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm</a> : <span class="keyword">public</span> <a class="code" href="classmEF.html" title="Exponential family model.">mEF</a> { 
     135<a name="l00198"></a>00198         <a class="code" href="classenorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm&lt;sq_T&gt;</a> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>; 
     136<a name="l00199"></a>00199         vec&amp; _mu; <span class="comment">//cached epdf.mu;</span> 
     137<a name="l00200"></a>00200         mat A; 
     138<a name="l00201"></a>00201 <span class="keyword">public</span>: 
     139<a name="l00203"></a>00203         <a class="code" href="classmlnorm.html#f927203b3f31171c5c10ffc7caa797f5" title="Constructor.">mlnorm</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;<a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>,<a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;<a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab" title="random variable in condition">rvc</a> ); 
     140<a name="l00205"></a>00205         <span class="keywordtype">void</span> <a class="code" href="classmlnorm.html#b6749030c5d5abcb3eb6898f74cea3c0" title="Set A and R.">set_parameters</a> ( <span class="keyword">const</span>  mat &amp;A, <span class="keyword">const</span> sq_T &amp;R ); 
     141<a name="l00207"></a>00207         vec <a class="code" href="classmlnorm.html#decf3e3b5c8e0812e5b4dbe94fa2ae18" title="Generate one sample of the posterior.">samplecond</a> ( vec &amp;cond, <span class="keywordtype">double</span> &amp;lik ); 
     142<a name="l00209"></a>00209         mat <a class="code" href="classmlnorm.html#decf3e3b5c8e0812e5b4dbe94fa2ae18" title="Generate one sample of the posterior.">samplecond</a> ( vec &amp;cond, vec &amp;lik, <span class="keywordtype">int</span> n ); 
     143<a name="l00211"></a>00211         <span class="keywordtype">void</span> <a class="code" href="classmlnorm.html#5232fc7e305eceab4e2bd6a8daa44195" title="Set value of rvc . Result of this operation is stored in epdf use function _ep to...">condition</a> ( vec &amp;cond ); 
     144<a name="l00212"></a>00212 }; 
     145<a name="l00213"></a>00213  
     146<a name="l00223"></a><a class="code" href="classmgamma.html">00223</a> <span class="keyword">class </span><a class="code" href="classmgamma.html" title="Gamma random walk.">mgamma</a> : <span class="keyword">public</span> <a class="code" href="classmEF.html" title="Exponential family model.">mEF</a> { 
     147<a name="l00224"></a>00224 <span class="keyword">protected</span>: 
     148<a name="l00226"></a><a class="code" href="classmgamma.html#612dbf35c770a780027619aaac2c443e">00226</a>         <a class="code" href="classegamma.html" title="Gamma posterior density.">egamma</a> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>; 
     149<a name="l00228"></a><a class="code" href="classmgamma.html#43f733cce0245a52363d566099add687">00228</a>         <span class="keywordtype">double</span> <a class="code" href="classmgamma.html#43f733cce0245a52363d566099add687" title="Constant $k$.">k</a>; 
     150<a name="l00230"></a><a class="code" href="classmgamma.html#5e90652837448bcc29707e7412f99691">00230</a>         vec* <a class="code" href="classmgamma.html#5e90652837448bcc29707e7412f99691" title="cache of epdf.beta">_beta</a>; 
     151<a name="l00231"></a>00231  
     152<a name="l00232"></a>00232 <span class="keyword">public</span>: 
     153<a name="l00234"></a>00234         <a class="code" href="classmgamma.html#af43e61b86900c0398d5c0ffc83b94e6" title="Constructor.">mgamma</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;<a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>,<span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;<a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab" title="random variable in condition">rvc</a> ); 
     154<a name="l00236"></a>00236         <span class="keywordtype">void</span> <a class="code" href="classmgamma.html#a9d646cf758a70126dde7c48790b6e94" title="Set value of k.">set_parameters</a> ( <span class="keywordtype">double</span> <a class="code" href="classmgamma.html#43f733cce0245a52363d566099add687" title="Constant $k$.">k</a> ); 
     155<a name="l00238"></a>00238         vec <a class="code" href="classmgamma.html#9f40dc43885085fad8e3d6652b79e139" title="Generate one sample of the posterior.">samplecond</a> ( vec &amp;cond, <span class="keywordtype">double</span> &amp;lik ); 
     156<a name="l00240"></a>00240         mat <a class="code" href="classmgamma.html#9f40dc43885085fad8e3d6652b79e139" title="Generate one sample of the posterior.">samplecond</a> ( vec &amp;cond, vec &amp;lik, <span class="keywordtype">int</span> n ); 
     157<a name="l00241"></a><a class="code" href="classmgamma.html#a61094c9f7a2d64ea77b130cbc031f97">00241</a>         <span class="keywordtype">void</span> <a class="code" href="classmgamma.html#a61094c9f7a2d64ea77b130cbc031f97" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a> ( <span class="keyword">const</span> vec &amp;val ) {*<a class="code" href="classmgamma.html#5e90652837448bcc29707e7412f99691" title="cache of epdf.beta">_beta</a>=<a class="code" href="classmgamma.html#43f733cce0245a52363d566099add687" title="Constant $k$.">k</a>/val;}; 
     158<a name="l00242"></a>00242 }; 
     159<a name="l00243"></a>00243  
     160<a name="l00255"></a><a class="code" href="classmgamma__fix.html">00255</a> <span class="keyword">class </span><a class="code" href="classmgamma__fix.html" title="Gamma random walk around a fixed point.">mgamma_fix</a> : <span class="keyword">public</span> <a class="code" href="classmgamma.html" title="Gamma random walk.">mgamma</a> { 
     161<a name="l00256"></a>00256 <span class="keyword">protected</span>: 
     162<a name="l00257"></a>00257         <span class="keywordtype">double</span> l; 
     163<a name="l00258"></a>00258         vec refl; 
     164<a name="l00259"></a>00259 <span class="keyword">public</span>: 
     165<a name="l00261"></a><a class="code" href="classmgamma__fix.html#b92c3d2e5fd0381033a072e5ef3bcf80">00261</a>         <a class="code" href="classmgamma__fix.html#b92c3d2e5fd0381033a072e5ef3bcf80" title="Constructor.">mgamma_fix</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;<a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>,<span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;<a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab" title="random variable in condition">rvc</a> ) : <a class="code" href="classmgamma.html" title="Gamma random walk.">mgamma</a> ( rv,rvc ),refl ( rv.count() ) {}; 
     166<a name="l00263"></a><a class="code" href="classmgamma__fix.html#ec6f846896749e27cb7be9fa48dd1cb1">00263</a>         <span class="keywordtype">void</span> <a class="code" href="classmgamma__fix.html#ec6f846896749e27cb7be9fa48dd1cb1" title="Set value of k.">set_parameters</a> ( <span class="keywordtype">double</span> k0 , vec ref0, <span class="keywordtype">double</span> l0 ) { 
     167<a name="l00264"></a>00264                 <a class="code" href="classmgamma.html#a9d646cf758a70126dde7c48790b6e94" title="Set value of k.">mgamma::set_parameters</a> ( k0 ); 
     168<a name="l00265"></a>00265                 refl=pow ( ref0,1.0-l0 );l=l0; 
     169<a name="l00266"></a>00266         }; 
     170<a name="l00267"></a>00267  
     171<a name="l00268"></a><a class="code" href="classmgamma__fix.html#6ea3931eec7b7da7b693e45981052460">00268</a>         <span class="keywordtype">void</span> <a class="code" href="classmgamma__fix.html#6ea3931eec7b7da7b693e45981052460" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a> ( <span class="keyword">const</span> vec &amp;val ) {vec mean=elem_mult ( refl,pow ( val,l ) ); *<a class="code" href="classmgamma.html#5e90652837448bcc29707e7412f99691" title="cache of epdf.beta">_beta</a>=<a class="code" href="classmgamma.html#43f733cce0245a52363d566099add687" title="Constant $k$.">k</a>/mean;}; 
     172<a name="l00269"></a>00269 }; 
     173<a name="l00270"></a>00270  
     174<a name="l00272"></a><a class="code" href="libEF_8h.html#99497a3ff630f761cf6bff7babd23212">00272</a> <span class="keyword">enum</span> <a class="code" href="libEF_8h.html#99497a3ff630f761cf6bff7babd23212" title="Switch between various resampling methods.">RESAMPLING_METHOD</a> { MULTINOMIAL = 0, STRATIFIED = 1, SYSTEMATIC = 3 }; 
     175<a name="l00278"></a><a class="code" href="classeEmp.html">00278</a> <span class="keyword">class </span><a class="code" href="classeEmp.html" title="Weighted empirical density.">eEmp</a>: <span class="keyword">public</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> { 
     176<a name="l00279"></a>00279 <span class="keyword">protected</span> : 
     177<a name="l00281"></a><a class="code" href="classeEmp.html#8c33034de0e35f03f8bb85d3d67438fd">00281</a>         <span class="keywordtype">int</span> <a class="code" href="classeEmp.html#8c33034de0e35f03f8bb85d3d67438fd" title="Number of particles.">n</a>; 
     178<a name="l00283"></a><a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8">00283</a>         vec <a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8" title="Sample weights $w$.">w</a>; 
     179<a name="l00285"></a><a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a">00285</a>         Array&lt;vec&gt; <a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a" title="Samples .">samples</a>; 
     180<a name="l00286"></a>00286 <span class="keyword">public</span>: 
     181<a name="l00288"></a><a class="code" href="classeEmp.html#0c04b073ecd0dae3d498e680ae27e9e4">00288</a>         <a class="code" href="classeEmp.html#0c04b073ecd0dae3d498e680ae27e9e4" title="Default constructor.">eEmp</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rv0 ,<span class="keywordtype">int</span> n0 ) :<a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( rv0 ),<a class="code" href="classeEmp.html#8c33034de0e35f03f8bb85d3d67438fd" title="Number of particles.">n</a> ( n0 ),<a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8" title="Sample weights $w$.">w</a> ( <a class="code" href="classeEmp.html#8c33034de0e35f03f8bb85d3d67438fd" title="Number of particles.">n</a> ),<a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a" title="Samples .">samples</a> ( <a class="code" href="classeEmp.html#8c33034de0e35f03f8bb85d3d67438fd" title="Number of particles.">n</a> ) {}; 
     182<a name="l00290"></a>00290         <span class="keywordtype">void</span> <a class="code" href="classeEmp.html#6606a656c1b28114f7384c25aaf80e8d" title="Set sample.">set_parameters</a> ( <span class="keyword">const</span> vec &amp;w0, <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* pdf0 ); 
     183<a name="l00292"></a><a class="code" href="classeEmp.html#31b2bfb73b72486a5c89f2ab850c7a9b">00292</a>         vec&amp; <a class="code" href="classeEmp.html#31b2bfb73b72486a5c89f2ab850c7a9b" title="Potentially dangerous, use with care.">_w</a>()  {<span class="keywordflow">return</span> <a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8" title="Sample weights $w$.">w</a>;}; 
     184<a name="l00294"></a><a class="code" href="classeEmp.html#31b747eca73b16f30370827ba4cc3575">00294</a>         Array&lt;vec&gt;&amp; <a class="code" href="classeEmp.html#31b747eca73b16f30370827ba4cc3575" title="access function">_samples</a>() {<span class="keywordflow">return</span> <a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a" title="Samples .">samples</a>;}; 
     185<a name="l00296"></a>00296         ivec <a class="code" href="classeEmp.html#77268292fc4465cb73ddbfb1f2932a59" title="Function performs resampling, i.e. removal of low-weight samples and duplication...">resample</a> ( <a class="code" href="libEF_8h.html#99497a3ff630f761cf6bff7babd23212" title="Switch between various resampling methods.">RESAMPLING_METHOD</a> method = SYSTEMATIC ); 
     186<a name="l00298"></a><a class="code" href="classeEmp.html#83f9283f92b805508d896479dc1ccf12">00298</a>         vec <a class="code" href="classeEmp.html#83f9283f92b805508d896479dc1ccf12" title="inherited operation : NOT implemneted">sample</a>()<span class="keyword"> const </span>{it_error ( <span class="stringliteral">"Not implemented"</span> );<span class="keywordflow">return</span> 0;} 
     187<a name="l00300"></a><a class="code" href="classeEmp.html#23e7358995400865ad2e278945922fb3">00300</a>         <span class="keywordtype">double</span> <a class="code" href="classeEmp.html#23e7358995400865ad2e278945922fb3" title="inherited operation : NOT implemneted">evalpdflog</a> ( <span class="keyword">const</span> vec &amp;val )<span class="keyword"> const </span>{it_error ( <span class="stringliteral">"Not implemented"</span> );<span class="keywordflow">return</span> 0.0;} 
     188<a name="l00301"></a><a class="code" href="classeEmp.html#ba055c19038cc72628d98e25197e982d">00301</a>         vec <a class="code" href="classeEmp.html#ba055c19038cc72628d98e25197e982d" title="return expected value">mean</a>()<span class="keyword"> const </span>{ 
     189<a name="l00302"></a>00302                 vec pom=zeros ( <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return length (number of scalars) of the RV.">count</a>() ); 
     190<a name="l00303"></a>00303                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i&lt;<a class="code" href="classeEmp.html#8c33034de0e35f03f8bb85d3d67438fd" title="Number of particles.">n</a>;i++ ) {pom+=<a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a" title="Samples .">samples</a> ( i ) *<a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8" title="Sample weights $w$.">w</a> ( i );} 
     191<a name="l00304"></a>00304                 <span class="keywordflow">return</span> pom; 
     192<a name="l00305"></a>00305         } 
     193<a name="l00306"></a>00306 }; 
     194<a name="l00307"></a>00307  
    206195<a name="l00308"></a>00308  
    207 <a name="l00309"></a>00309 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    208 <a name="l00310"></a><a class="code" href="classenorm.html#60b47544f6181ffd4530d3e415ce12c5">00310</a> vec <a class="code" href="classenorm.html#60b47544f6181ffd4530d3e415ce12c5" title="Returns the required moment of the epdf.">enorm&lt;sq_T&gt;::sample</a>()<span class="keyword"> const </span>{ 
    209 <a name="l00311"></a>00311         vec x ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a> ); 
    210 <a name="l00312"></a>00312         NorRNG.sample_vector ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a>,x ); 
    211 <a name="l00313"></a>00313         vec smp = <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.sqrt_mult ( x ); 
    212 <a name="l00314"></a>00314  
    213 <a name="l00315"></a>00315         smp += <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>; 
    214 <a name="l00316"></a>00316         <span class="keywordflow">return</span> smp; 
    215 <a name="l00317"></a>00317 }; 
    216 <a name="l00318"></a>00318  
    217 <a name="l00319"></a>00319 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    218 <a name="l00320"></a><a class="code" href="classenorm.html#60f0f3bfa53d6e65843eea9532b16d36">00320</a> mat <a class="code" href="classenorm.html#60b47544f6181ffd4530d3e415ce12c5" title="Returns the required moment of the epdf.">enorm&lt;sq_T&gt;::sample</a> ( <span class="keywordtype">int</span> N )<span class="keyword">const </span>{ 
    219 <a name="l00321"></a>00321         mat X ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a>,N ); 
    220 <a name="l00322"></a>00322         vec x ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a> ); 
    221 <a name="l00323"></a>00323         vec pom; 
    222 <a name="l00324"></a>00324         <span class="keywordtype">int</span> i; 
     196<a name="l00310"></a>00310  
     197<a name="l00311"></a>00311 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     198<a name="l00312"></a><a class="code" href="classenorm.html#7b5cb487a2570e8109bfdc0df149aa06">00312</a> <a class="code" href="classenorm.html#7b5cb487a2570e8109bfdc0df149aa06" title="Default constructor.">enorm&lt;sq_T&gt;::enorm</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rv ) :<a class="code" href="classeEF.html" title="General conjugate exponential family posterior density.">eEF</a> ( rv ), mu ( rv.count() ),R ( rv.count() ),dim ( rv.count() ) {}; 
     199<a name="l00313"></a>00313  
     200<a name="l00314"></a>00314 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     201<a name="l00315"></a><a class="code" href="classenorm.html#1394a65caa6e00d42e00cc99b12227af">00315</a> <span class="keywordtype">void</span> <a class="code" href="classenorm.html#1394a65caa6e00d42e00cc99b12227af" title="Set mean value mu and covariance R.">enorm&lt;sq_T&gt;::set_parameters</a> ( <span class="keyword">const</span> vec &amp;mu0, <span class="keyword">const</span> sq_T &amp;R0 ) { 
     202<a name="l00316"></a>00316 <span class="comment">//Fixme test dimensions of mu0 and R0;</span> 
     203<a name="l00317"></a>00317         <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a> = mu0; 
     204<a name="l00318"></a>00318         <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a> = R0; 
     205<a name="l00319"></a>00319 }; 
     206<a name="l00320"></a>00320  
     207<a name="l00321"></a>00321 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     208<a name="l00322"></a><a class="code" href="classenorm.html#5bf185e31e5954fceb90ada3debd2ff2">00322</a> <span class="keywordtype">void</span> <a class="code" href="classenorm.html#5bf185e31e5954fceb90ada3debd2ff2" title="dupdate in exponential form (not really handy)">enorm&lt;sq_T&gt;::dupdate</a> ( mat &amp;v, <span class="keywordtype">double</span> nu ) { 
     209<a name="l00323"></a>00323         <span class="comment">//</span> 
     210<a name="l00324"></a>00324 }; 
    223211<a name="l00325"></a>00325  
    224 <a name="l00326"></a>00326         <span class="keywordflow">for</span> ( i=0;i&lt;N;i++ ) { 
    225 <a name="l00327"></a>00327                 NorRNG.sample_vector ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a>,x ); 
    226 <a name="l00328"></a>00328                 pom = <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.sqrt_mult ( x ); 
    227 <a name="l00329"></a>00329                 pom +=<a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>; 
    228 <a name="l00330"></a>00330                 X.set_col ( i, pom ); 
    229 <a name="l00331"></a>00331         } 
    230 <a name="l00332"></a>00332  
    231 <a name="l00333"></a>00333         <span class="keywordflow">return</span> X; 
    232 <a name="l00334"></a>00334 }; 
    233 <a name="l00335"></a>00335  
    234 <a name="l00336"></a>00336 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    235 <a name="l00337"></a><a class="code" href="classenorm.html#b9e1dfd33692d7b3f1a59f17b0e61bd0">00337</a> <span class="keywordtype">double</span> <a class="code" href="classenorm.html#b9e1dfd33692d7b3f1a59f17b0e61bd0" title="Compute probability of argument val.">enorm&lt;sq_T&gt;::eval</a> ( <span class="keyword">const</span> vec &amp;val )<span class="keyword"> const </span>{ 
    236 <a name="l00338"></a>00338         <span class="keywordtype">double</span> pdfl,e; 
    237 <a name="l00339"></a>00339         pdfl = <a class="code" href="classenorm.html#609a7c33dbb4fdfab050f3bdd1122401" title="Compute log-probability of argument val.">evalpdflog</a> ( val ); 
    238 <a name="l00340"></a>00340         e = exp ( pdfl ); 
    239 <a name="l00341"></a>00341         <span class="keywordflow">return</span> e; 
    240 <a name="l00342"></a>00342 }; 
    241 <a name="l00343"></a>00343  
    242 <a name="l00344"></a>00344 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    243 <a name="l00345"></a><a class="code" href="classenorm.html#609a7c33dbb4fdfab050f3bdd1122401">00345</a> <span class="keywordtype">double</span> <a class="code" href="classenorm.html#609a7c33dbb4fdfab050f3bdd1122401" title="Compute log-probability of argument val.">enorm&lt;sq_T&gt;::evalpdflog</a> ( <span class="keyword">const</span> vec &amp;val )<span class="keyword"> const </span>{ 
    244 <a name="l00346"></a>00346         <span class="keywordflow">if</span> ( !<a class="code" href="classenorm.html#ae12db77283a96e0f14a3eae93dc3bf1" title="indicator if _iR is chached">cached</a> ) {it_error(<span class="stringliteral">"this should not happen, see cached"</span>);} 
     212<a name="l00326"></a>00326 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     213<a name="l00327"></a><a class="code" href="classenorm.html#5b5fd142b6b17ea334597960e3fe126a">00327</a> <span class="keywordtype">void</span> <a class="code" href="classenorm.html#5b5fd142b6b17ea334597960e3fe126a" title="tupdate in exponential form (not really handy)">enorm&lt;sq_T&gt;::tupdate</a> ( <span class="keywordtype">double</span> phi, mat &amp;vbar, <span class="keywordtype">double</span> nubar ) { 
     214<a name="l00328"></a>00328         <span class="comment">//</span> 
     215<a name="l00329"></a>00329 }; 
     216<a name="l00330"></a>00330  
     217<a name="l00331"></a>00331 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     218<a name="l00332"></a><a class="code" href="classenorm.html#60b47544f6181ffd4530d3e415ce12c5">00332</a> vec <a class="code" href="classenorm.html#60b47544f6181ffd4530d3e415ce12c5" title="Returns the required moment of the epdf.">enorm&lt;sq_T&gt;::sample</a>()<span class="keyword"> const </span>{ 
     219<a name="l00333"></a>00333         vec x ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a> ); 
     220<a name="l00334"></a>00334         NorRNG.sample_vector ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a>,x ); 
     221<a name="l00335"></a>00335         vec smp = <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.sqrt_mult ( x ); 
     222<a name="l00336"></a>00336  
     223<a name="l00337"></a>00337         smp += <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>; 
     224<a name="l00338"></a>00338         <span class="keywordflow">return</span> smp; 
     225<a name="l00339"></a>00339 }; 
     226<a name="l00340"></a>00340  
     227<a name="l00341"></a>00341 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     228<a name="l00342"></a><a class="code" href="classenorm.html#60f0f3bfa53d6e65843eea9532b16d36">00342</a> mat <a class="code" href="classenorm.html#60b47544f6181ffd4530d3e415ce12c5" title="Returns the required moment of the epdf.">enorm&lt;sq_T&gt;::sample</a> ( <span class="keywordtype">int</span> N )<span class="keyword"> const </span>{ 
     229<a name="l00343"></a>00343         mat X ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a>,N ); 
     230<a name="l00344"></a>00344         vec x ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a> ); 
     231<a name="l00345"></a>00345         vec pom; 
     232<a name="l00346"></a>00346         <span class="keywordtype">int</span> i; 
    245233<a name="l00347"></a>00347  
    246 <a name="l00348"></a>00348         <span class="comment">// 1.83787706640935 = log(2pi)</span> 
    247 <a name="l00349"></a>00349         <span class="keywordflow">return</span> -0.5* ( <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.cols() * 1.83787706640935 +<a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.logdet() +<a class="code" href="classenorm.html#82f39ac49911d7097f4bfe385deba355" title="Cache: _iR = inv(R);.">_iR</a>.qform ( <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>-val ) ); 
    248 <a name="l00350"></a>00350 }; 
    249 <a name="l00351"></a>00351  
    250 <a name="l00352"></a>00352  
    251 <a name="l00353"></a>00353 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    252 <a name="l00354"></a><a class="code" href="classmlnorm.html#f927203b3f31171c5c10ffc7caa797f5">00354</a> <a class="code" href="classmlnorm.html#f927203b3f31171c5c10ffc7caa797f5" title="Constructor.">mlnorm&lt;sq_T&gt;::mlnorm</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rv0,<a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rvc0 ) :<a class="code" href="classmEF.html" title="Exponential family model.">mEF</a> ( rv0,rvc0 ),<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#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ),A ( rv0.count(),rv0.count() ) { 
    253 <a name="l00355"></a>00355         _mu = <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>._mu(); 
    254 <a name="l00356"></a>00356 } 
     234<a name="l00348"></a>00348         <span class="keywordflow">for</span> ( i=0;i&lt;N;i++ ) { 
     235<a name="l00349"></a>00349                 NorRNG.sample_vector ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a>,x ); 
     236<a name="l00350"></a>00350                 pom = <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.sqrt_mult ( x ); 
     237<a name="l00351"></a>00351                 pom +=<a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>; 
     238<a name="l00352"></a>00352                 X.set_col ( i, pom ); 
     239<a name="l00353"></a>00353         } 
     240<a name="l00354"></a>00354  
     241<a name="l00355"></a>00355         <span class="keywordflow">return</span> X; 
     242<a name="l00356"></a>00356 }; 
    255243<a name="l00357"></a>00357  
    256244<a name="l00358"></a>00358 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    257 <a name="l00359"></a><a class="code" href="classmlnorm.html#b6749030c5d5abcb3eb6898f74cea3c0">00359</a> <span class="keywordtype">void</span> <a class="code" href="classmlnorm.html#b6749030c5d5abcb3eb6898f74cea3c0" title="Set A and R.">mlnorm&lt;sq_T&gt;::set_parameters</a> ( <span class="keyword">const</span> mat &amp;A0, <span class="keyword">const</span> sq_T &amp;R0 ) { 
    258 <a name="l00360"></a>00360         <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.set_parameters ( zeros ( <a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return length (number of scalars) of the RV.">count</a>() ),R0 ); 
    259 <a name="l00361"></a>00361         A = A0; 
    260 <a name="l00362"></a>00362 } 
    261 <a name="l00363"></a>00363  
    262 <a name="l00364"></a>00364 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    263 <a name="l00365"></a><a class="code" href="classmlnorm.html#decf3e3b5c8e0812e5b4dbe94fa2ae18">00365</a> vec <a class="code" href="classmlnorm.html#decf3e3b5c8e0812e5b4dbe94fa2ae18" title="Generate one sample of the posterior.">mlnorm&lt;sq_T&gt;::samplecond</a> ( vec &amp;cond, <span class="keywordtype">double</span> &amp;lik ) { 
    264 <a name="l00366"></a>00366         this-&gt;<a class="code" href="classmlnorm.html#5232fc7e305eceab4e2bd6a8daa44195" title="Set value of rvc . Result of this operation is stored in epdf use function _ep to...">condition</a> ( cond ); 
    265 <a name="l00367"></a>00367         vec smp = <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.sample(); 
    266 <a name="l00368"></a>00368         lik = <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.eval ( smp ); 
    267 <a name="l00369"></a>00369         <span class="keywordflow">return</span> smp; 
    268 <a name="l00370"></a>00370 } 
     245<a name="l00359"></a><a class="code" href="classenorm.html#b9e1dfd33692d7b3f1a59f17b0e61bd0">00359</a> <span class="keywordtype">double</span> <a class="code" href="classenorm.html#b9e1dfd33692d7b3f1a59f17b0e61bd0" title="Compute probability of argument val.">enorm&lt;sq_T&gt;::eval</a> ( <span class="keyword">const</span> vec &amp;val )<span class="keyword"> const </span>{ 
     246<a name="l00360"></a>00360         <span class="keywordtype">double</span> pdfl,e; 
     247<a name="l00361"></a>00361         pdfl = <a class="code" href="classenorm.html#609a7c33dbb4fdfab050f3bdd1122401" title="Compute log-probability of argument val.">evalpdflog</a> ( val ); 
     248<a name="l00362"></a>00362         e = exp ( pdfl ); 
     249<a name="l00363"></a>00363         <span class="keywordflow">return</span> e; 
     250<a name="l00364"></a>00364 }; 
     251<a name="l00365"></a>00365  
     252<a name="l00366"></a>00366 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     253<a name="l00367"></a><a class="code" href="classenorm.html#609a7c33dbb4fdfab050f3bdd1122401">00367</a> <span class="keywordtype">double</span> <a class="code" href="classenorm.html#609a7c33dbb4fdfab050f3bdd1122401" title="Compute log-probability of argument val.">enorm&lt;sq_T&gt;::evalpdflog</a> ( <span class="keyword">const</span> vec &amp;val )<span class="keyword"> const </span>{ 
     254<a name="l00368"></a>00368         <span class="comment">// 1.83787706640935 = log(2pi)</span> 
     255<a name="l00369"></a>00369         <span class="keywordflow">return</span> -0.5* ( <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.cols() * 1.83787706640935 +<a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.logdet() +<a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.invqform ( <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>-val ) ); 
     256<a name="l00370"></a>00370 }; 
    269257<a name="l00371"></a>00371  
    270 <a name="l00372"></a>00372 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    271 <a name="l00373"></a><a class="code" href="classmlnorm.html#215fb88cc8b95d64cdefd6849abdd1e8">00373</a> mat <a class="code" href="classmlnorm.html#decf3e3b5c8e0812e5b4dbe94fa2ae18" title="Generate one sample of the posterior.">mlnorm&lt;sq_T&gt;::samplecond</a> ( vec &amp;cond, vec &amp;lik, <span class="keywordtype">int</span> n ) { 
    272 <a name="l00374"></a>00374         <span class="keywordtype">int</span> i; 
    273 <a name="l00375"></a>00375         <span class="keywordtype">int</span> dim = <a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return length (number of scalars) of the RV.">count</a>(); 
    274 <a name="l00376"></a>00376         mat Smp ( dim,n ); 
    275 <a name="l00377"></a>00377         vec smp ( dim ); 
    276 <a name="l00378"></a>00378         this-&gt;<a class="code" href="classmlnorm.html#5232fc7e305eceab4e2bd6a8daa44195" title="Set value of rvc . Result of this operation is stored in epdf use function _ep to...">condition</a> ( cond ); 
    277 <a name="l00379"></a>00379  
    278 <a name="l00380"></a>00380         <span class="keywordflow">for</span> ( i=0; i&lt;n; i++ ) { 
    279 <a name="l00381"></a>00381                 smp = <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.sample(); 
    280 <a name="l00382"></a>00382                 lik ( i ) = <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.eval ( smp ); 
    281 <a name="l00383"></a>00383                 Smp.set_col ( i ,smp ); 
    282 <a name="l00384"></a>00384         } 
    283 <a name="l00385"></a>00385  
    284 <a name="l00386"></a>00386         <span class="keywordflow">return</span> Smp; 
    285 <a name="l00387"></a>00387 } 
    286 <a name="l00388"></a>00388  
    287 <a name="l00389"></a>00389 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    288 <a name="l00390"></a><a class="code" href="classmlnorm.html#5232fc7e305eceab4e2bd6a8daa44195">00390</a> <span class="keywordtype">void</span> <a class="code" href="classmlnorm.html#5232fc7e305eceab4e2bd6a8daa44195" title="Set value of rvc . Result of this operation is stored in epdf use function _ep to...">mlnorm&lt;sq_T&gt;::condition</a> ( vec &amp;cond ) { 
    289 <a name="l00391"></a>00391         *_mu = A*cond; 
    290 <a name="l00392"></a>00392 <span class="comment">//R is already assigned;</span> 
    291 <a name="l00393"></a>00393 } 
    292 <a name="l00394"></a>00394  
    293 <a name="l00396"></a>00396  
    294 <a name="l00397"></a>00397  
    295 <a name="l00398"></a>00398 <span class="preprocessor">#endif //EF_H</span> 
    296 </pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Wed Mar 12 16:15:45 2008 for mixpp by&nbsp; 
     258<a name="l00372"></a>00372  
     259<a name="l00373"></a>00373 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     260<a name="l00374"></a><a class="code" href="classmlnorm.html#f927203b3f31171c5c10ffc7caa797f5">00374</a> <a class="code" href="classmlnorm.html#f927203b3f31171c5c10ffc7caa797f5" title="Constructor.">mlnorm&lt;sq_T&gt;::mlnorm</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rv0,<a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;rvc0 ) :<a class="code" href="classmEF.html" title="Exponential family model.">mEF</a> ( rv0,rvc0 ),<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#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ),A ( rv0.count(),rv0.count() ),<a class="code" href="classenorm.html#0b8cb284e5af920a1b64a21d057ec5ac" title="returns a pointer to the internal mean value. Use with Care!">_mu</a>(<a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.<a class="code" href="classenorm.html#0b8cb284e5af920a1b64a21d057ec5ac" title="returns a pointer to the internal mean value. Use with Care!">_mu</a>()) { 
     261<a name="l00375"></a>00375 } 
     262<a name="l00376"></a>00376  
     263<a name="l00377"></a>00377 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     264<a name="l00378"></a><a class="code" href="classmlnorm.html#b6749030c5d5abcb3eb6898f74cea3c0">00378</a> <span class="keywordtype">void</span> <a class="code" href="classmlnorm.html#b6749030c5d5abcb3eb6898f74cea3c0" title="Set A and R.">mlnorm&lt;sq_T&gt;::set_parameters</a> ( <span class="keyword">const</span> mat &amp;A0, <span class="keyword">const</span> sq_T &amp;R0 ) { 
     265<a name="l00379"></a>00379         <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.set_parameters ( zeros ( <a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return length (number of scalars) of the RV.">count</a>() ),R0 ); 
     266<a name="l00380"></a>00380         A = A0; 
     267<a name="l00381"></a>00381 } 
     268<a name="l00382"></a>00382  
     269<a name="l00383"></a>00383 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     270<a name="l00384"></a><a class="code" href="classmlnorm.html#decf3e3b5c8e0812e5b4dbe94fa2ae18">00384</a> vec <a class="code" href="classmlnorm.html#decf3e3b5c8e0812e5b4dbe94fa2ae18" title="Generate one sample of the posterior.">mlnorm&lt;sq_T&gt;::samplecond</a> ( vec &amp;cond, <span class="keywordtype">double</span> &amp;lik ) { 
     271<a name="l00385"></a>00385         this-&gt;<a class="code" href="classmlnorm.html#5232fc7e305eceab4e2bd6a8daa44195" title="Set value of rvc . Result of this operation is stored in epdf use function _ep to...">condition</a> ( cond ); 
     272<a name="l00386"></a>00386         vec smp = <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.sample(); 
     273<a name="l00387"></a>00387         lik = <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.eval ( smp ); 
     274<a name="l00388"></a>00388         <span class="keywordflow">return</span> smp; 
     275<a name="l00389"></a>00389 } 
     276<a name="l00390"></a>00390  
     277<a name="l00391"></a>00391 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     278<a name="l00392"></a><a class="code" href="classmlnorm.html#215fb88cc8b95d64cdefd6849abdd1e8">00392</a> mat <a class="code" href="classmlnorm.html#decf3e3b5c8e0812e5b4dbe94fa2ae18" title="Generate one sample of the posterior.">mlnorm&lt;sq_T&gt;::samplecond</a> ( vec &amp;cond, vec &amp;lik, <span class="keywordtype">int</span> n ) { 
     279<a name="l00393"></a>00393         <span class="keywordtype">int</span> i; 
     280<a name="l00394"></a>00394         <span class="keywordtype">int</span> dim = <a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return length (number of scalars) of the RV.">count</a>(); 
     281<a name="l00395"></a>00395         mat Smp ( dim,n ); 
     282<a name="l00396"></a>00396         vec smp ( dim ); 
     283<a name="l00397"></a>00397         this-&gt;<a class="code" href="classmlnorm.html#5232fc7e305eceab4e2bd6a8daa44195" title="Set value of rvc . Result of this operation is stored in epdf use function _ep to...">condition</a> ( cond ); 
     284<a name="l00398"></a>00398  
     285<a name="l00399"></a>00399         <span class="keywordflow">for</span> ( i=0; i&lt;n; i++ ) { 
     286<a name="l00400"></a>00400                 smp = <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.sample(); 
     287<a name="l00401"></a>00401                 lik ( i ) = <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.eval ( smp ); 
     288<a name="l00402"></a>00402                 Smp.set_col ( i ,smp ); 
     289<a name="l00403"></a>00403         } 
     290<a name="l00404"></a>00404  
     291<a name="l00405"></a>00405         <span class="keywordflow">return</span> Smp; 
     292<a name="l00406"></a>00406 } 
     293<a name="l00407"></a>00407  
     294<a name="l00408"></a>00408 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     295<a name="l00409"></a><a class="code" href="classmlnorm.html#5232fc7e305eceab4e2bd6a8daa44195">00409</a> <span class="keywordtype">void</span> <a class="code" href="classmlnorm.html#5232fc7e305eceab4e2bd6a8daa44195" title="Set value of rvc . Result of this operation is stored in epdf use function _ep to...">mlnorm&lt;sq_T&gt;::condition</a> ( vec &amp;cond ) { 
     296<a name="l00410"></a>00410         _mu = A*cond; 
     297<a name="l00411"></a>00411 <span class="comment">//R is already assigned;</span> 
     298<a name="l00412"></a>00412 } 
     299<a name="l00413"></a>00413  
     300<a name="l00415"></a>00415  
     301<a name="l00416"></a>00416  
     302<a name="l00417"></a>00417 <span class="preprocessor">#endif //EF_H</span> 
     303</pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Fri Apr 18 11:15:15 2008 for mixpp by&nbsp; 
    297304<a href="http://www.doxygen.org/index.html"> 
    298305<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>