Changeset 91 for doc/html/libEF_8h-source.html
- Timestamp:
- 04/30/08 15:20:07 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
doc/html/libEF_8h-source.html
r79 r91 5 5 <link href="tabs.css" rel="stylesheet" type="text/css"> 6 6 </head><body> 7 <!-- Generated by Doxygen 1.5.3 --> 8 <div class="tabs"> 9 <ul> 10 <li><a href="index.html"><span>Main Page</span></a></li> 11 <li><a href="annotated.html"><span>Classes</span></a></li> 12 <li class="current"><a href="files.html"><span>Files</span></a></li> 13 <li><a href="pages.html"><span>Related Pages</span></a></li> 14 </ul> 15 </div> 7 <!-- Generated by Doxygen 1.5.5 --> 8 <div class="navigation" id="top"> 9 <div class="tabs"> 10 <ul> 11 <li><a href="index.html"><span>Main Page</span></a></li> 12 <li><a href="pages.html"><span>Related Pages</span></a></li> 13 <li><a href="annotated.html"><span>Classes</span></a></li> 14 <li class="current"><a href="files.html"><span>Files</span></a></li> 15 </ul> 16 </div> 16 17 <h1>work/mixpp/bdm/stat/libEF.h</h1><a href="libEF_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 17 18 <a name="l00013"></a>00013 <span class="preprocessor">#ifndef EF_H</span> … … 116 117 <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 &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 118 <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) ofthe RV.">count</a>(),smp );119 <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 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 ); 119 120 <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 121 <a name="l00176"></a>00176 } … … 134 135 <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 136 <a name="l00198"></a>00198 <a class="code" href="classenorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T></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& _mu; <span class="comment">//cached epdf.mu;</span>137 <a name="l00200"></a>00200 mat A;137 <a name="l00199"></a>00199 mat A; 138 <a name="l00200"></a>00200 vec& _mu; <span class="comment">//cached epdf.mu;</span> 138 139 <a name="l00201"></a>00201 <span class="keyword">public</span>: 139 140 <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> &<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> &<a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab" title="random variable in condition">rvc</a> ); … … 147 148 <a name="l00224"></a>00224 <span class="keyword">protected</span>: 148 149 <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="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</a>; 150 151 <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 152 <a name="l00231"></a>00231 152 153 <a name="l00232"></a>00232 <span class="keyword">public</span>: 153 154 <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> &<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> &<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="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</a> ); 155 156 <a name="l00238"></a>00238 vec <a class="code" href="classmgamma.html#9f40dc43885085fad8e3d6652b79e139" title="Generate one sample of the posterior.">samplecond</a> ( vec &cond, <span class="keywordtype">double</span> &lik ); 156 157 <a name="l00240"></a>00240 mat <a class="code" href="classmgamma.html#9f40dc43885085fad8e3d6652b79e139" title="Generate one sample of the posterior.">samplecond</a> ( vec &cond, vec &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 &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="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 &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;}; 158 159 <a name="l00242"></a>00242 }; 159 160 <a name="l00243"></a>00243 … … 169 170 <a name="l00266"></a>00266 }; 170 171 <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 &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="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 &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</a>/mean;}; 172 173 <a name="l00269"></a>00269 }; 173 174 <a name="l00270"></a>00270 … … 176 177 <a name="l00279"></a>00279 <span class="keyword">protected</span> : 177 178 <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="l00283"></a><a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8">00283</a> vec <a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8" title="Sample weights .">w</a>; 179 180 <a name="l00285"></a><a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a">00285</a> Array<vec> <a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a" title="Samples .">samples</a>; 180 181 <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> &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="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> &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> ) {}; 182 183 <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 &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& <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="l00292"></a><a class="code" href="classeEmp.html#31b2bfb73b72486a5c89f2ab850c7a9b">00292</a> vec& <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>;}; 184 185 <a name="l00294"></a><a class="code" href="classeEmp.html#31b747eca73b16f30370827ba4cc3575">00294</a> Array<vec>& <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 186 <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 ); … … 187 188 <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 &val )<span class="keyword"> const </span>{it_error ( <span class="stringliteral">"Not implemented"</span> );<span class="keywordflow">return</span> 0.0;} 188 189 <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) ofthe RV.">count</a>() );190 <a name="l00303"></a>00303 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<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 );}190 <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 number of scalars in the RV.">count</a>() ); 191 <a name="l00303"></a>00303 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<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 );} 191 192 <a name="l00304"></a>00304 <span class="keywordflow">return</span> pom; 192 193 <a name="l00305"></a>00305 } … … 263 264 <a name="l00377"></a>00377 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> 264 265 <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<sq_T>::set_parameters</a> ( <span class="keyword">const</span> mat &A0, <span class="keyword">const</span> sq_T &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) ofthe RV.">count</a>() ),R0 );266 <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 number of scalars in the RV.">count</a>() ),R0 ); 266 267 <a name="l00380"></a>00380 A = A0; 267 268 <a name="l00381"></a>00381 } … … 278 279 <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<sq_T>::samplecond</a> ( vec &cond, vec &lik, <span class="keywordtype">int</span> n ) { 279 280 <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) ofthe RV.">count</a>();281 <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 number of scalars in the RV.">count</a>(); 281 282 <a name="l00395"></a>00395 mat Smp ( dim,n ); 282 283 <a name="l00396"></a>00396 vec smp ( dim ); … … 301 302 <a name="l00416"></a>00416 302 303 <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 304 </pre></div></div> 305 <hr size="1"><address style="text-align: right;"><small>Generated on Tue Apr 29 20:46:25 2008 for mixpp by 304 306 <a href="http://www.doxygen.org/index.html"> 305 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5. 3</small></address>307 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.5 </small></address> 306 308 </body> 307 309 </html>