Show
Ignore:
Timestamp:
08/18/08 14:27:50 (16 years ago)
Author:
smidl
Message:

Documentation update

Files:
1 modified

Legend:

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

    r106 r139  
    55<link href="tabs.css" rel="stylesheet" type="text/css"> 
    66</head><body> 
    7 <!-- Generated by Doxygen 1.5.5 --> 
     7<!-- Generated by Doxygen 1.5.6 --> 
    88<div class="navigation" id="top"> 
    99  <div class="tabs"> 
     
    106106<a name="l00161"></a><a class="code" href="classegamma.html#8e348b89be82b70471fe8c5630f61339">00161</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;}; 
    107107<a name="l00162"></a>00162         vec <a class="code" href="classegamma.html#8e10c0021b5dfdd9cb62c6959b5ef425" title="Returns the required moment of the epdf.">sample</a>() <span class="keyword">const</span>; 
    108 <a name="l00164"></a>00164         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>; 
    109 <a name="l00165"></a>00165         <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>; 
     108<a name="l00164"></a>00164 <span class="comment">//      mat sample ( int N ) const;</span> 
     109<a name="l00165"></a>00165         <span class="keywordtype">double</span> <a class="code" href="classegamma.html#de84faac8f9799dfe2777ddbedf997ef" title="TODO: is it used anywhere?">evalpdflog</a> ( <span class="keyword">const</span> vec &amp;val ) <span class="keyword">const</span>; 
    110110<a name="l00166"></a>00166         <span class="keywordtype">double</span> <a class="code" href="classegamma.html#d6dbbdb72360f9e54d64501f80318bb6" title="logarithm of the normalizing constant, ">lognc</a> () <span class="keyword">const</span>; 
    111111<a name="l00168"></a><a class="code" href="classegamma.html#44445c56e60b91b377f207f8d5089790">00168</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>;}; 
     
    139139<a name="l00205"></a><a class="code" href="classeuni.html#06af95d514a6623ad4688bd2ad50ad71">00205</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>;} 
    140140<a name="l00206"></a><a class="code" href="classeuni.html#4a0e09392be17beaee120ba98fc038cd">00206</a>         vec <a class="code" href="classeuni.html#4a0e09392be17beaee120ba98fc038cd" title="Returns the required moment of the epdf.">sample</a>()<span class="keyword"> const </span>{ 
    141 <a name="l00207"></a>00207                 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 number of scalars in 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 number of scalars in the RV.">count</a>(),smp ); 
    142 <a name="l00208"></a>00208                 <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; 
    143 <a name="l00209"></a>00209         } 
    144 <a name="l00211"></a><a class="code" href="classeuni.html#4fd7c6a05100616ad16ece405cad7bf2">00211</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 ) { 
    145 <a name="l00212"></a>00212                 <a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a> = high0-low0; 
    146 <a name="l00213"></a>00213                 it_assert_debug ( min ( <a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a> ) &gt;0.0,<span class="stringliteral">"bad support"</span> ); 
    147 <a name="l00214"></a>00214                 <a class="code" href="classeuni.html#ef42cd8d7645422048d46c46ec5cdac1" title="lower bound on support">low</a> = low0; 
    148 <a name="l00215"></a>00215                 <a class="code" href="classeuni.html#71b6d6b41aeb61a7f76f682b72119231" title="upper bound on support">high</a> = high0; 
    149 <a name="l00216"></a>00216                 <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> ); 
    150 <a name="l00217"></a>00217                 <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> ); 
    151 <a name="l00218"></a>00218         } 
    152 <a name="l00219"></a><a class="code" href="classeuni.html#8050087e421a9cfd1b4b1f8bd33b1cc1">00219</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;} 
    153 <a name="l00220"></a>00220 }; 
    154 <a name="l00221"></a>00221  
    155 <a name="l00222"></a>00222  
    156 <a name="l00228"></a>00228 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    157 <a name="l00229"></a><a class="code" href="classmlnorm.html">00229</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> { 
    158 <a name="l00231"></a>00231         <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>; 
    159 <a name="l00232"></a>00232         mat A; 
    160 <a name="l00233"></a>00233         vec&amp; _mu; <span class="comment">//cached epdf.mu;</span> 
    161 <a name="l00234"></a>00234 <span class="keyword">public</span>: 
    162 <a name="l00236"></a>00236         <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> ); 
    163 <a name="l00238"></a>00238         <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 ); 
    164 <a name="l00240"></a>00240         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 ); 
    165 <a name="l00242"></a>00242         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 ); 
    166 <a name="l00244"></a>00244         <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 ); 
    167 <a name="l00245"></a>00245 }; 
    168 <a name="l00246"></a>00246  
    169 <a name="l00256"></a><a class="code" href="classmgamma.html">00256</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> { 
    170 <a name="l00257"></a>00257 <span class="keyword">protected</span>: 
    171 <a name="l00259"></a><a class="code" href="classmgamma.html#612dbf35c770a780027619aaac2c443e">00259</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>; 
    172 <a name="l00261"></a><a class="code" href="classmgamma.html#43f733cce0245a52363d566099add687">00261</a>         <span class="keywordtype">double</span> <a class="code" href="classmgamma.html#43f733cce0245a52363d566099add687" title="Constant .">k</a>; 
    173 <a name="l00263"></a><a class="code" href="classmgamma.html#5e90652837448bcc29707e7412f99691">00263</a>         vec* <a class="code" href="classmgamma.html#5e90652837448bcc29707e7412f99691" title="cache of epdf.beta">_beta</a>; 
    174 <a name="l00264"></a>00264  
    175 <a name="l00265"></a>00265 <span class="keyword">public</span>: 
    176 <a name="l00267"></a>00267         <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> ); 
    177 <a name="l00269"></a>00269         <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</a> ); 
    178 <a name="l00271"></a>00271         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 ); 
    179 <a name="l00273"></a>00273         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 ); 
    180 <a name="l00274"></a><a class="code" href="classmgamma.html#a61094c9f7a2d64ea77b130cbc031f97">00274</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</a>/val;}; 
    181 <a name="l00275"></a>00275 }; 
    182 <a name="l00276"></a>00276  
    183 <a name="l00288"></a><a class="code" href="classmgamma__fix.html">00288</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> { 
    184 <a name="l00289"></a>00289 <span class="keyword">protected</span>: 
    185 <a name="l00291"></a><a class="code" href="classmgamma__fix.html#3f48c09caddc298901ad75fe7c0529f6">00291</a>         <span class="keywordtype">double</span> <a class="code" href="classmgamma__fix.html#3f48c09caddc298901ad75fe7c0529f6" title="parameter l">l</a>; 
    186 <a name="l00293"></a><a class="code" href="classmgamma__fix.html#81ce49029ecc385418619b200dcafeb0">00293</a>         vec <a class="code" href="classmgamma__fix.html#81ce49029ecc385418619b200dcafeb0" title="reference vector">refl</a>; 
    187 <a name="l00294"></a>00294 <span class="keyword">public</span>: 
    188 <a name="l00296"></a><a class="code" href="classmgamma__fix.html#b92c3d2e5fd0381033a072e5ef3bcf80">00296</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 ),<a class="code" href="classmgamma__fix.html#81ce49029ecc385418619b200dcafeb0" title="reference vector">refl</a> ( rv.count() ) {}; 
    189 <a name="l00298"></a><a class="code" href="classmgamma__fix.html#ec6f846896749e27cb7be9fa48dd1cb1">00298</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 ) { 
    190 <a name="l00299"></a>00299                 <a class="code" href="classmgamma.html#a9d646cf758a70126dde7c48790b6e94" title="Set value of k.">mgamma::set_parameters</a> ( k0 ); 
    191 <a name="l00300"></a>00300                 <a class="code" href="classmgamma__fix.html#81ce49029ecc385418619b200dcafeb0" title="reference vector">refl</a>=pow ( ref0,1.0-l0 );<a class="code" href="classmgamma__fix.html#3f48c09caddc298901ad75fe7c0529f6" title="parameter l">l</a>=l0; 
    192 <a name="l00301"></a>00301         }; 
    193 <a name="l00302"></a>00302  
    194 <a name="l00303"></a><a class="code" href="classmgamma__fix.html#6ea3931eec7b7da7b693e45981052460">00303</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 ( <a class="code" href="classmgamma__fix.html#81ce49029ecc385418619b200dcafeb0" title="reference vector">refl</a>,pow ( val,<a class="code" href="classmgamma__fix.html#3f48c09caddc298901ad75fe7c0529f6" title="parameter l">l</a> ) ); *<a class="code" href="classmgamma.html#5e90652837448bcc29707e7412f99691" title="cache of epdf.beta">_beta</a>=<a class="code" href="classmgamma.html#43f733cce0245a52363d566099add687" title="Constant .">k</a>/mean;}; 
    195 <a name="l00304"></a>00304 }; 
    196 <a name="l00305"></a>00305  
    197 <a name="l00307"></a><a class="code" href="libEF_8h.html#99497a3ff630f761cf6bff7babd23212">00307</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 }; 
    198 <a name="l00313"></a><a class="code" href="classeEmp.html">00313</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> { 
    199 <a name="l00314"></a>00314 <span class="keyword">protected</span> : 
    200 <a name="l00316"></a><a class="code" href="classeEmp.html#8c33034de0e35f03f8bb85d3d67438fd">00316</a>         <span class="keywordtype">int</span> <a class="code" href="classeEmp.html#8c33034de0e35f03f8bb85d3d67438fd" title="Number of particles.">n</a>; 
    201 <a name="l00318"></a><a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8">00318</a>         vec <a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8" title="Sample weights .">w</a>; 
    202 <a name="l00320"></a><a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a">00320</a>         Array&lt;vec&gt; <a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a" title="Samples .">samples</a>; 
    203 <a name="l00321"></a>00321 <span class="keyword">public</span>: 
    204 <a name="l00323"></a><a class="code" href="classeEmp.html#0c04b073ecd0dae3d498e680ae27e9e4">00323</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</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> ) {}; 
    205 <a name="l00325"></a>00325         <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 ); 
    206 <a name="l00327"></a><a class="code" href="classeEmp.html#31b2bfb73b72486a5c89f2ab850c7a9b">00327</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</a>;}; 
    207 <a name="l00329"></a><a class="code" href="classeEmp.html#31b747eca73b16f30370827ba4cc3575">00329</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>;}; 
    208 <a name="l00331"></a>00331         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 ); 
    209 <a name="l00333"></a><a class="code" href="classeEmp.html#83f9283f92b805508d896479dc1ccf12">00333</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;} 
    210 <a name="l00335"></a><a class="code" href="classeEmp.html#23e7358995400865ad2e278945922fb3">00335</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;} 
    211 <a name="l00336"></a><a class="code" href="classeEmp.html#ba055c19038cc72628d98e25197e982d">00336</a>         vec <a class="code" href="classeEmp.html#ba055c19038cc72628d98e25197e982d" title="return expected value">mean</a>()<span class="keyword"> const </span>{ 
    212 <a name="l00337"></a>00337                 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 number of scalars in the RV.">count</a>() ); 
    213 <a name="l00338"></a>00338                 <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</a> ( i );} 
    214 <a name="l00339"></a>00339                 <span class="keywordflow">return</span> pom; 
    215 <a name="l00340"></a>00340         } 
    216 <a name="l00341"></a>00341 }; 
    217 <a name="l00342"></a>00342  
    218 <a name="l00343"></a>00343  
     141<a name="l00207"></a>00207                 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 number of scalars in the RV.">count</a>() );  
     142<a name="l00208"></a>00208 <span class="preprocessor">                #pragma omp critical</span> 
     143<a name="l00209"></a>00209 <span class="preprocessor"></span>                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 number of scalars in the RV.">count</a>(),smp ); 
     144<a name="l00210"></a>00210                 <span class="keywordflow">return</span> <a class="code" href="classeuni.html#ef42cd8d7645422048d46c46ec5cdac1" title="lower bound on support">low</a>+elem_mult(<a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a>,smp); 
     145<a name="l00211"></a>00211         } 
     146<a name="l00213"></a><a class="code" href="classeuni.html#4fd7c6a05100616ad16ece405cad7bf2">00213</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 ) { 
     147<a name="l00214"></a>00214                 <a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a> = high0-low0; 
     148<a name="l00215"></a>00215                 it_assert_debug ( min ( <a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a> ) &gt;0.0,<span class="stringliteral">"bad support"</span> ); 
     149<a name="l00216"></a>00216                 <a class="code" href="classeuni.html#ef42cd8d7645422048d46c46ec5cdac1" title="lower bound on support">low</a> = low0; 
     150<a name="l00217"></a>00217                 <a class="code" href="classeuni.html#71b6d6b41aeb61a7f76f682b72119231" title="upper bound on support">high</a> = high0; 
     151<a name="l00218"></a>00218                 <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> ); 
     152<a name="l00219"></a>00219                 <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> ); 
     153<a name="l00220"></a>00220         } 
     154<a name="l00221"></a><a class="code" href="classeuni.html#8050087e421a9cfd1b4b1f8bd33b1cc1">00221</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;} 
     155<a name="l00222"></a>00222 }; 
     156<a name="l00223"></a>00223  
     157<a name="l00224"></a>00224  
     158<a name="l00230"></a>00230 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     159<a name="l00231"></a><a class="code" href="classmlnorm.html">00231</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> { 
     160<a name="l00233"></a>00233         <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>; 
     161<a name="l00234"></a>00234         mat A; 
     162<a name="l00235"></a>00235         vec&amp; _mu; <span class="comment">//cached epdf.mu;</span> 
     163<a name="l00236"></a>00236 <span class="keyword">public</span>: 
     164<a name="l00238"></a>00238         <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> ); 
     165<a name="l00240"></a>00240         <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 ); 
     166<a name="l00242"></a>00242         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 ); 
     167<a name="l00244"></a>00244         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 ); 
     168<a name="l00246"></a>00246         <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 ); 
     169<a name="l00247"></a>00247 }; 
     170<a name="l00248"></a>00248  
     171<a name="l00258"></a><a class="code" href="classmgamma.html">00258</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> { 
     172<a name="l00259"></a>00259 <span class="keyword">protected</span>: 
     173<a name="l00261"></a><a class="code" href="classmgamma.html#612dbf35c770a780027619aaac2c443e">00261</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>; 
     174<a name="l00263"></a><a class="code" href="classmgamma.html#43f733cce0245a52363d566099add687">00263</a>         <span class="keywordtype">double</span> <a class="code" href="classmgamma.html#43f733cce0245a52363d566099add687" title="Constant .">k</a>; 
     175<a name="l00265"></a><a class="code" href="classmgamma.html#5e90652837448bcc29707e7412f99691">00265</a>         vec* <a class="code" href="classmgamma.html#5e90652837448bcc29707e7412f99691" title="cache of epdf.beta">_beta</a>; 
     176<a name="l00266"></a>00266  
     177<a name="l00267"></a>00267 <span class="keyword">public</span>: 
     178<a name="l00269"></a>00269         <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> ); 
     179<a name="l00271"></a>00271         <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</a> ); 
     180<a name="l00273"></a>00273         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 ); 
     181<a name="l00275"></a>00275         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 ); 
     182<a name="l00276"></a><a class="code" href="classmgamma.html#a61094c9f7a2d64ea77b130cbc031f97">00276</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</a>/val;}; 
     183<a name="l00277"></a>00277 }; 
     184<a name="l00278"></a>00278  
     185<a name="l00290"></a><a class="code" href="classmgamma__fix.html">00290</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> { 
     186<a name="l00291"></a>00291 <span class="keyword">protected</span>: 
     187<a name="l00293"></a><a class="code" href="classmgamma__fix.html#3f48c09caddc298901ad75fe7c0529f6">00293</a>         <span class="keywordtype">double</span> <a class="code" href="classmgamma__fix.html#3f48c09caddc298901ad75fe7c0529f6" title="parameter l">l</a>; 
     188<a name="l00295"></a><a class="code" href="classmgamma__fix.html#81ce49029ecc385418619b200dcafeb0">00295</a>         vec <a class="code" href="classmgamma__fix.html#81ce49029ecc385418619b200dcafeb0" title="reference vector">refl</a>; 
     189<a name="l00296"></a>00296 <span class="keyword">public</span>: 
     190<a name="l00298"></a><a class="code" href="classmgamma__fix.html#b92c3d2e5fd0381033a072e5ef3bcf80">00298</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 ),<a class="code" href="classmgamma__fix.html#81ce49029ecc385418619b200dcafeb0" title="reference vector">refl</a> ( rv.count() ) {}; 
     191<a name="l00300"></a><a class="code" href="classmgamma__fix.html#ec6f846896749e27cb7be9fa48dd1cb1">00300</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 ) { 
     192<a name="l00301"></a>00301                 <a class="code" href="classmgamma.html#a9d646cf758a70126dde7c48790b6e94" title="Set value of k.">mgamma::set_parameters</a> ( k0 ); 
     193<a name="l00302"></a>00302                 <a class="code" href="classmgamma__fix.html#81ce49029ecc385418619b200dcafeb0" title="reference vector">refl</a>=pow ( ref0,1.0-l0 );<a class="code" href="classmgamma__fix.html#3f48c09caddc298901ad75fe7c0529f6" title="parameter l">l</a>=l0; 
     194<a name="l00303"></a>00303         }; 
     195<a name="l00304"></a>00304  
     196<a name="l00305"></a><a class="code" href="classmgamma__fix.html#6ea3931eec7b7da7b693e45981052460">00305</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 ( <a class="code" href="classmgamma__fix.html#81ce49029ecc385418619b200dcafeb0" title="reference vector">refl</a>,pow ( val,<a class="code" href="classmgamma__fix.html#3f48c09caddc298901ad75fe7c0529f6" title="parameter l">l</a> ) ); *<a class="code" href="classmgamma.html#5e90652837448bcc29707e7412f99691" title="cache of epdf.beta">_beta</a>=<a class="code" href="classmgamma.html#43f733cce0245a52363d566099add687" title="Constant .">k</a>/mean;}; 
     197<a name="l00306"></a>00306 }; 
     198<a name="l00307"></a>00307  
     199<a name="l00309"></a><a class="code" href="libEF_8h.html#99497a3ff630f761cf6bff7babd23212">00309</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 }; 
     200<a name="l00315"></a><a class="code" href="classeEmp.html">00315</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> { 
     201<a name="l00316"></a>00316 <span class="keyword">protected</span> : 
     202<a name="l00318"></a><a class="code" href="classeEmp.html#8c33034de0e35f03f8bb85d3d67438fd">00318</a>         <span class="keywordtype">int</span> <a class="code" href="classeEmp.html#8c33034de0e35f03f8bb85d3d67438fd" title="Number of particles.">n</a>; 
     203<a name="l00320"></a><a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8">00320</a>         vec <a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8" title="Sample weights .">w</a>; 
     204<a name="l00322"></a><a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a">00322</a>         Array&lt;vec&gt; <a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a" title="Samples .">samples</a>; 
     205<a name="l00323"></a>00323 <span class="keyword">public</span>: 
     206<a name="l00325"></a><a class="code" href="classeEmp.html#0c04b073ecd0dae3d498e680ae27e9e4">00325</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</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> ) {}; 
     207<a name="l00327"></a>00327         <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 ); 
     208<a name="l00329"></a><a class="code" href="classeEmp.html#31b2bfb73b72486a5c89f2ab850c7a9b">00329</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</a>;}; 
     209<a name="l00331"></a><a class="code" href="classeEmp.html#31b747eca73b16f30370827ba4cc3575">00331</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>;}; 
     210<a name="l00333"></a>00333         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 ); 
     211<a name="l00335"></a><a class="code" href="classeEmp.html#83f9283f92b805508d896479dc1ccf12">00335</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;} 
     212<a name="l00337"></a><a class="code" href="classeEmp.html#23e7358995400865ad2e278945922fb3">00337</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;} 
     213<a name="l00338"></a><a class="code" href="classeEmp.html#ba055c19038cc72628d98e25197e982d">00338</a>         vec <a class="code" href="classeEmp.html#ba055c19038cc72628d98e25197e982d" title="return expected value">mean</a>()<span class="keyword"> const </span>{ 
     214<a name="l00339"></a>00339                 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 number of scalars in the RV.">count</a>() ); 
     215<a name="l00340"></a>00340                 <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</a> ( i );} 
     216<a name="l00341"></a>00341                 <span class="keywordflow">return</span> pom; 
     217<a name="l00342"></a>00342         } 
     218<a name="l00343"></a>00343 }; 
     219<a name="l00344"></a>00344  
    219220<a name="l00345"></a>00345  
    220 <a name="l00346"></a>00346 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    221 <a name="l00347"></a><a class="code" href="classenorm.html#7b5cb487a2570e8109bfdc0df149aa06">00347</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() ) {}; 
    222 <a name="l00348"></a>00348  
    223 <a name="l00349"></a>00349 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    224 <a name="l00350"></a><a class="code" href="classenorm.html#1394a65caa6e00d42e00cc99b12227af">00350</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 ) { 
    225 <a name="l00351"></a>00351 <span class="comment">//Fixme test dimensions of mu0 and R0;</span> 
    226 <a name="l00352"></a>00352         <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a> = mu0; 
    227 <a name="l00353"></a>00353         <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a> = R0; 
    228 <a name="l00354"></a>00354 }; 
    229 <a name="l00355"></a>00355  
    230 <a name="l00356"></a>00356 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    231 <a name="l00357"></a><a class="code" href="classenorm.html#5bf185e31e5954fceb90ada3debd2ff2">00357</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 ) { 
    232 <a name="l00358"></a>00358         <span class="comment">//</span> 
    233 <a name="l00359"></a>00359 }; 
    234 <a name="l00360"></a>00360  
    235 <a name="l00361"></a>00361 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    236 <a name="l00362"></a><a class="code" href="classenorm.html#5b5fd142b6b17ea334597960e3fe126a">00362</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 ) { 
    237 <a name="l00363"></a>00363         <span class="comment">//</span> 
    238 <a name="l00364"></a>00364 }; 
    239 <a name="l00365"></a>00365  
    240 <a name="l00366"></a>00366 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    241 <a name="l00367"></a><a class="code" href="classenorm.html#60b47544f6181ffd4530d3e415ce12c5">00367</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>{ 
    242 <a name="l00368"></a>00368         vec x ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a> ); 
    243 <a name="l00369"></a>00369         NorRNG.sample_vector ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a>,x ); 
    244 <a name="l00370"></a>00370         vec smp = <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.sqrt_mult ( x ); 
    245 <a name="l00371"></a>00371  
    246 <a name="l00372"></a>00372         smp += <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>; 
    247 <a name="l00373"></a>00373         <span class="keywordflow">return</span> smp; 
    248 <a name="l00374"></a>00374 }; 
    249 <a name="l00375"></a>00375  
    250 <a name="l00376"></a>00376 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    251 <a name="l00377"></a><a class="code" href="classenorm.html#60f0f3bfa53d6e65843eea9532b16d36">00377</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>{ 
    252 <a name="l00378"></a>00378         mat X ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a>,N ); 
    253 <a name="l00379"></a>00379         vec x ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a> ); 
    254 <a name="l00380"></a>00380         vec pom; 
    255 <a name="l00381"></a>00381         <span class="keywordtype">int</span> i; 
    256 <a name="l00382"></a>00382  
    257 <a name="l00383"></a>00383         <span class="keywordflow">for</span> ( i=0;i&lt;N;i++ ) { 
    258 <a name="l00384"></a>00384                 NorRNG.sample_vector ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a>,x ); 
    259 <a name="l00385"></a>00385                 pom = <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.sqrt_mult ( x ); 
    260 <a name="l00386"></a>00386                 pom +=<a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>; 
    261 <a name="l00387"></a>00387                 X.set_col ( i, pom ); 
    262 <a name="l00388"></a>00388         } 
    263 <a name="l00389"></a>00389  
    264 <a name="l00390"></a>00390         <span class="keywordflow">return</span> X; 
    265 <a name="l00391"></a>00391 }; 
    266 <a name="l00392"></a>00392  
    267 <a name="l00393"></a>00393 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    268 <a name="l00394"></a><a class="code" href="classenorm.html#b9e1dfd33692d7b3f1a59f17b0e61bd0">00394</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>{ 
    269 <a name="l00395"></a>00395         <span class="keywordtype">double</span> pdfl,e; 
    270 <a name="l00396"></a>00396         pdfl = <a class="code" href="classenorm.html#609a7c33dbb4fdfab050f3bdd1122401" title="Compute log-probability of argument val.">evalpdflog</a> ( val ); 
    271 <a name="l00397"></a>00397         e = exp ( pdfl ); 
    272 <a name="l00398"></a>00398         <span class="keywordflow">return</span> e; 
    273 <a name="l00399"></a>00399 }; 
    274 <a name="l00400"></a>00400  
    275 <a name="l00401"></a>00401 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    276 <a name="l00402"></a><a class="code" href="classenorm.html#609a7c33dbb4fdfab050f3bdd1122401">00402</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>{ 
    277 <a name="l00403"></a>00403         <span class="comment">// 1.83787706640935 = log(2pi)</span> 
    278 <a name="l00404"></a>00404         <span class="keywordflow">return</span>  -0.5* (  +<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 ) ) - <a class="code" href="classenorm.html#b289a36a69db59d182bb6eba9c05d4a8" title="logarithm of the normalizing constant, ">lognc</a>(); 
    279 <a name="l00405"></a>00405 }; 
    280 <a name="l00406"></a>00406  
    281 <a name="l00407"></a>00407 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    282 <a name="l00408"></a><a class="code" href="classenorm.html#b289a36a69db59d182bb6eba9c05d4a8">00408</a> <span class="keyword">inline</span> <span class="keywordtype">double</span> <a class="code" href="classenorm.html#b289a36a69db59d182bb6eba9c05d4a8" title="logarithm of the normalizing constant, ">enorm&lt;sq_T&gt;::lognc</a> ()<span class="keyword"> const </span>{ 
    283 <a name="l00409"></a>00409         <span class="comment">// 1.83787706640935 = log(2pi)</span> 
    284 <a name="l00410"></a>00410         <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()); 
    285 <a name="l00411"></a>00411 }; 
    286 <a name="l00412"></a>00412  
    287 <a name="l00413"></a>00413 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    288 <a name="l00414"></a><a class="code" href="classmlnorm.html#f927203b3f31171c5c10ffc7caa797f5">00414</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>()) { 
    289 <a name="l00415"></a>00415 } 
    290 <a name="l00416"></a>00416  
    291 <a name="l00417"></a>00417 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    292 <a name="l00418"></a><a class="code" href="classmlnorm.html#b6749030c5d5abcb3eb6898f74cea3c0">00418</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 ) { 
    293 <a name="l00419"></a>00419         <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 number of scalars in the RV.">count</a>() ),R0 ); 
    294 <a name="l00420"></a>00420         A = A0; 
    295 <a name="l00421"></a>00421 } 
    296 <a name="l00422"></a>00422  
    297 <a name="l00423"></a>00423 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    298 <a name="l00424"></a><a class="code" href="classmlnorm.html#decf3e3b5c8e0812e5b4dbe94fa2ae18">00424</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 ) { 
    299 <a name="l00425"></a>00425         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 ); 
    300 <a name="l00426"></a>00426         vec smp = <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.sample(); 
    301 <a name="l00427"></a>00427         lik = <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.eval ( smp ); 
    302 <a name="l00428"></a>00428         <span class="keywordflow">return</span> smp; 
    303 <a name="l00429"></a>00429 } 
    304 <a name="l00430"></a>00430  
    305 <a name="l00431"></a>00431 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    306 <a name="l00432"></a><a class="code" href="classmlnorm.html#215fb88cc8b95d64cdefd6849abdd1e8">00432</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 ) { 
    307 <a name="l00433"></a>00433         <span class="keywordtype">int</span> i; 
    308 <a name="l00434"></a>00434         <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 number of scalars in the RV.">count</a>(); 
    309 <a name="l00435"></a>00435         mat Smp ( dim,n ); 
    310 <a name="l00436"></a>00436         vec smp ( dim ); 
    311 <a name="l00437"></a>00437         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 ); 
    312 <a name="l00438"></a>00438  
    313 <a name="l00439"></a>00439         <span class="keywordflow">for</span> ( i=0; i&lt;n; i++ ) { 
    314 <a name="l00440"></a>00440                 smp = <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.sample(); 
    315 <a name="l00441"></a>00441                 lik ( i ) = <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.eval ( smp ); 
    316 <a name="l00442"></a>00442                 Smp.set_col ( i ,smp ); 
    317 <a name="l00443"></a>00443         } 
    318 <a name="l00444"></a>00444  
    319 <a name="l00445"></a>00445         <span class="keywordflow">return</span> Smp; 
    320 <a name="l00446"></a>00446 } 
    321 <a name="l00447"></a>00447  
    322 <a name="l00448"></a>00448 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
    323 <a name="l00449"></a><a class="code" href="classmlnorm.html#5232fc7e305eceab4e2bd6a8daa44195">00449</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 ) { 
    324 <a name="l00450"></a>00450         _mu = A*cond; 
    325 <a name="l00451"></a>00451 <span class="comment">//R is already assigned;</span> 
    326 <a name="l00452"></a>00452 } 
    327 <a name="l00453"></a>00453  
     221<a name="l00347"></a>00347  
     222<a name="l00348"></a>00348 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     223<a name="l00349"></a><a class="code" href="classenorm.html#7b5cb487a2570e8109bfdc0df149aa06">00349</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() ) {}; 
     224<a name="l00350"></a>00350  
     225<a name="l00351"></a>00351 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     226<a name="l00352"></a><a class="code" href="classenorm.html#1394a65caa6e00d42e00cc99b12227af">00352</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 ) { 
     227<a name="l00353"></a>00353 <span class="comment">//Fixme test dimensions of mu0 and R0;</span> 
     228<a name="l00354"></a>00354         <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a> = mu0; 
     229<a name="l00355"></a>00355         <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a> = R0; 
     230<a name="l00356"></a>00356 }; 
     231<a name="l00357"></a>00357  
     232<a name="l00358"></a>00358 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     233<a name="l00359"></a><a class="code" href="classenorm.html#5bf185e31e5954fceb90ada3debd2ff2">00359</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 ) { 
     234<a name="l00360"></a>00360         <span class="comment">//</span> 
     235<a name="l00361"></a>00361 }; 
     236<a name="l00362"></a>00362  
     237<a name="l00363"></a>00363 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     238<a name="l00364"></a><a class="code" href="classenorm.html#5b5fd142b6b17ea334597960e3fe126a">00364</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 ) { 
     239<a name="l00365"></a>00365         <span class="comment">//</span> 
     240<a name="l00366"></a>00366 }; 
     241<a name="l00367"></a>00367  
     242<a name="l00368"></a>00368 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     243<a name="l00369"></a><a class="code" href="classenorm.html#60b47544f6181ffd4530d3e415ce12c5">00369</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>{ 
     244<a name="l00370"></a>00370         vec x ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a> ); 
     245<a name="l00371"></a>00371         NorRNG.sample_vector ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a>,x ); 
     246<a name="l00372"></a>00372         vec smp = <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.sqrt_mult ( x ); 
     247<a name="l00373"></a>00373  
     248<a name="l00374"></a>00374         smp += <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>; 
     249<a name="l00375"></a>00375         <span class="keywordflow">return</span> smp; 
     250<a name="l00376"></a>00376 }; 
     251<a name="l00377"></a>00377  
     252<a name="l00378"></a>00378 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     253<a name="l00379"></a><a class="code" href="classenorm.html#60f0f3bfa53d6e65843eea9532b16d36">00379</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>{ 
     254<a name="l00380"></a>00380         mat X ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a>,N ); 
     255<a name="l00381"></a>00381         vec x ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a> ); 
     256<a name="l00382"></a>00382         vec pom; 
     257<a name="l00383"></a>00383         <span class="keywordtype">int</span> i; 
     258<a name="l00384"></a>00384  
     259<a name="l00385"></a>00385         <span class="keywordflow">for</span> ( i=0;i&lt;N;i++ ) { 
     260<a name="l00386"></a>00386                 NorRNG.sample_vector ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a>,x ); 
     261<a name="l00387"></a>00387                 pom = <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.sqrt_mult ( x ); 
     262<a name="l00388"></a>00388                 pom +=<a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>; 
     263<a name="l00389"></a>00389                 X.set_col ( i, pom ); 
     264<a name="l00390"></a>00390         } 
     265<a name="l00391"></a>00391  
     266<a name="l00392"></a>00392         <span class="keywordflow">return</span> X; 
     267<a name="l00393"></a>00393 }; 
     268<a name="l00394"></a>00394  
     269<a name="l00395"></a>00395 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     270<a name="l00396"></a><a class="code" href="classenorm.html#b9e1dfd33692d7b3f1a59f17b0e61bd0">00396</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>{ 
     271<a name="l00397"></a>00397         <span class="keywordtype">double</span> pdfl,e; 
     272<a name="l00398"></a>00398         pdfl = <a class="code" href="classenorm.html#609a7c33dbb4fdfab050f3bdd1122401" title="Compute log-probability of argument val.">evalpdflog</a> ( val ); 
     273<a name="l00399"></a>00399         e = exp ( pdfl ); 
     274<a name="l00400"></a>00400         <span class="keywordflow">return</span> e; 
     275<a name="l00401"></a>00401 }; 
     276<a name="l00402"></a>00402  
     277<a name="l00403"></a>00403 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     278<a name="l00404"></a><a class="code" href="classenorm.html#609a7c33dbb4fdfab050f3bdd1122401">00404</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>{ 
     279<a name="l00405"></a>00405         <span class="comment">// 1.83787706640935 = log(2pi)</span> 
     280<a name="l00406"></a>00406         <span class="keywordflow">return</span>  -0.5* (  +<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 ) ) - <a class="code" href="classenorm.html#b289a36a69db59d182bb6eba9c05d4a8" title="logarithm of the normalizing constant, ">lognc</a>(); 
     281<a name="l00407"></a>00407 }; 
     282<a name="l00408"></a>00408  
     283<a name="l00409"></a>00409 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     284<a name="l00410"></a><a class="code" href="classenorm.html#b289a36a69db59d182bb6eba9c05d4a8">00410</a> <span class="keyword">inline</span> <span class="keywordtype">double</span> <a class="code" href="classenorm.html#b289a36a69db59d182bb6eba9c05d4a8" title="logarithm of the normalizing constant, ">enorm&lt;sq_T&gt;::lognc</a> ()<span class="keyword"> const </span>{ 
     285<a name="l00411"></a>00411         <span class="comment">// 1.83787706640935 = log(2pi)</span> 
     286<a name="l00412"></a>00412         <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()); 
     287<a name="l00413"></a>00413 }; 
     288<a name="l00414"></a>00414  
     289<a name="l00415"></a>00415 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     290<a name="l00416"></a><a class="code" href="classmlnorm.html#f927203b3f31171c5c10ffc7caa797f5">00416</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> ( rv0 ),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>()) { <a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a> =&amp;<a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>; 
     291<a name="l00417"></a>00417 } 
     292<a name="l00418"></a>00418  
     293<a name="l00419"></a>00419 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     294<a name="l00420"></a><a class="code" href="classmlnorm.html#b6749030c5d5abcb3eb6898f74cea3c0">00420</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 ) { 
     295<a name="l00421"></a>00421         <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 number of scalars in the RV.">count</a>() ),R0 ); 
     296<a name="l00422"></a>00422         A = A0; 
     297<a name="l00423"></a>00423 } 
     298<a name="l00424"></a>00424  
     299<a name="l00425"></a>00425 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     300<a name="l00426"></a><a class="code" href="classmlnorm.html#decf3e3b5c8e0812e5b4dbe94fa2ae18">00426</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 ) { 
     301<a name="l00427"></a>00427         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 ); 
     302<a name="l00428"></a>00428         vec smp = <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.sample(); 
     303<a name="l00429"></a>00429         lik = <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.eval ( smp ); 
     304<a name="l00430"></a>00430         <span class="keywordflow">return</span> smp; 
     305<a name="l00431"></a>00431 } 
     306<a name="l00432"></a>00432  
     307<a name="l00433"></a>00433 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     308<a name="l00434"></a><a class="code" href="classmlnorm.html#215fb88cc8b95d64cdefd6849abdd1e8">00434</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 ) { 
     309<a name="l00435"></a>00435         <span class="keywordtype">int</span> i; 
     310<a name="l00436"></a>00436         <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 number of scalars in the RV.">count</a>(); 
     311<a name="l00437"></a>00437         mat Smp ( dim,n ); 
     312<a name="l00438"></a>00438         vec smp ( dim ); 
     313<a name="l00439"></a>00439         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 ); 
     314<a name="l00440"></a>00440  
     315<a name="l00441"></a>00441         <span class="keywordflow">for</span> ( i=0; i&lt;n; i++ ) { 
     316<a name="l00442"></a>00442                 smp = <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.sample(); 
     317<a name="l00443"></a>00443                 lik ( i ) = <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.eval ( smp ); 
     318<a name="l00444"></a>00444                 Smp.set_col ( i ,smp ); 
     319<a name="l00445"></a>00445         } 
     320<a name="l00446"></a>00446  
     321<a name="l00447"></a>00447         <span class="keywordflow">return</span> Smp; 
     322<a name="l00448"></a>00448 } 
     323<a name="l00449"></a>00449  
     324<a name="l00450"></a>00450 <span class="keyword">template</span>&lt;<span class="keyword">class</span> sq_T&gt; 
     325<a name="l00451"></a><a class="code" href="classmlnorm.html#5232fc7e305eceab4e2bd6a8daa44195">00451</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 ) { 
     326<a name="l00452"></a>00452         _mu = A*cond; 
     327<a name="l00453"></a>00453 <span class="comment">//R is already assigned;</span> 
     328<a name="l00454"></a>00454 } 
    328329<a name="l00455"></a>00455  
    329 <a name="l00456"></a>00456  
    330 <a name="l00457"></a>00457 <span class="preprocessor">#endif //EF_H</span> 
     330<a name="l00457"></a>00457  
     331<a name="l00458"></a>00458  
     332<a name="l00459"></a>00459 <span class="preprocessor">#endif //EF_H</span> 
    331333</pre></div></div> 
    332 <hr size="1"><address style="text-align: right;"><small>Generated on Fri May 9 23:06:28 2008 for mixpp by&nbsp; 
     334<hr size="1"><address style="text-align: right;"><small>Generated on Sat Aug 16 11:58:41 2008 for mixpp by&nbsp; 
    333335<a href="http://www.doxygen.org/index.html"> 
    334 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.5 </small></address> 
     336<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address> 
    335337</body> 
    336338</html>