Changeset 255 for doc/html/libEF_8h-source.html
- Timestamp:
- 01/28/09 10:01:09 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
doc/html/libEF_8h-source.html
r234 r255 26 26 <a name="l00020"></a>00020 <span class="comment">//#include <std></span> 27 27 <a name="l00021"></a>00021 28 <a name="l00022"></a>00022 <span class="keyword"> using namespace </span>itpp;28 <a name="l00022"></a>00022 <span class="keyword">namespace </span>bdm{ 29 29 <a name="l00023"></a>00023 30 30 <a name="l00024"></a>00024 … … 33 33 <a name="l00030"></a>00030 <span class="keyword">extern</span> <a class="code" href="classitpp_1_1Gamma__RNG.html" title="Gamma distribution.">Gamma_RNG</a> GamRNG; 34 34 <a name="l00031"></a>00031 35 <a name="l00038"></a><a class="code" href="class eEF.html">00038</a> <span class="keyword">class </span><a class="code" href="classeEF.html" title="General conjugate exponential family posterior density.">eEF</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> {35 <a name="l00038"></a><a class="code" href="classbdm_1_1eEF.html">00038</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> { 36 36 <a name="l00039"></a>00039 <span class="keyword">public</span>: 37 37 <a name="l00040"></a>00040 <span class="comment">// eEF() :epdf() {};</span> 38 <a name="l00042"></a><a class="code" href="class eEF.html#7e3c63655e8375c76bf1f421245427a7">00042</a> <span class="comment"></span> <a class="code" href="classeEF.html#7e3c63655e8375c76bf1f421245427a7" title="default constructor">eEF</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ) :<a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( rv ) {};39 <a name="l00044"></a>00044 <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="class eEF.html#69e5680dac10375d62520d26c672477d" title="logarithm of the normalizing constant, ">lognc</a>() <span class="keyword">const</span> =0;40 <a name="l00046"></a><a class="code" href="class eEF.html#a89bef8996410609004fa019b5b48964">00046</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classeEF.html#a89bef8996410609004fa019b5b48964" title="TODO decide if it is really needed.">dupdate</a> ( mat &v ) {it_error ( <span class="stringliteral">"Not implemented"</span> );};41 <a name="l00048"></a><a class="code" href="class eEF.html#41c70565b4d3fb424599817d008f0c71">00048</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classeEF.html#41c70565b4d3fb424599817d008f0c71" title="Evaluate normalized log-probability.">evallog_nn</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;};42 <a name="l00050"></a><a class="code" href="class eEF.html#357512dd565e199904d367294b7dd862">00050</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classeEF.html#357512dd565e199904d367294b7dd862" title="Evaluate normalized log-probability.">evallog</a> ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{<span class="keywordtype">double</span> tmp;tmp= <a class="code" href="classeEF.html#41c70565b4d3fb424599817d008f0c71" title="Evaluate normalized log-probability.">evallog_nn</a> ( val )-<a class="code" href="classeEF.html#69e5680dac10375d62520d26c672477d" title="logarithm of the normalizing constant, ">lognc</a>();it_assert_debug(std::isfinite(tmp),<span class="stringliteral">"Infinite value"</span>); <span class="keywordflow">return</span> tmp;}43 <a name="l00052"></a><a class="code" href="class eEF.html#cff03a658aec11b806c3e3d48f37b81f">00052</a> <span class="keyword">virtual</span> vec <a class="code" href="classeEF.html#357512dd565e199904d367294b7dd862" title="Evaluate normalized log-probability.">evallog</a> ( <span class="keyword">const</span> mat &Val )<span class="keyword"> const </span>{38 <a name="l00042"></a><a class="code" href="classbdm_1_1eEF.html#1e92e3f94e594edb20adfa81ae9e2959">00042</a> <span class="comment"></span> <a class="code" href="classbdm_1_1eEF.html#1e92e3f94e594edb20adfa81ae9e2959" title="default constructor">eEF</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a> ) :<a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( rv ) {}; 39 <a name="l00044"></a>00044 <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eEF.html#cd678fc9b02007a4b8d6692e746f1bf8" title="logarithm of the normalizing constant, ">lognc</a>() <span class="keyword">const</span> =0; 40 <a name="l00046"></a><a class="code" href="classbdm_1_1eEF.html#deef7d6273ba4d5a5cf0bbd91ec7277a">00046</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eEF.html#deef7d6273ba4d5a5cf0bbd91ec7277a" title="TODO decide if it is really needed.">dupdate</a> ( mat &v ) {it_error ( <span class="stringliteral">"Not implemented"</span> );}; 41 <a name="l00048"></a><a class="code" href="classbdm_1_1eEF.html#a4135778ecd9ab774762936c82a097c6">00048</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eEF.html#a4135778ecd9ab774762936c82a097c6" title="Evaluate normalized log-probability.">evallog_nn</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;}; 42 <a name="l00050"></a><a class="code" href="classbdm_1_1eEF.html#a36d06ecdd6f4c79dc122510eaccc692">00050</a> <span class="keyword">virtual</span> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eEF.html#a36d06ecdd6f4c79dc122510eaccc692" title="Evaluate normalized log-probability.">evallog</a> ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{<span class="keywordtype">double</span> tmp;tmp= <a class="code" href="classbdm_1_1eEF.html#a4135778ecd9ab774762936c82a097c6" title="Evaluate normalized log-probability.">evallog_nn</a> ( val )-<a class="code" href="classbdm_1_1eEF.html#cd678fc9b02007a4b8d6692e746f1bf8" title="logarithm of the normalizing constant, ">lognc</a>();it_assert_debug(std::isfinite(tmp),<span class="stringliteral">"Infinite value"</span>); <span class="keywordflow">return</span> tmp;} 43 <a name="l00052"></a><a class="code" href="classbdm_1_1eEF.html#79a7c8ea8c02e45d410bd1d7ffd72b41">00052</a> <span class="keyword">virtual</span> vec <a class="code" href="classbdm_1_1eEF.html#a36d06ecdd6f4c79dc122510eaccc692" title="Evaluate normalized log-probability.">evallog</a> ( <span class="keyword">const</span> mat &Val )<span class="keyword"> const </span>{ 44 44 <a name="l00053"></a>00053 vec x ( Val.cols() ); 45 <a name="l00054"></a>00054 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<Val.cols();i++ ) {x ( i ) =<a class="code" href="class eEF.html#41c70565b4d3fb424599817d008f0c71" title="Evaluate normalized log-probability.">evallog_nn</a> ( Val.get_col ( i ) ) ;}46 <a name="l00055"></a>00055 <span class="keywordflow">return</span> x-<a class="code" href="class eEF.html#69e5680dac10375d62520d26c672477d" title="logarithm of the normalizing constant, ">lognc</a>();45 <a name="l00054"></a>00054 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<Val.cols();i++ ) {x ( i ) =<a class="code" href="classbdm_1_1eEF.html#a4135778ecd9ab774762936c82a097c6" title="Evaluate normalized log-probability.">evallog_nn</a> ( Val.get_col ( i ) ) ;} 46 <a name="l00055"></a>00055 <span class="keywordflow">return</span> x-<a class="code" href="classbdm_1_1eEF.html#cd678fc9b02007a4b8d6692e746f1bf8" title="logarithm of the normalizing constant, ">lognc</a>(); 47 47 <a name="l00056"></a>00056 } 48 <a name="l00058"></a><a class="code" href="class eEF.html#4f8385dd1cc9740522dc373b1dc3cbf5">00058</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classeEF.html#4f8385dd1cc9740522dc373b1dc3cbf5" title="Power of the density, used e.g. to flatten the density.">pow</a> ( <span class="keywordtype">double</span> p ) {it_error ( <span class="stringliteral">"Not implemented"</span> );};48 <a name="l00058"></a><a class="code" href="classbdm_1_1eEF.html#cf38af29e8e3d650c640509a52396053">00058</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eEF.html#cf38af29e8e3d650c640509a52396053" title="Power of the density, used e.g. to flatten the density.">pow</a> ( <span class="keywordtype">double</span> p ) {it_error ( <span class="stringliteral">"Not implemented"</span> );}; 49 49 <a name="l00059"></a>00059 }; 50 50 <a name="l00060"></a>00060 51 <a name="l00067"></a><a class="code" href="class mEF.html">00067</a> <span class="keyword">class </span><a class="code" href="classmEF.html" title="Exponential family model.">mEF</a> : <span class="keyword">public</span> <a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> {51 <a name="l00067"></a><a class="code" href="classbdm_1_1mEF.html">00067</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mEF.html" title="Exponential family model.">mEF</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> { 52 52 <a name="l00068"></a>00068 53 53 <a name="l00069"></a>00069 <span class="keyword">public</span>: 54 <a name="l00071"></a><a class="code" href="class mEF.html#8bf51fe8654d7b83c8c8afeb19409d4f">00071</a> <a class="code" href="classmEF.html#8bf51fe8654d7b83c8c8afeb19409d4f" title="Default constructor.">mEF</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv0, <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rvc0 ) :<a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> ( rv0,rvc0 ) {};54 <a name="l00071"></a><a class="code" href="classbdm_1_1mEF.html#f6647b16e9c99b8a7d7df93374ef90f3">00071</a> <a class="code" href="classbdm_1_1mEF.html#f6647b16e9c99b8a7d7df93374ef90f3" title="Default constructor.">mEF</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv0, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rvc0 ) :<a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> ( rv0,rvc0 ) {}; 55 55 <a name="l00072"></a>00072 }; 56 56 <a name="l00073"></a>00073 57 <a name="l00075"></a><a class="code" href="class BMEF.html">00075</a> <span class="keyword">class </span><a class="code" href="classBMEF.html" title="Estimator for Exponential family.">BMEF</a> : <span class="keyword">public</span> <a class="code" href="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a> {57 <a name="l00075"></a><a class="code" href="classbdm_1_1BMEF.html">00075</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a> { 58 58 <a name="l00076"></a>00076 <span class="keyword">protected</span>: 59 <a name="l00078"></a><a class="code" href="class BMEF.html#538d632e59f9afa8daa1de74da12ce71">00078</a> <span class="keywordtype">double</span> <a class="code" href="classBMEF.html#538d632e59f9afa8daa1de74da12ce71" title="forgetting factor">frg</a>;60 <a name="l00080"></a><a class="code" href="class BMEF.html#308cf5d4133cd471fdf1ecd5dfa09d02">00080</a> <span class="keywordtype">double</span> <a class="code" href="classBMEF.html#308cf5d4133cd471fdf1ecd5dfa09d02" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>;59 <a name="l00078"></a><a class="code" href="classbdm_1_1BMEF.html#1331865e10fb1ccef65bb4c47fa3be64">00078</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1BMEF.html#1331865e10fb1ccef65bb4c47fa3be64" title="forgetting factor">frg</a>; 60 <a name="l00080"></a><a class="code" href="classbdm_1_1BMEF.html#06e7b3ac03e10017d4288c76888e2865">00080</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1BMEF.html#06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>; 61 61 <a name="l00081"></a>00081 <span class="keyword">public</span>: 62 <a name="l00083"></a><a class="code" href="class BMEF.html#46ac5c919ae647f3a6a38d9faba35f5d">00083</a> <a class="code" href="classBMEF.html#46ac5c919ae647f3a6a38d9faba35f5d" title="Default constructor.">BMEF</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a>, <span class="keywordtype">double</span> frg0=1.0 ) :<a class="code" href="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a> ( rv ), <a class="code" href="classBMEF.html#538d632e59f9afa8daa1de74da12ce71" title="forgetting factor">frg</a> ( frg0 ) {}63 <a name="l00085"></a><a class="code" href="class BMEF.html#3dc6277cafbdc6cbc2db860ff219b33e">00085</a> <a class="code" href="classBMEF.html#46ac5c919ae647f3a6a38d9faba35f5d" title="Default constructor.">BMEF</a> ( <span class="keyword">const</span> <a class="code" href="classBMEF.html" title="Estimator for Exponential family.">BMEF</a> &B ) :<a class="code" href="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a> ( B ), <a class="code" href="classBMEF.html#538d632e59f9afa8daa1de74da12ce71" title="forgetting factor">frg</a> ( B.<a class="code" href="classBMEF.html#538d632e59f9afa8daa1de74da12ce71" title="forgetting factor">frg</a> ), <a class="code" href="classBMEF.html#308cf5d4133cd471fdf1ecd5dfa09d02" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a> ( B.<a class="code" href="classBMEF.html#308cf5d4133cd471fdf1ecd5dfa09d02" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a> ) {}64 <a name="l00087"></a><a class="code" href="class BMEF.html#30bb40eb1fd31869b2e62e79e1ecdcb4">00087</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classBMEF.html#30bb40eb1fd31869b2e62e79e1ecdcb4" title="get statistics from another model">set_statistics</a> ( <span class="keyword">const</span> <a class="code" href="classBMEF.html" title="Estimator for Exponential family.">BMEF</a>* BM0 ) {it_error ( <span class="stringliteral">"Not implemented"</span> );};65 <a name="l00089"></a><a class="code" href="class BMEF.html#8f4ecb6e2eaf630155a1fa98f35aa6ad">00089</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classBMEF.html#8f4ecb6e2eaf630155a1fa98f35aa6ad" title="Weighted update of sufficient statistics (Bayes rule).">bayes</a> ( <span class="keyword">const</span> vec &data, <span class="keyword">const</span> <span class="keywordtype">double</span> w ) {};62 <a name="l00083"></a><a class="code" href="classbdm_1_1BMEF.html#73bccd1d8142d4d330e35637ca30decc">00083</a> <a class="code" href="classbdm_1_1BMEF.html#73bccd1d8142d4d330e35637ca30decc" title="Default constructor.">BMEF</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1BM.html#18d6db4af8ee42077741d9e3618153ca" title="Random variable of the posterior.">rv</a>, <span class="keywordtype">double</span> frg0=1.0 ) :<a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a> ( rv ), <a class="code" href="classbdm_1_1BMEF.html#1331865e10fb1ccef65bb4c47fa3be64" title="forgetting factor">frg</a> ( frg0 ) {} 63 <a name="l00085"></a><a class="code" href="classbdm_1_1BMEF.html#9662379513101405e159e76717104e62">00085</a> <a class="code" href="classbdm_1_1BMEF.html#73bccd1d8142d4d330e35637ca30decc" title="Default constructor.">BMEF</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a> &B ) :<a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a> ( B ), <a class="code" href="classbdm_1_1BMEF.html#1331865e10fb1ccef65bb4c47fa3be64" title="forgetting factor">frg</a> ( B.<a class="code" href="classbdm_1_1BMEF.html#1331865e10fb1ccef65bb4c47fa3be64" title="forgetting factor">frg</a> ), <a class="code" href="classbdm_1_1BMEF.html#06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a> ( B.<a class="code" href="classbdm_1_1BMEF.html#06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a> ) {} 64 <a name="l00087"></a><a class="code" href="classbdm_1_1BMEF.html#d2b528b7a41ca67163152142f5404051">00087</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1BMEF.html#d2b528b7a41ca67163152142f5404051" title="get statistics from another model">set_statistics</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a>* BM0 ) {it_error ( <span class="stringliteral">"Not implemented"</span> );}; 65 <a name="l00089"></a><a class="code" href="classbdm_1_1BMEF.html#bf58deb99af2a6cc674f13ff90300de6">00089</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1BMEF.html#bf58deb99af2a6cc674f13ff90300de6" title="Weighted update of sufficient statistics (Bayes rule).">bayes</a> ( <span class="keyword">const</span> vec &data, <span class="keyword">const</span> <span class="keywordtype">double</span> w ) {}; 66 66 <a name="l00090"></a>00090 <span class="comment">//original Bayes</span> 67 <a name="l00091"></a>00091 <span class="keywordtype">void</span> <a class="code" href="class BMEF.html#8f4ecb6e2eaf630155a1fa98f35aa6ad" title="Weighted update of sufficient statistics (Bayes rule).">bayes</a> ( <span class="keyword">const</span> vec &dt );68 <a name="l00093"></a><a class="code" href="class BMEF.html#b3689f3ade328d157aa813384a5b153a">00093</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classBMEF.html#b3689f3ade328d157aa813384a5b153a" title="Flatten the posterior according to the given BMEF (of the same type!).">flatten</a> ( <span class="keyword">const</span> <a class="code" href="classBMEF.html" title="Estimator for Exponential family.">BMEF</a> * B ) {it_error ( <span class="stringliteral">"Not implemented"</span> );}67 <a name="l00091"></a>00091 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1BMEF.html#bf58deb99af2a6cc674f13ff90300de6" title="Weighted update of sufficient statistics (Bayes rule).">bayes</a> ( <span class="keyword">const</span> vec &dt ); 68 <a name="l00093"></a><a class="code" href="classbdm_1_1BMEF.html#b2916a2e71a958665054473124d5e749">00093</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1BMEF.html#b2916a2e71a958665054473124d5e749" title="Flatten the posterior according to the given BMEF (of the same type!).">flatten</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a> * B ) {it_error ( <span class="stringliteral">"Not implemented"</span> );} 69 69 <a name="l00095"></a>00095 <span class="comment">// virtual void flatten ( double nu0 ) {it_error ( "Not implemented" );}</span> 70 70 <a name="l00096"></a>00096 71 <a name="l00097"></a><a class="code" href="class BMEF.html#97f5312efe4a5bedb86d2daec59d8651">00097</a> <a class="code" href="classBMEF.html" title="Estimator for Exponential family.">BMEF</a>* <a class="code" href="classBMEF.html#97f5312efe4a5bedb86d2daec59d8651" title="Flatten the posterior as if to keep nu0 data.">_copy_</a> ( <span class="keywordtype">bool</span> changerv=<span class="keyword">false</span> ) {it_error ( <span class="stringliteral">"function _copy_ not implemented for this BM"</span> ); <span class="keywordflow">return</span> NULL;};71 <a name="l00097"></a><a class="code" href="classbdm_1_1BMEF.html#5912dbcf28ae711e30b08c2fa766a3e6">00097</a> <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a>* <a class="code" href="classbdm_1_1BMEF.html#5912dbcf28ae711e30b08c2fa766a3e6" title="Flatten the posterior as if to keep nu0 data.">_copy_</a> ( <span class="keywordtype">bool</span> changerv=<span class="keyword">false</span> ) {it_error ( <span class="stringliteral">"function _copy_ not implemented for this BM"</span> ); <span class="keywordflow">return</span> NULL;}; 72 72 <a name="l00098"></a>00098 }; 73 73 <a name="l00099"></a>00099 74 74 <a name="l00100"></a>00100 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> 75 <a name="l00101"></a>00101 <span class="keyword">class </span> <a class="code" href="classmlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm</a>;75 <a name="l00101"></a>00101 <span class="keyword">class </span>mlnorm; 76 76 <a name="l00102"></a>00102 77 77 <a name="l00108"></a>00108 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> 78 <a name="l00109"></a><a class="code" href="class enorm.html">00109</a> <span class="keyword">class </span><a class="code" href="classenorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm</a> : <span class="keyword">public</span> <a class="code" href="classeEF.html" title="General conjugate exponential family posterior density.">eEF</a> {78 <a name="l00109"></a><a class="code" href="classbdm_1_1enorm.html">00109</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> { 79 79 <a name="l00110"></a>00110 <span class="keyword">protected</span>: 80 <a name="l00112"></a><a class="code" href="class enorm.html#71fde0d54bba147e00f612577f95ad20">00112</a> vec <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>;81 <a name="l00114"></a><a class="code" href="class enorm.html#4ccc8d8514d644ef1c98d8ab023748a1">00114</a> sq_T <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>;82 <a name="l00116"></a><a class="code" href="class enorm.html#6938fc390a19cdaf6ad4503fcbaada4e">00116</a> <span class="keywordtype">int</span> <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a>;80 <a name="l00112"></a><a class="code" href="classbdm_1_1enorm.html#c702a194720853570d08b65482f842c7">00112</a> vec <a class="code" href="classbdm_1_1enorm.html#c702a194720853570d08b65482f842c7" title="mean value">mu</a>; 81 <a name="l00114"></a><a class="code" href="classbdm_1_1enorm.html#2d92dde696b2a7a5b10ddef5d22ba2c2">00114</a> sq_T <a class="code" href="classbdm_1_1enorm.html#2d92dde696b2a7a5b10ddef5d22ba2c2" title="Covariance matrix in decomposed form.">R</a>; 82 <a name="l00116"></a><a class="code" href="classbdm_1_1enorm.html#91a2d4a91364b0144e1523cad4d1135b">00116</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1enorm.html#91a2d4a91364b0144e1523cad4d1135b" title="dimension (redundant from rv.count() for easier coding )">dim</a>; 83 83 <a name="l00117"></a>00117 <span class="keyword">public</span>: 84 <a name="l00119"></a>00119 <a class="code" href="class enorm.html#0caf54fed9e48f9fe28b534b2027df2f" title="Default constructor.">enorm</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> );85 <a name="l00121"></a>00121 <span class="keywordtype">void</span> <a class="code" href="class enorm.html#1394a65caa6e00d42e00cc99b12227af" title="Set mean value mu and covariance R.">set_parameters</a> ( <span class="keyword">const</span> vec &<a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>,<span class="keyword">const</span> sq_T &<a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a> );84 <a name="l00119"></a>00119 <a class="code" href="classbdm_1_1enorm.html#7d433390d6bbad337986945b63d7fbe9" title="Default constructor.">enorm</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a> ); 85 <a name="l00121"></a>00121 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1enorm.html#b8322f2c11560871dd922c660f4771bb" title="Set mean value mu and covariance R.">set_parameters</a> ( <span class="keyword">const</span> vec &<a class="code" href="classbdm_1_1enorm.html#c702a194720853570d08b65482f842c7" title="mean value">mu</a>,<span class="keyword">const</span> sq_T &<a class="code" href="classbdm_1_1enorm.html#2d92dde696b2a7a5b10ddef5d22ba2c2" title="Covariance matrix in decomposed form.">R</a> ); 86 86 <a name="l00123"></a>00123 <span class="comment">//void tupdate ( double phi, mat &vbar, double nubar );</span> 87 <a name="l00125"></a>00125 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="class enorm.html#5bf185e31e5954fceb90ada3debd2ff2" title="dupdate in exponential form (not really handy)">dupdate</a> ( mat &v,<span class="keywordtype">double</span> nu=1.0 );87 <a name="l00125"></a>00125 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1enorm.html#d2e0d3a1e30ab3ab04df2d0c43ae74a2" title="dupdate in exponential form (not really handy)">dupdate</a> ( mat &v,<span class="keywordtype">double</span> nu=1.0 ); 88 88 <a name="l00126"></a>00126 89 <a name="l00127"></a>00127 vec <a class="code" href="class enorm.html#60b47544f6181ffd4530d3e415ce12c5" title="Returns a sample, from density .">sample</a>() <span class="keyword">const</span>;90 <a name="l00129"></a>00129 mat <a class="code" href="class enorm.html#60b47544f6181ffd4530d3e415ce12c5" title="Returns a sample, from density .">sample</a> ( <span class="keywordtype">int</span> N ) <span class="keyword">const</span>;89 <a name="l00127"></a>00127 vec <a class="code" href="classbdm_1_1enorm.html#e1a48f52351ec3a349bd443b713b1766" title="Returns a sample, from density .">sample</a>() <span class="keyword">const</span>; 90 <a name="l00129"></a>00129 mat <a class="code" href="classbdm_1_1enorm.html#e1a48f52351ec3a349bd443b713b1766" title="Returns a sample, from density .">sample</a> ( <span class="keywordtype">int</span> N ) <span class="keyword">const</span>; 91 91 <a name="l00130"></a>00130 <span class="comment">// double eval ( const vec &val ) const ;</span> 92 <a name="l00131"></a>00131 <span class="keywordtype">double</span> <a class="code" href="class enorm.html#50cb0a083d97a7adbbd97c92e712c46c" title="Evaluate normalized log-probability.">evallog_nn</a> ( <span class="keyword">const</span> vec &val ) <span class="keyword">const</span>;93 <a name="l00132"></a>00132 <span class="keywordtype">double</span> <a class="code" href="class enorm.html#b289a36a69db59d182bb6eba9c05d4a8" title="logarithm of the normalizing constant, ">lognc</a> () <span class="keyword">const</span>;94 <a name="l00133"></a><a class="code" href="class enorm.html#50fa84da7bae02f7af17a98f37566899">00133</a> vec <a class="code" href="classenorm.html#50fa84da7bae02f7af17a98f37566899" title="return expected value">mean</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>;}95 <a name="l00134"></a><a class="code" href="class enorm.html#d4b4bfec464fe971bf57e69d71a1cf2e">00134</a> vec <a class="code" href="classenorm.html#d4b4bfec464fe971bf57e69d71a1cf2e" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> diag(<a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.to_mat());}92 <a name="l00131"></a>00131 <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1enorm.html#e13aeed5b543b2179bacdc4fa2ae47a3" title="Evaluate normalized log-probability.">evallog_nn</a> ( <span class="keyword">const</span> vec &val ) <span class="keyword">const</span>; 93 <a name="l00132"></a>00132 <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1enorm.html#25785343aff102cc5df1cab08ba16d32" title="logarithm of the normalizing constant, ">lognc</a> () <span class="keyword">const</span>; 94 <a name="l00133"></a><a class="code" href="classbdm_1_1enorm.html#b2fa2915c35366392fe9bb022ca1a600">00133</a> vec <a class="code" href="classbdm_1_1enorm.html#b2fa2915c35366392fe9bb022ca1a600" title="return expected value">mean</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1enorm.html#c702a194720853570d08b65482f842c7" title="mean value">mu</a>;} 95 <a name="l00134"></a><a class="code" href="classbdm_1_1enorm.html#729c75ef0fa8abae03d58ad1f81e6773">00134</a> vec <a class="code" href="classbdm_1_1enorm.html#729c75ef0fa8abae03d58ad1f81e6773" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> diag(<a class="code" href="classbdm_1_1enorm.html#2d92dde696b2a7a5b10ddef5d22ba2c2" title="Covariance matrix in decomposed form.">R</a>.to_mat());} 96 96 <a name="l00135"></a>00135 <span class="comment">// mlnorm<sq_T>* condition ( const RV &rvn ) const ;</span> 97 <a name="l00136"></a>00136 <a class="code" href="class mpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a>* <a class="code" href="classenorm.html#921024bd6d5a0e65f2af2e39bf38dfca" title="Return conditional density on the given RV, the remaining rvs will be in conditioning...">condition</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rvn ) <span class="keyword">const</span> ;97 <a name="l00136"></a>00136 <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a>* <a class="code" href="classbdm_1_1enorm.html#baea4d49c657342b58297d68cda16d26" title="Return conditional density on the given RV, the remaining rvs will be in conditioning...">condition</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rvn ) <span class="keyword">const</span> ; 98 98 <a name="l00137"></a>00137 <span class="comment">// enorm<sq_T>* marginal ( const RV &rv ) const;</span> 99 <a name="l00138"></a>00138 <a class="code" href="class epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* <a class="code" href="classenorm.html#af50a6102846060bcb23a670bf38117b" title="Return marginal density on the given RV, the remainig rvs are intergrated out.">marginal</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ) <span class="keyword">const</span>;99 <a name="l00138"></a>00138 <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* <a class="code" href="classbdm_1_1enorm.html#cd02d76e9d4f96bdd3fa6b604e273039" title="Return marginal density on the given RV, the remainig rvs are intergrated out.">marginal</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a> ) <span class="keyword">const</span>; 100 100 <a name="l00139"></a>00139 <span class="comment">//Access methods</span> 101 <a name="l00141"></a><a class="code" href="class enorm.html#0b8cb284e5af920a1b64a21d057ec5ac">00141</a> <span class="comment"></span> vec& <a class="code" href="classenorm.html#0b8cb284e5af920a1b64a21d057ec5ac" title="returns a pointer to the internal mean value. Use with Care!">_mu</a>() {<span class="keywordflow">return</span> <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>;}101 <a name="l00141"></a><a class="code" href="classbdm_1_1enorm.html#766127847e9482aea9226ea157295ea2">00141</a> <span class="comment"></span> vec& <a class="code" href="classbdm_1_1enorm.html#766127847e9482aea9226ea157295ea2" title="returns a pointer to the internal mean value. Use with Care!">_mu</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1enorm.html#c702a194720853570d08b65482f842c7" title="mean value">mu</a>;} 102 102 <a name="l00142"></a>00142 103 <a name="l00144"></a><a class="code" href="class enorm.html#d892a38f03be12e572ea57d9689cef6b">00144</a> <span class="keywordtype">void</span> <a class="code" href="classenorm.html#d892a38f03be12e572ea57d9689cef6b" title="access function">set_mu</a> ( <span class="keyword">const</span> vec mu0 ) { <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>=mu0;}103 <a name="l00144"></a><a class="code" href="classbdm_1_1enorm.html#8915d68ae76ad185c8c314f960a63f0c">00144</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1enorm.html#8915d68ae76ad185c8c314f960a63f0c" title="access function">set_mu</a> ( <span class="keyword">const</span> vec mu0 ) { <a class="code" href="classbdm_1_1enorm.html#c702a194720853570d08b65482f842c7" title="mean value">mu</a>=mu0;} 104 104 <a name="l00145"></a>00145 105 <a name="l00147"></a><a class="code" href="class enorm.html#7a5034b25771a84450a990d10fc40ac9">00147</a> sq_T& <a class="code" href="classenorm.html#7a5034b25771a84450a990d10fc40ac9" title="returns pointers to the internal variance and its inverse. Use with Care!">_R</a>() {<span class="keywordflow">return</span> <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>;}106 <a name="l00148"></a>00148 <span class="keyword">const</span> sq_T& <a class="code" href="class enorm.html#7a5034b25771a84450a990d10fc40ac9" title="returns pointers to the internal variance and its inverse. Use with Care!">_R</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>;}105 <a name="l00147"></a><a class="code" href="classbdm_1_1enorm.html#81d81e35e57c9f194bde248e3affcf1f">00147</a> sq_T& <a class="code" href="classbdm_1_1enorm.html#81d81e35e57c9f194bde248e3affcf1f" title="returns pointers to the internal variance and its inverse. Use with Care!">_R</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1enorm.html#2d92dde696b2a7a5b10ddef5d22ba2c2" title="Covariance matrix in decomposed form.">R</a>;} 106 <a name="l00148"></a>00148 <span class="keyword">const</span> sq_T& <a class="code" href="classbdm_1_1enorm.html#81d81e35e57c9f194bde248e3affcf1f" title="returns pointers to the internal variance and its inverse. Use with Care!">_R</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1enorm.html#2d92dde696b2a7a5b10ddef5d22ba2c2" title="Covariance matrix in decomposed form.">R</a>;} 107 107 <a name="l00149"></a>00149 108 108 <a name="l00151"></a>00151 <span class="comment">// mat getR () {return R.to_mat();}</span> 109 109 <a name="l00152"></a>00152 }; 110 110 <a name="l00153"></a>00153 111 <a name="l00160"></a><a class="code" href="class egiw.html">00160</a> <span class="keyword">class </span><a class="code" href="classegiw.html" title="Gauss-inverse-Wishart density stored in LD form.">egiw</a> : <span class="keyword">public</span> <a class="code" href="classeEF.html" title="General conjugate exponential family posterior density.">eEF</a> {111 <a name="l00160"></a><a class="code" href="classbdm_1_1egiw.html">00160</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1egiw.html" title="Gauss-inverse-Wishart density stored in LD form.">egiw</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> { 112 112 <a name="l00161"></a>00161 <span class="keyword">protected</span>: 113 <a name="l00163"></a><a class="code" href="class egiw.html#f343d03ede89db820edf44a6297fa442">00163</a> <a class="code" href="classldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a> <a class="code" href="classegiw.html#f343d03ede89db820edf44a6297fa442" title="Extended information matrix of sufficient statistics.">V</a>;114 <a name="l00165"></a><a class="code" href="class egiw.html#4a2f130b91afe84f6d62fed289d5d453">00165</a> <span class="keywordtype">double</span> <a class="code" href="classegiw.html#4a2f130b91afe84f6d62fed289d5d453" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a>;115 <a name="l00167"></a><a class="code" href="class egiw.html#3d5c719f15a5527a6c62c2a53160148e">00167</a> <span class="keywordtype">int</span> <a class="code" href="classegiw.html#3d5c719f15a5527a6c62c2a53160148e" title="Dimension of the output.">xdim</a>;116 <a name="l00169"></a><a class="code" href="class egiw.html#c70d13d86e0d9f0acede3e1dc0368812">00169</a> <span class="keywordtype">int</span> <a class="code" href="classegiw.html#c70d13d86e0d9f0acede3e1dc0368812" title="Dimension of the regressor.">nPsi</a>;113 <a name="l00163"></a><a class="code" href="classbdm_1_1egiw.html#ae56852845c6af176fd9017dbebbbd52">00163</a> <a class="code" href="classldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a> <a class="code" href="classbdm_1_1egiw.html#ae56852845c6af176fd9017dbebbbd52" title="Extended information matrix of sufficient statistics.">V</a>; 114 <a name="l00165"></a><a class="code" href="classbdm_1_1egiw.html#447eacf19d4f4083872686f044814dc4">00165</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1egiw.html#447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a>; 115 <a name="l00167"></a><a class="code" href="classbdm_1_1egiw.html#40b68a9c3b2120fba94cc4d2fcd291e1">00167</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1egiw.html#40b68a9c3b2120fba94cc4d2fcd291e1" title="Dimension of the output.">xdim</a>; 116 <a name="l00169"></a><a class="code" href="classbdm_1_1egiw.html#322414c32d9a21a006a5aab0311f64fd">00169</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1egiw.html#322414c32d9a21a006a5aab0311f64fd" title="Dimension of the regressor.">nPsi</a>; 117 117 <a name="l00170"></a>00170 <span class="keyword">public</span>: 118 <a name="l00172"></a><a class="code" href="class egiw.html#056c094f01ca1cc308d72162f47617c9">00172</a> <a class="code" href="classegiw.html#056c094f01ca1cc308d72162f47617c9" title="Default constructor, if nu0&lt;0 a minimal nu0 will be computed.">egiw</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>, mat V0, <span class="keywordtype">double</span> nu0=-1.0 ) : <a class="code" href="classeEF.html" title="General conjugate exponential family posterior density.">eEF</a> ( rv ), <a class="code" href="classegiw.html#f343d03ede89db820edf44a6297fa442" title="Extended information matrix of sufficient statistics.">V</a> ( V0 ), <a class="code" href="classegiw.html#4a2f130b91afe84f6d62fed289d5d453" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a> ( nu0 ) {119 <a name="l00173"></a>00173 <a class="code" href="class egiw.html#3d5c719f15a5527a6c62c2a53160148e" title="Dimension of the output.">xdim</a> = rv.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>() /<a class="code" href="classegiw.html#f343d03ede89db820edf44a6297fa442" title="Extended information matrix of sufficient statistics.">V</a>.<a class="code" href="group__math.html#g96dfb21865db4f5bd36fa70f9b0b1163" title="access function">rows</a>();120 <a name="l00174"></a>00174 it_assert_debug ( rv.<a class="code" href="class RV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>() ==<a class="code" href="classegiw.html#3d5c719f15a5527a6c62c2a53160148e" title="Dimension of the output.">xdim</a>*<a class="code" href="classegiw.html#f343d03ede89db820edf44a6297fa442" title="Extended information matrix of sufficient statistics.">V</a>.<a class="code" href="group__math.html#g96dfb21865db4f5bd36fa70f9b0b1163" title="access function">rows</a>(),<span class="stringliteral">"Incompatible V0."</span> );121 <a name="l00175"></a>00175 <a class="code" href="class egiw.html#c70d13d86e0d9f0acede3e1dc0368812" title="Dimension of the regressor.">nPsi</a> = <a class="code" href="classegiw.html#f343d03ede89db820edf44a6297fa442" title="Extended information matrix of sufficient statistics.">V</a>.<a class="code" href="group__math.html#g96dfb21865db4f5bd36fa70f9b0b1163" title="access function">rows</a>()-<a class="code" href="classegiw.html#3d5c719f15a5527a6c62c2a53160148e" title="Dimension of the output.">xdim</a>;118 <a name="l00172"></a><a class="code" href="classbdm_1_1egiw.html#a60e072c191acf65ab480deeb11c5b88">00172</a> <a class="code" href="classbdm_1_1egiw.html#a60e072c191acf65ab480deeb11c5b88" title="Default constructor, if nu0&lt;0 a minimal nu0 will be computed.">egiw</a> ( <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a>, mat V0, <span class="keywordtype">double</span> nu0=-1.0 ) : <a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> ( rv ), <a class="code" href="classbdm_1_1egiw.html#ae56852845c6af176fd9017dbebbbd52" title="Extended information matrix of sufficient statistics.">V</a> ( V0 ), <a class="code" href="classbdm_1_1egiw.html#447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a> ( nu0 ) { 119 <a name="l00173"></a>00173 <a class="code" href="classbdm_1_1egiw.html#40b68a9c3b2120fba94cc4d2fcd291e1" title="Dimension of the output.">xdim</a> = rv.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>() /<a class="code" href="classbdm_1_1egiw.html#ae56852845c6af176fd9017dbebbbd52" title="Extended information matrix of sufficient statistics.">V</a>.<a class="code" href="group__math.html#g96dfb21865db4f5bd36fa70f9b0b1163" title="access function">rows</a>(); 120 <a name="l00174"></a>00174 it_assert_debug ( rv.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>() ==<a class="code" href="classbdm_1_1egiw.html#40b68a9c3b2120fba94cc4d2fcd291e1" title="Dimension of the output.">xdim</a>*<a class="code" href="classbdm_1_1egiw.html#ae56852845c6af176fd9017dbebbbd52" title="Extended information matrix of sufficient statistics.">V</a>.<a class="code" href="group__math.html#g96dfb21865db4f5bd36fa70f9b0b1163" title="access function">rows</a>(),<span class="stringliteral">"Incompatible V0."</span> ); 121 <a name="l00175"></a>00175 <a class="code" href="classbdm_1_1egiw.html#322414c32d9a21a006a5aab0311f64fd" title="Dimension of the regressor.">nPsi</a> = <a class="code" href="classbdm_1_1egiw.html#ae56852845c6af176fd9017dbebbbd52" title="Extended information matrix of sufficient statistics.">V</a>.<a class="code" href="group__math.html#g96dfb21865db4f5bd36fa70f9b0b1163" title="access function">rows</a>()-<a class="code" href="classbdm_1_1egiw.html#40b68a9c3b2120fba94cc4d2fcd291e1" title="Dimension of the output.">xdim</a>; 122 122 <a name="l00176"></a>00176 <span class="comment">//set mu to have proper normalization and </span> 123 123 <a name="l00177"></a>00177 <span class="keywordflow">if</span> (nu0<0){ 124 <a name="l00178"></a>00178 <a class="code" href="class egiw.html#4a2f130b91afe84f6d62fed289d5d453" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a> = 0.1 +nPsi +2*<a class="code" href="classegiw.html#3d5c719f15a5527a6c62c2a53160148e" title="Dimension of the output.">xdim</a> +2; <span class="comment">// +2 assures finite expected value of R</span>124 <a name="l00178"></a>00178 <a class="code" href="classbdm_1_1egiw.html#447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a> = 0.1 +nPsi +2*<a class="code" href="classbdm_1_1egiw.html#40b68a9c3b2120fba94cc4d2fcd291e1" title="Dimension of the output.">xdim</a> +2; <span class="comment">// +2 assures finite expected value of R</span> 125 125 <a name="l00179"></a>00179 <span class="comment">// terms before that are sufficient for finite normalization</span> 126 126 <a name="l00180"></a>00180 } 127 127 <a name="l00181"></a>00181 } 128 <a name="l00183"></a><a class="code" href="class egiw.html#18c1bf6125652a6dcbca68dd02dddd8d">00183</a> <a class="code" href="classegiw.html#056c094f01ca1cc308d72162f47617c9" title="Default constructor, if nu0&lt;0 a minimal nu0 will be computed.">egiw</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>, <a class="code" href="classldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a> V0, <span class="keywordtype">double</span> nu0=-1.0 ) : <a class="code" href="classeEF.html" title="General conjugate exponential family posterior density.">eEF</a> ( rv ), <a class="code" href="classegiw.html#f343d03ede89db820edf44a6297fa442" title="Extended information matrix of sufficient statistics.">V</a> ( V0 ), <a class="code" href="classegiw.html#4a2f130b91afe84f6d62fed289d5d453" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a> ( nu0 ) {129 <a name="l00184"></a>00184 <a class="code" href="class egiw.html#3d5c719f15a5527a6c62c2a53160148e" title="Dimension of the output.">xdim</a> = rv.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>() /<a class="code" href="classegiw.html#f343d03ede89db820edf44a6297fa442" title="Extended information matrix of sufficient statistics.">V</a>.<a class="code" href="group__math.html#g96dfb21865db4f5bd36fa70f9b0b1163" title="access function">rows</a>();130 <a name="l00185"></a>00185 it_assert_debug ( rv.<a class="code" href="class RV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>() ==<a class="code" href="classegiw.html#3d5c719f15a5527a6c62c2a53160148e" title="Dimension of the output.">xdim</a>*<a class="code" href="classegiw.html#f343d03ede89db820edf44a6297fa442" title="Extended information matrix of sufficient statistics.">V</a>.<a class="code" href="group__math.html#g96dfb21865db4f5bd36fa70f9b0b1163" title="access function">rows</a>(),<span class="stringliteral">"Incompatible V0."</span> );131 <a name="l00186"></a>00186 <a class="code" href="class egiw.html#c70d13d86e0d9f0acede3e1dc0368812" title="Dimension of the regressor.">nPsi</a> = <a class="code" href="classegiw.html#f343d03ede89db820edf44a6297fa442" title="Extended information matrix of sufficient statistics.">V</a>.<a class="code" href="group__math.html#g96dfb21865db4f5bd36fa70f9b0b1163" title="access function">rows</a>()-<a class="code" href="classegiw.html#3d5c719f15a5527a6c62c2a53160148e" title="Dimension of the output.">xdim</a>;128 <a name="l00183"></a><a class="code" href="classbdm_1_1egiw.html#bc3db93cb60dd29187eb3c6cfd557f97">00183</a> <a class="code" href="classbdm_1_1egiw.html#a60e072c191acf65ab480deeb11c5b88" title="Default constructor, if nu0&lt;0 a minimal nu0 will be computed.">egiw</a> ( <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a>, <a class="code" href="classldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a> V0, <span class="keywordtype">double</span> nu0=-1.0 ) : <a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> ( rv ), <a class="code" href="classbdm_1_1egiw.html#ae56852845c6af176fd9017dbebbbd52" title="Extended information matrix of sufficient statistics.">V</a> ( V0 ), <a class="code" href="classbdm_1_1egiw.html#447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a> ( nu0 ) { 129 <a name="l00184"></a>00184 <a class="code" href="classbdm_1_1egiw.html#40b68a9c3b2120fba94cc4d2fcd291e1" title="Dimension of the output.">xdim</a> = rv.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>() /<a class="code" href="classbdm_1_1egiw.html#ae56852845c6af176fd9017dbebbbd52" title="Extended information matrix of sufficient statistics.">V</a>.<a class="code" href="group__math.html#g96dfb21865db4f5bd36fa70f9b0b1163" title="access function">rows</a>(); 130 <a name="l00185"></a>00185 it_assert_debug ( rv.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>() ==<a class="code" href="classbdm_1_1egiw.html#40b68a9c3b2120fba94cc4d2fcd291e1" title="Dimension of the output.">xdim</a>*<a class="code" href="classbdm_1_1egiw.html#ae56852845c6af176fd9017dbebbbd52" title="Extended information matrix of sufficient statistics.">V</a>.<a class="code" href="group__math.html#g96dfb21865db4f5bd36fa70f9b0b1163" title="access function">rows</a>(),<span class="stringliteral">"Incompatible V0."</span> ); 131 <a name="l00186"></a>00186 <a class="code" href="classbdm_1_1egiw.html#322414c32d9a21a006a5aab0311f64fd" title="Dimension of the regressor.">nPsi</a> = <a class="code" href="classbdm_1_1egiw.html#ae56852845c6af176fd9017dbebbbd52" title="Extended information matrix of sufficient statistics.">V</a>.<a class="code" href="group__math.html#g96dfb21865db4f5bd36fa70f9b0b1163" title="access function">rows</a>()-<a class="code" href="classbdm_1_1egiw.html#40b68a9c3b2120fba94cc4d2fcd291e1" title="Dimension of the output.">xdim</a>; 132 132 <a name="l00187"></a>00187 <span class="keywordflow">if</span> (nu0<0){ 133 <a name="l00188"></a>00188 <a class="code" href="class egiw.html#4a2f130b91afe84f6d62fed289d5d453" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a> = 0.1 +nPsi +2*<a class="code" href="classegiw.html#3d5c719f15a5527a6c62c2a53160148e" title="Dimension of the output.">xdim</a> +2; <span class="comment">// +2 assures finite expected value of R</span>133 <a name="l00188"></a>00188 <a class="code" href="classbdm_1_1egiw.html#447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a> = 0.1 +nPsi +2*<a class="code" href="classbdm_1_1egiw.html#40b68a9c3b2120fba94cc4d2fcd291e1" title="Dimension of the output.">xdim</a> +2; <span class="comment">// +2 assures finite expected value of R</span> 134 134 <a name="l00189"></a>00189 <span class="comment">// terms before that are sufficient for finite normalization</span> 135 135 <a name="l00190"></a>00190 } 136 136 <a name="l00191"></a>00191 } 137 137 <a name="l00192"></a>00192 138 <a name="l00193"></a>00193 vec <a class="code" href="class egiw.html#3d2c1f2ba0f9966781f1e0ae695e8a6f" title="Returns a sample, from density .">sample</a>() <span class="keyword">const</span>;139 <a name="l00194"></a>00194 vec <a class="code" href="class egiw.html#6deb0ff2859f41ef7cbdf6a842cabb29" title="return expected value">mean</a>() <span class="keyword">const</span>;140 <a name="l00195"></a><a class="code" href="class egiw.html#458a89e32dfcc363daa4b6d5335ac791">00195</a> vec <a class="code" href="classegiw.html#458a89e32dfcc363daa4b6d5335ac791" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const</span>{it_error(<span class="stringliteral">"Not implemented"</span>); <span class="keywordflow">return</span> vec(0);};138 <a name="l00193"></a>00193 vec <a class="code" href="classbdm_1_1egiw.html#920f21548b7a3723923dd108fe514c61" title="Returns a sample, from density .">sample</a>() <span class="keyword">const</span>; 139 <a name="l00194"></a>00194 vec <a class="code" href="classbdm_1_1egiw.html#df70c05f918c3a6f86d60f10c1fd6ba2" title="return expected value">mean</a>() <span class="keyword">const</span>; 140 <a name="l00195"></a><a class="code" href="classbdm_1_1egiw.html#c1ecc406613cc2341225dc10c3d3b46a">00195</a> vec <a class="code" href="classbdm_1_1egiw.html#c1ecc406613cc2341225dc10c3d3b46a" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const</span>{it_error(<span class="stringliteral">"Not implemented"</span>); <span class="keywordflow">return</span> vec(0);}; 141 141 <a name="l00196"></a>00196 <span class="keywordtype">void</span> mean_mat ( mat &M, mat&R ) <span class="keyword">const</span>; 142 <a name="l00198"></a>00198 <span class="keywordtype">double</span> <a class="code" href="class egiw.html#2d94daac10d66bb743e4ddc8c1ba7268" title="In this instance, val= [theta, r]. For multivariate instances, it is stored columnwise...">evallog_nn</a> ( <span class="keyword">const</span> vec &val ) <span class="keyword">const</span>;143 <a name="l00199"></a>00199 <span class="keywordtype">double</span> <a class="code" href="class egiw.html#70eb1a0b88459b227f919b425b0d3359" title="logarithm of the normalizing constant, ">lognc</a> () <span class="keyword">const</span>;142 <a name="l00198"></a>00198 <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1egiw.html#bfb8e7c619b34ad804a73bff71742b5e" title="In this instance, val= [theta, r]. For multivariate instances, it is stored columnwise...">evallog_nn</a> ( <span class="keyword">const</span> vec &val ) <span class="keyword">const</span>; 143 <a name="l00199"></a>00199 <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1egiw.html#41d72ba7b2abc8a9a4209ffa98ed5633" title="logarithm of the normalizing constant, ">lognc</a> () <span class="keyword">const</span>; 144 144 <a name="l00200"></a>00200 145 145 <a name="l00201"></a>00201 <span class="comment">//Access</span> 146 <a name="l00203"></a><a class="code" href="class egiw.html#533e792e1175bfa06d5d595dc5d080d5">00203</a> <span class="comment"></span> <a class="code" href="classldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a>& <a class="code" href="classegiw.html#533e792e1175bfa06d5d595dc5d080d5" title="returns a pointer to the internal statistics. Use with Care!">_V</a>() {<span class="keywordflow">return</span> <a class="code" href="classegiw.html#f343d03ede89db820edf44a6297fa442" title="Extended information matrix of sufficient statistics.">V</a>;}147 <a name="l00205"></a><a class="code" href="class egiw.html#a46c8a206edf80b357a138d7491780c1">00205</a> <span class="keyword">const</span> <a class="code" href="classldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a>& <a class="code" href="classegiw.html#533e792e1175bfa06d5d595dc5d080d5" title="returns a pointer to the internal statistics. Use with Care!">_V</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classegiw.html#f343d03ede89db820edf44a6297fa442" title="Extended information matrix of sufficient statistics.">V</a>;}148 <a name="l00207"></a><a class="code" href="class egiw.html#08029c481ff95d24f093df0573879afe">00207</a> <span class="keywordtype">double</span>& <a class="code" href="classegiw.html#08029c481ff95d24f093df0573879afe" title="returns a pointer to the internal statistics. Use with Care!">_nu</a>() {<span class="keywordflow">return</span> <a class="code" href="classegiw.html#4a2f130b91afe84f6d62fed289d5d453" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a>;}149 <a name="l00208"></a>00208 <span class="keyword">const</span> <span class="keywordtype">double</span>& <a class="code" href="class egiw.html#08029c481ff95d24f093df0573879afe" title="returns a pointer to the internal statistics. Use with Care!">_nu</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classegiw.html#4a2f130b91afe84f6d62fed289d5d453" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a>;}150 <a name="l00209"></a><a class="code" href="class egiw.html#036306322a90a9977834baac07460816">00209</a> <span class="keywordtype">void</span> <a class="code" href="classegiw.html#036306322a90a9977834baac07460816" title="Power of the density, used e.g. to flatten the density.">pow</a> ( <span class="keywordtype">double</span> p ) {<a class="code" href="classegiw.html#f343d03ede89db820edf44a6297fa442" title="Extended information matrix of sufficient statistics.">V</a>*=p;<a class="code" href="classegiw.html#4a2f130b91afe84f6d62fed289d5d453" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a>*=p;};146 <a name="l00203"></a><a class="code" href="classbdm_1_1egiw.html#15792f3112e5cf67d572f491b09324c8">00203</a> <span class="comment"></span> <a class="code" href="classldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a>& <a class="code" href="classbdm_1_1egiw.html#15792f3112e5cf67d572f491b09324c8" title="returns a pointer to the internal statistics. Use with Care!">_V</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1egiw.html#ae56852845c6af176fd9017dbebbbd52" title="Extended information matrix of sufficient statistics.">V</a>;} 147 <a name="l00205"></a><a class="code" href="classbdm_1_1egiw.html#ad9c539a80a552e837245ddcebcbbba4">00205</a> <span class="keyword">const</span> <a class="code" href="classldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a>& <a class="code" href="classbdm_1_1egiw.html#15792f3112e5cf67d572f491b09324c8" title="returns a pointer to the internal statistics. Use with Care!">_V</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1egiw.html#ae56852845c6af176fd9017dbebbbd52" title="Extended information matrix of sufficient statistics.">V</a>;} 148 <a name="l00207"></a><a class="code" href="classbdm_1_1egiw.html#a025ee710274ca142dd0ae978735ad4a">00207</a> <span class="keywordtype">double</span>& <a class="code" href="classbdm_1_1egiw.html#a025ee710274ca142dd0ae978735ad4a" title="returns a pointer to the internal statistics. Use with Care!">_nu</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1egiw.html#447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a>;} 149 <a name="l00208"></a>00208 <span class="keyword">const</span> <span class="keywordtype">double</span>& <a class="code" href="classbdm_1_1egiw.html#a025ee710274ca142dd0ae978735ad4a" title="returns a pointer to the internal statistics. Use with Care!">_nu</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1egiw.html#447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a>;} 150 <a name="l00209"></a><a class="code" href="classbdm_1_1egiw.html#8e610e95401a11baf34f65e16ecd87be">00209</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egiw.html#8e610e95401a11baf34f65e16ecd87be" title="Power of the density, used e.g. to flatten the density.">pow</a> ( <span class="keywordtype">double</span> p ) {<a class="code" href="classbdm_1_1egiw.html#ae56852845c6af176fd9017dbebbbd52" title="Extended information matrix of sufficient statistics.">V</a>*=p;<a class="code" href="classbdm_1_1egiw.html#447eacf19d4f4083872686f044814dc4" title="Number of data records (degrees of freedom) of sufficient statistics.">nu</a>*=p;}; 151 151 <a name="l00210"></a>00210 }; 152 152 <a name="l00211"></a>00211 153 <a name="l00220"></a><a class="code" href="class eDirich.html">00220</a> <span class="keyword">class </span><a class="code" href="classeDirich.html" title="Dirichlet posterior density.">eDirich</a>: <span class="keyword">public</span> <a class="code" href="classeEF.html" title="General conjugate exponential family posterior density.">eEF</a> {153 <a name="l00220"></a><a class="code" href="classbdm_1_1eDirich.html">00220</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1eDirich.html" title="Dirichlet posterior density.">eDirich</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> { 154 154 <a name="l00221"></a>00221 <span class="keyword">protected</span>: 155 <a name="l00223"></a><a class="code" href="class eDirich.html#15e6b65e9595eedc8a1286c6cecd36d7">00223</a> vec <a class="code" href="classeDirich.html#15e6b65e9595eedc8a1286c6cecd36d7" title="sufficient statistics">beta</a>;156 <a name="l00225"></a><a class="code" href="class eDirich.html#a4f34a1b98ee6d09688b8d0f043ac10d">00225</a> <span class="keywordtype">double</span> <a class="code" href="classeDirich.html#a4f34a1b98ee6d09688b8d0f043ac10d" title="speedup variable">gamma</a>;155 <a name="l00223"></a><a class="code" href="classbdm_1_1eDirich.html#f25886a49b4667af61245de81c83b5d2">00223</a> vec <a class="code" href="classbdm_1_1eDirich.html#f25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>; 156 <a name="l00225"></a><a class="code" href="classbdm_1_1eDirich.html#ee9db192a6f0ab7b29c33b2a18a5e1b4">00225</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eDirich.html#ee9db192a6f0ab7b29c33b2a18a5e1b4" title="speedup variable">gamma</a>; 157 157 <a name="l00226"></a>00226 <span class="keyword">public</span>: 158 <a name="l00228"></a><a class="code" href="class eDirich.html#ac7e6116f3575c3860d07355e96cd4af">00228</a> <a class="code" href="classeDirich.html#ac7e6116f3575c3860d07355e96cd4af" title="Default constructor.">eDirich</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>, <span class="keyword">const</span> vec &beta0 ) : <a class="code" href="classeEF.html" title="General conjugate exponential family posterior density.">eEF</a> ( rv ),<a class="code" href="classeDirich.html#15e6b65e9595eedc8a1286c6cecd36d7" title="sufficient statistics">beta</a> ( beta0 ) {it_assert_debug ( rv.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>() ==<a class="code" href="classeDirich.html#15e6b65e9595eedc8a1286c6cecd36d7" title="sufficient statistics">beta</a>.length(),<span class="stringliteral">"Incompatible statistics"</span> ); };159 <a name="l00230"></a><a class="code" href="class eDirich.html#55cccbc5eb44764dce722567acf5fd58">00230</a> <a class="code" href="classeDirich.html#ac7e6116f3575c3860d07355e96cd4af" title="Default constructor.">eDirich</a> ( <span class="keyword">const</span> <a class="code" href="classeDirich.html" title="Dirichlet posterior density.">eDirich</a> &D0 ) : <a class="code" href="classeEF.html" title="General conjugate exponential family posterior density.">eEF</a> ( D0.<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ),<a class="code" href="classeDirich.html#15e6b65e9595eedc8a1286c6cecd36d7" title="sufficient statistics">beta</a> ( D0.<a class="code" href="classeDirich.html#15e6b65e9595eedc8a1286c6cecd36d7" title="sufficient statistics">beta</a> ) {};160 <a name="l00231"></a><a class="code" href="class eDirich.html#23dff79110822e9639343fe8e177fd80">00231</a> vec <a class="code" href="classeDirich.html#23dff79110822e9639343fe8e177fd80" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{it_error ( <span class="stringliteral">"Not implemented"</span> );<span class="keywordflow">return</span> vec_1 ( 0.0 );};161 <a name="l00232"></a><a class="code" href="class eDirich.html#4206e1da149d51ff3b663c9241096b73">00232</a> vec <a class="code" href="classeDirich.html#4206e1da149d51ff3b663c9241096b73" title="return expected value">mean</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classeDirich.html#15e6b65e9595eedc8a1286c6cecd36d7" title="sufficient statistics">beta</a>/<a class="code" href="classeDirich.html#a4f34a1b98ee6d09688b8d0f043ac10d" title="speedup variable">gamma</a>;};162 <a name="l00233"></a><a class="code" href="class eDirich.html#eaf157ad4c0d191bc17061f29fb76da1">00233</a> vec <a class="code" href="classeDirich.html#eaf157ad4c0d191bc17061f29fb76da1" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> elem_mult(<a class="code" href="classeDirich.html#15e6b65e9595eedc8a1286c6cecd36d7" title="sufficient statistics">beta</a>,(<a class="code" href="classeDirich.html#15e6b65e9595eedc8a1286c6cecd36d7" title="sufficient statistics">beta</a>+1))/ (<a class="code" href="classeDirich.html#a4f34a1b98ee6d09688b8d0f043ac10d" title="speedup variable">gamma</a>*(<a class="code" href="classeDirich.html#a4f34a1b98ee6d09688b8d0f043ac10d" title="speedup variable">gamma</a>+1));}163 <a name="l00235"></a><a class="code" href="class eDirich.html#bb4b14ed7794777386de10608a83d142">00235</a> <span class="keywordtype">double</span> <a class="code" href="classeDirich.html#bb4b14ed7794777386de10608a83d142" title="In this instance, val is ...">evallog_nn</a> ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{<span class="keywordtype">double</span> tmp; tmp=( <a class="code" href="classeDirich.html#15e6b65e9595eedc8a1286c6cecd36d7" title="sufficient statistics">beta</a>-1 ) *log ( val ); it_assert_debug(std::isfinite(tmp),<span class="stringliteral">"Infinite value"</span>);158 <a name="l00228"></a><a class="code" href="classbdm_1_1eDirich.html#2ae893fe9167f67bca09bc159acbf957">00228</a> <a class="code" href="classbdm_1_1eDirich.html#2ae893fe9167f67bca09bc159acbf957" title="Default constructor.">eDirich</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a>, <span class="keyword">const</span> vec &beta0 ) : <a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> ( rv ),<a class="code" href="classbdm_1_1eDirich.html#f25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a> ( beta0 ) {it_assert_debug ( rv.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>() ==<a class="code" href="classbdm_1_1eDirich.html#f25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>.length(),<span class="stringliteral">"Incompatible statistics"</span> ); }; 159 <a name="l00230"></a><a class="code" href="classbdm_1_1eDirich.html#31cc8bf709552c9e7286ac16b27c8e2c">00230</a> <a class="code" href="classbdm_1_1eDirich.html#2ae893fe9167f67bca09bc159acbf957" title="Default constructor.">eDirich</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1eDirich.html" title="Dirichlet posterior density.">eDirich</a> &D0 ) : <a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> ( D0.<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a> ),<a class="code" href="classbdm_1_1eDirich.html#f25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a> ( D0.<a class="code" href="classbdm_1_1eDirich.html#f25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a> ) {}; 160 <a name="l00231"></a><a class="code" href="classbdm_1_1eDirich.html#3290613d31d58daa8a45a54b003871fc">00231</a> vec <a class="code" href="classbdm_1_1eDirich.html#3290613d31d58daa8a45a54b003871fc" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{it_error ( <span class="stringliteral">"Not implemented"</span> );<span class="keywordflow">return</span> vec_1 ( 0.0 );}; 161 <a name="l00232"></a><a class="code" href="classbdm_1_1eDirich.html#cb343355ec791298bb5a3404cd482fb6">00232</a> vec <a class="code" href="classbdm_1_1eDirich.html#cb343355ec791298bb5a3404cd482fb6" title="return expected value">mean</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eDirich.html#f25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>/<a class="code" href="classbdm_1_1eDirich.html#ee9db192a6f0ab7b29c33b2a18a5e1b4" title="speedup variable">gamma</a>;}; 162 <a name="l00233"></a><a class="code" href="classbdm_1_1eDirich.html#43c547a2507e233706f92712d8c2aacc">00233</a> vec <a class="code" href="classbdm_1_1eDirich.html#43c547a2507e233706f92712d8c2aacc" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> elem_mult(<a class="code" href="classbdm_1_1eDirich.html#f25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>,(<a class="code" href="classbdm_1_1eDirich.html#f25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>+1))/ (<a class="code" href="classbdm_1_1eDirich.html#ee9db192a6f0ab7b29c33b2a18a5e1b4" title="speedup variable">gamma</a>*(<a class="code" href="classbdm_1_1eDirich.html#ee9db192a6f0ab7b29c33b2a18a5e1b4" title="speedup variable">gamma</a>+1));} 163 <a name="l00235"></a><a class="code" href="classbdm_1_1eDirich.html#e09a24938e80c3d94b0ee842d1552318">00235</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eDirich.html#e09a24938e80c3d94b0ee842d1552318" title="In this instance, val is ...">evallog_nn</a> ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{<span class="keywordtype">double</span> tmp; tmp=( <a class="code" href="classbdm_1_1eDirich.html#f25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>-1 ) *log ( val ); it_assert_debug(std::isfinite(tmp),<span class="stringliteral">"Infinite value"</span>); 164 164 <a name="l00236"></a>00236 <span class="keywordflow">return</span> tmp;}; 165 <a name="l00237"></a><a class="code" href="class eDirich.html#7ce60be7119ffc639ede4e583c1f6e77">00237</a> <span class="keywordtype">double</span> <a class="code" href="classeDirich.html#7ce60be7119ffc639ede4e583c1f6e77" title="logarithm of the normalizing constant, ">lognc</a> ()<span class="keyword"> const </span>{165 <a name="l00237"></a><a class="code" href="classbdm_1_1eDirich.html#279a99f6266c82fe2273e83841f19eb2">00237</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eDirich.html#279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a> ()<span class="keyword"> const </span>{ 166 166 <a name="l00238"></a>00238 <span class="keywordtype">double</span> tmp; 167 <a name="l00239"></a>00239 <span class="keywordtype">double</span> gam=sum ( <a class="code" href="class eDirich.html#15e6b65e9595eedc8a1286c6cecd36d7" title="sufficient statistics">beta</a> );167 <a name="l00239"></a>00239 <span class="keywordtype">double</span> gam=sum ( <a class="code" href="classbdm_1_1eDirich.html#f25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a> ); 168 168 <a name="l00240"></a>00240 <span class="keywordtype">double</span> lgb=0.0; 169 <a name="l00241"></a>00241 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="class eDirich.html#15e6b65e9595eedc8a1286c6cecd36d7" title="sufficient statistics">beta</a>.length();i++ ) {lgb+=lgamma ( <a class="code" href="classeDirich.html#15e6b65e9595eedc8a1286c6cecd36d7" title="sufficient statistics">beta</a> ( i ) );}169 <a name="l00241"></a>00241 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eDirich.html#f25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>.length();i++ ) {lgb+=lgamma ( <a class="code" href="classbdm_1_1eDirich.html#f25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a> ( i ) );} 170 170 <a name="l00242"></a>00242 tmp= lgb-lgamma ( gam ); 171 171 <a name="l00243"></a>00243 it_assert_debug(std::isfinite(tmp),<span class="stringliteral">"Infinite value"</span>); 172 172 <a name="l00244"></a>00244 <span class="keywordflow">return</span> tmp; 173 173 <a name="l00245"></a>00245 }; 174 <a name="l00247"></a><a class="code" href="class eDirich.html#6409d0362143a23976b43641ff19e53a">00247</a> vec& <a class="code" href="classeDirich.html#6409d0362143a23976b43641ff19e53a" title="access function">_beta</a>() {<span class="keywordflow">return</span> <a class="code" href="classeDirich.html#15e6b65e9595eedc8a1286c6cecd36d7" title="sufficient statistics">beta</a>;}175 <a name="l00249"></a><a class="code" href="class eDirich.html#c842acb2e1cce5cc9000769ff06c086d">00249</a> <span class="keywordtype">void</span> <a class="code" href="classeDirich.html#c842acb2e1cce5cc9000769ff06c086d" title="Set internal parameters.">set_parameters</a> ( <span class="keyword">const</span> vec &beta0 ) {176 <a name="l00250"></a>00250 <span class="keywordflow">if</span> ( beta0.length() !=<a class="code" href="class eDirich.html#15e6b65e9595eedc8a1286c6cecd36d7" title="sufficient statistics">beta</a>.length() ) {177 <a name="l00251"></a>00251 it_assert_debug ( <a class="code" href="class epdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>.<a class="code" href="classRV.html#c114a6f3ff06796cc2f4dacba74291eb" title="Return length (number of entries) of the RV.">length</a>() ==1,<span class="stringliteral">"Undefined"</span> );178 <a name="l00252"></a>00252 <a class="code" href="class epdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>.<a class="code" href="classRV.html#70b24c39c5130b1e4753fa2eef495433" title="access function">set_size</a> ( 0,beta0.length() );174 <a name="l00247"></a><a class="code" href="classbdm_1_1eDirich.html#175e0add26d2105c28d8121eefb9e324">00247</a> vec& <a class="code" href="classbdm_1_1eDirich.html#175e0add26d2105c28d8121eefb9e324" title="access function">_beta</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eDirich.html#f25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>;} 175 <a name="l00249"></a><a class="code" href="classbdm_1_1eDirich.html#a06af2376976a33e1eceaed7e8da75a5">00249</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eDirich.html#a06af2376976a33e1eceaed7e8da75a5" title="Set internal parameters.">set_parameters</a> ( <span class="keyword">const</span> vec &beta0 ) { 176 <a name="l00250"></a>00250 <span class="keywordflow">if</span> ( beta0.length() !=<a class="code" href="classbdm_1_1eDirich.html#f25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>.length() ) { 177 <a name="l00251"></a>00251 it_assert_debug ( <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#e9ec8c3e756651ff352ab5e3d3acda4b" title="Return length (number of entries) of the RV.">length</a>() ==1,<span class="stringliteral">"Undefined"</span> ); 178 <a name="l00252"></a>00252 <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#0b2c9e73ff66847c3644ebc3eb559a03" title="access function">set_size</a> ( 0,beta0.length() ); 179 179 <a name="l00253"></a>00253 } 180 <a name="l00254"></a>00254 <a class="code" href="class eDirich.html#15e6b65e9595eedc8a1286c6cecd36d7" title="sufficient statistics">beta</a>= beta0;181 <a name="l00255"></a>00255 <a class="code" href="class eDirich.html#a4f34a1b98ee6d09688b8d0f043ac10d" title="speedup variable">gamma</a> = sum(<a class="code" href="classeDirich.html#15e6b65e9595eedc8a1286c6cecd36d7" title="sufficient statistics">beta</a>);180 <a name="l00254"></a>00254 <a class="code" href="classbdm_1_1eDirich.html#f25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>= beta0; 181 <a name="l00255"></a>00255 <a class="code" href="classbdm_1_1eDirich.html#ee9db192a6f0ab7b29c33b2a18a5e1b4" title="speedup variable">gamma</a> = sum(<a class="code" href="classbdm_1_1eDirich.html#f25886a49b4667af61245de81c83b5d2" title="sufficient statistics">beta</a>); 182 182 <a name="l00256"></a>00256 } 183 183 <a name="l00257"></a>00257 }; 184 184 <a name="l00258"></a>00258 185 <a name="l00260"></a><a class="code" href="class multiBM.html">00260</a> <span class="keyword">class </span><a class="code" href="classmultiBM.html" title="Estimator for Multinomial density.">multiBM</a> : <span class="keyword">public</span> <a class="code" href="classBMEF.html" title="Estimator for Exponential family.">BMEF</a> {185 <a name="l00260"></a><a class="code" href="classbdm_1_1multiBM.html">00260</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1multiBM.html" title="Estimator for Multinomial density.">multiBM</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a> { 186 186 <a name="l00261"></a>00261 <span class="keyword">protected</span>: 187 <a name="l00263"></a><a class="code" href="class multiBM.html#eddee08a724170de63f36e40c57b27b5">00263</a> <a class="code" href="classeDirich.html" title="Dirichlet posterior density.">eDirich</a> <a class="code" href="classmultiBM.html#eddee08a724170de63f36e40c57b27b5" title="Conjugate prior and posterior.">est</a>;188 <a name="l00265"></a><a class="code" href="class multiBM.html#7b606116aed7e8834a339cbb0424b1d6">00265</a> vec &<a class="code" href="classmultiBM.html#7b606116aed7e8834a339cbb0424b1d6" title="Pointer inside est to sufficient statistics.">beta</a>;187 <a name="l00263"></a><a class="code" href="classbdm_1_1multiBM.html#9ecc6878abbd20eb8d8e43b6ab3f941a">00263</a> <a class="code" href="classbdm_1_1eDirich.html" title="Dirichlet posterior density.">eDirich</a> <a class="code" href="classbdm_1_1multiBM.html#9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>; 188 <a name="l00265"></a><a class="code" href="classbdm_1_1multiBM.html#044263356944c92209eecd39a5187d25">00265</a> vec &<a class="code" href="classbdm_1_1multiBM.html#044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a>; 189 189 <a name="l00266"></a>00266 <span class="keyword">public</span>: 190 <a name="l00268"></a><a class="code" href="class multiBM.html#7d7d7e78c129602bcde96078359dc6e5">00268</a> <a class="code" href="classmultiBM.html#7d7d7e78c129602bcde96078359dc6e5" title="Default constructor.">multiBM</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a>, <span class="keyword">const</span> vec beta0 ) : <a class="code" href="classBMEF.html" title="Estimator for Exponential family.">BMEF</a> ( rv ),<a class="code" href="classmultiBM.html#eddee08a724170de63f36e40c57b27b5" title="Conjugate prior and posterior.">est</a> ( rv,beta0 ),<a class="code" href="classmultiBM.html#7b606116aed7e8834a339cbb0424b1d6" title="Pointer inside est to sufficient statistics.">beta</a> ( <a class="code" href="classmultiBM.html#eddee08a724170de63f36e40c57b27b5" title="Conjugate prior and posterior.">est</a>._beta() ) {<span class="keywordflow">if</span>(<a class="code" href="classmultiBM.html#7b606116aed7e8834a339cbb0424b1d6" title="Pointer inside est to sufficient statistics.">beta</a>.length()>0){<a class="code" href="classBMEF.html#308cf5d4133cd471fdf1ecd5dfa09d02" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>=<a class="code" href="classmultiBM.html#eddee08a724170de63f36e40c57b27b5" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classeDirich.html#7ce60be7119ffc639ede4e583c1f6e77" title="logarithm of the normalizing constant, ">lognc</a>();}<span class="keywordflow">else</span>{<a class="code" href="classBMEF.html#308cf5d4133cd471fdf1ecd5dfa09d02" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>=0.0;}}191 <a name="l00270"></a><a class="code" href="class multiBM.html#b92751adbfb9f259ca8c95232cfd9c09">00270</a> <a class="code" href="classmultiBM.html#7d7d7e78c129602bcde96078359dc6e5" title="Default constructor.">multiBM</a> ( <span class="keyword">const</span> <a class="code" href="classmultiBM.html" title="Estimator for Multinomial density.">multiBM</a> &B ) : <a class="code" href="classBMEF.html" title="Estimator for Exponential family.">BMEF</a> ( B ),<a class="code" href="classmultiBM.html#eddee08a724170de63f36e40c57b27b5" title="Conjugate prior and posterior.">est</a> ( <a class="code" href="classBM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a>,B.<a class="code" href="classmultiBM.html#7b606116aed7e8834a339cbb0424b1d6" title="Pointer inside est to sufficient statistics.">beta</a> ),<a class="code" href="classmultiBM.html#7b606116aed7e8834a339cbb0424b1d6" title="Pointer inside est to sufficient statistics.">beta</a> ( <a class="code" href="classmultiBM.html#eddee08a724170de63f36e40c57b27b5" title="Conjugate prior and posterior.">est</a>._beta() ) {}192 <a name="l00272"></a><a class="code" href="class multiBM.html#42e36804041e551d3ceea6c75abc0562">00272</a> <span class="keywordtype">void</span> <a class="code" href="classmultiBM.html#42e36804041e551d3ceea6c75abc0562" title="Sets sufficient statistics to match that of givefrom mB0.">set_statistics</a> ( <span class="keyword">const</span> <a class="code" href="classBM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a>* mB0 ) {<span class="keyword">const</span> <a class="code" href="classmultiBM.html" title="Estimator for Multinomial density.">multiBM</a>* mB=<span class="keyword">dynamic_cast<</span><span class="keyword">const </span><a class="code" href="classmultiBM.html" title="Estimator for Multinomial density.">multiBM</a>*<span class="keyword">></span> ( mB0 ); <a class="code" href="classmultiBM.html#7b606116aed7e8834a339cbb0424b1d6" title="Pointer inside est to sufficient statistics.">beta</a>=mB-><a class="code" href="classmultiBM.html#7b606116aed7e8834a339cbb0424b1d6" title="Pointer inside est to sufficient statistics.">beta</a>;}193 <a name="l00273"></a><a class="code" href="class multiBM.html#11eeba7e97954e316e959116f90d80e2">00273</a> <span class="keywordtype">void</span> <a class="code" href="classmultiBM.html#11eeba7e97954e316e959116f90d80e2" title="Incremental Bayes rule.">bayes</a> ( <span class="keyword">const</span> vec &dt ) {194 <a name="l00274"></a>00274 <span class="keywordflow">if</span> ( <a class="code" href="class BMEF.html#538d632e59f9afa8daa1de74da12ce71" title="forgetting factor">frg</a><1.0 ) {<a class="code" href="classmultiBM.html#7b606116aed7e8834a339cbb0424b1d6" title="Pointer inside est to sufficient statistics.">beta</a>*=<a class="code" href="classBMEF.html#538d632e59f9afa8daa1de74da12ce71" title="forgetting factor">frg</a>;<a class="code" href="classBMEF.html#308cf5d4133cd471fdf1ecd5dfa09d02" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>=<a class="code" href="classmultiBM.html#eddee08a724170de63f36e40c57b27b5" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classeDirich.html#7ce60be7119ffc639ede4e583c1f6e77" title="logarithm of the normalizing constant, ">lognc</a>();}195 <a name="l00275"></a>00275 <a class="code" href="class multiBM.html#7b606116aed7e8834a339cbb0424b1d6" title="Pointer inside est to sufficient statistics.">beta</a>+=dt;196 <a name="l00276"></a>00276 <span class="keywordflow">if</span> ( <a class="code" href="class BM.html#bf6fb59b30141074f8ee1e2f43d03129" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a> ) {<a class="code" href="classBM.html#5623fef6572a08c2b53b8c87b82dc979" title="Logarithm of marginalized data likelihood.">ll</a>=<a class="code" href="classmultiBM.html#eddee08a724170de63f36e40c57b27b5" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classeDirich.html#7ce60be7119ffc639ede4e583c1f6e77" title="logarithm of the normalizing constant, ">lognc</a>()-<a class="code" href="classBMEF.html#308cf5d4133cd471fdf1ecd5dfa09d02" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>;}190 <a name="l00268"></a><a class="code" href="classbdm_1_1multiBM.html#65dc7567b67ce86a8f339dd496ed8e88">00268</a> <a class="code" href="classbdm_1_1multiBM.html#65dc7567b67ce86a8f339dd496ed8e88" title="Default constructor.">multiBM</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1BM.html#18d6db4af8ee42077741d9e3618153ca" title="Random variable of the posterior.">rv</a>, <span class="keyword">const</span> vec beta0 ) : <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a> ( rv ),<a class="code" href="classbdm_1_1multiBM.html#9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a> ( rv,beta0 ),<a class="code" href="classbdm_1_1multiBM.html#044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a> ( <a class="code" href="classbdm_1_1multiBM.html#9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>._beta() ) {<span class="keywordflow">if</span>(<a class="code" href="classbdm_1_1multiBM.html#044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a>.length()>0){<a class="code" href="classbdm_1_1BMEF.html#06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>=<a class="code" href="classbdm_1_1multiBM.html#9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classbdm_1_1eDirich.html#279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>();}<span class="keywordflow">else</span>{<a class="code" href="classbdm_1_1BMEF.html#06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>=0.0;}} 191 <a name="l00270"></a><a class="code" href="classbdm_1_1multiBM.html#c4378cf8037f6bed29c74eea63344b31">00270</a> <a class="code" href="classbdm_1_1multiBM.html#65dc7567b67ce86a8f339dd496ed8e88" title="Default constructor.">multiBM</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1multiBM.html" title="Estimator for Multinomial density.">multiBM</a> &B ) : <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a> ( B ),<a class="code" href="classbdm_1_1multiBM.html#9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a> ( <a class="code" href="classbdm_1_1BM.html#18d6db4af8ee42077741d9e3618153ca" title="Random variable of the posterior.">rv</a>,B.<a class="code" href="classbdm_1_1multiBM.html#044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a> ),<a class="code" href="classbdm_1_1multiBM.html#044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a> ( <a class="code" href="classbdm_1_1multiBM.html#9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>._beta() ) {} 192 <a name="l00272"></a><a class="code" href="classbdm_1_1multiBM.html#dbe6b90d410dc062a233d1dc09eeba52">00272</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1multiBM.html#dbe6b90d410dc062a233d1dc09eeba52" title="Sets sufficient statistics to match that of givefrom mB0.">set_statistics</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1BM.html" title="Bayesian Model of the world, i.e. all uncertainty is modeled by probabilities.">BM</a>* mB0 ) {<span class="keyword">const</span> <a class="code" href="classbdm_1_1multiBM.html" title="Estimator for Multinomial density.">multiBM</a>* mB=<span class="keyword">dynamic_cast<</span><span class="keyword">const </span><a class="code" href="classbdm_1_1multiBM.html" title="Estimator for Multinomial density.">multiBM</a>*<span class="keyword">></span> ( mB0 ); <a class="code" href="classbdm_1_1multiBM.html#044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a>=mB-><a class="code" href="classbdm_1_1multiBM.html#044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a>;} 193 <a name="l00273"></a><a class="code" href="classbdm_1_1multiBM.html#1e4bf41b61937fd80f34049742e23f95">00273</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1multiBM.html#1e4bf41b61937fd80f34049742e23f95" title="Incremental Bayes rule.">bayes</a> ( <span class="keyword">const</span> vec &dt ) { 194 <a name="l00274"></a>00274 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1BMEF.html#1331865e10fb1ccef65bb4c47fa3be64" title="forgetting factor">frg</a><1.0 ) {<a class="code" href="classbdm_1_1multiBM.html#044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a>*=<a class="code" href="classbdm_1_1BMEF.html#1331865e10fb1ccef65bb4c47fa3be64" title="forgetting factor">frg</a>;<a class="code" href="classbdm_1_1BMEF.html#06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>=<a class="code" href="classbdm_1_1multiBM.html#9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classbdm_1_1eDirich.html#279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>();} 195 <a name="l00275"></a>00275 <a class="code" href="classbdm_1_1multiBM.html#044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a>+=dt; 196 <a name="l00276"></a>00276 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1BM.html#faff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a> ) {<a class="code" href="classbdm_1_1BM.html#4064b6559d962633e4372b12f4cd204a" title="Logarithm of marginalized data likelihood.">ll</a>=<a class="code" href="classbdm_1_1multiBM.html#9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classbdm_1_1eDirich.html#279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>()-<a class="code" href="classbdm_1_1BMEF.html#06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>;} 197 197 <a name="l00277"></a>00277 } 198 <a name="l00278"></a><a class="code" href="class multiBM.html#13e26a61757278981fd8cac9a7ef91eb">00278</a> <span class="keywordtype">double</span> <a class="code" href="classmultiBM.html#13e26a61757278981fd8cac9a7ef91eb">logpred</a> ( <span class="keyword">const</span> vec &dt )<span class="keyword"> const </span>{199 <a name="l00279"></a>00279 <a class="code" href="class eDirich.html" title="Dirichlet posterior density.">eDirich</a> pred ( <a class="code" href="classmultiBM.html#eddee08a724170de63f36e40c57b27b5" title="Conjugate prior and posterior.">est</a> );200 <a name="l00280"></a>00280 vec &<a class="code" href="class multiBM.html#7b606116aed7e8834a339cbb0424b1d6" title="Pointer inside est to sufficient statistics.">beta</a> = pred.<a class="code" href="classeDirich.html#6409d0362143a23976b43641ff19e53a" title="access function">_beta</a>();198 <a name="l00278"></a><a class="code" href="classbdm_1_1multiBM.html#e157b607c1e3fa91d42aeea44458e2bf">00278</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1multiBM.html#e157b607c1e3fa91d42aeea44458e2bf">logpred</a> ( <span class="keyword">const</span> vec &dt )<span class="keyword"> const </span>{ 199 <a name="l00279"></a>00279 <a class="code" href="classbdm_1_1eDirich.html" title="Dirichlet posterior density.">eDirich</a> pred ( <a class="code" href="classbdm_1_1multiBM.html#9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a> ); 200 <a name="l00280"></a>00280 vec &<a class="code" href="classbdm_1_1multiBM.html#044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a> = pred.<a class="code" href="classbdm_1_1eDirich.html#175e0add26d2105c28d8121eefb9e324" title="access function">_beta</a>(); 201 201 <a name="l00281"></a>00281 202 202 <a name="l00282"></a>00282 <span class="keywordtype">double</span> lll; 203 <a name="l00283"></a>00283 <span class="keywordflow">if</span> ( <a class="code" href="class BMEF.html#538d632e59f9afa8daa1de74da12ce71" title="forgetting factor">frg</a><1.0 )204 <a name="l00284"></a>00284 {beta*=<a class="code" href="class BMEF.html#538d632e59f9afa8daa1de74da12ce71" title="forgetting factor">frg</a>;lll=pred.<a class="code" href="classeDirich.html#7ce60be7119ffc639ede4e583c1f6e77" title="logarithm of the normalizing constant, ">lognc</a>();}203 <a name="l00283"></a>00283 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1BMEF.html#1331865e10fb1ccef65bb4c47fa3be64" title="forgetting factor">frg</a><1.0 ) 204 <a name="l00284"></a>00284 {beta*=<a class="code" href="classbdm_1_1BMEF.html#1331865e10fb1ccef65bb4c47fa3be64" title="forgetting factor">frg</a>;lll=pred.<a class="code" href="classbdm_1_1eDirich.html#279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>();} 205 205 <a name="l00285"></a>00285 <span class="keywordflow">else</span> 206 <a name="l00286"></a>00286 <span class="keywordflow">if</span> ( <a class="code" href="class BM.html#bf6fb59b30141074f8ee1e2f43d03129" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a> ) {lll=<a class="code" href="classBMEF.html#308cf5d4133cd471fdf1ecd5dfa09d02" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>;}207 <a name="l00287"></a>00287 <span class="keywordflow">else</span>{lll=pred.<a class="code" href="class eDirich.html#7ce60be7119ffc639ede4e583c1f6e77" title="logarithm of the normalizing constant, ">lognc</a>();}206 <a name="l00286"></a>00286 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1BM.html#faff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a> ) {lll=<a class="code" href="classbdm_1_1BMEF.html#06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>;} 207 <a name="l00287"></a>00287 <span class="keywordflow">else</span>{lll=pred.<a class="code" href="classbdm_1_1eDirich.html#279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>();} 208 208 <a name="l00288"></a>00288 209 209 <a name="l00289"></a>00289 beta+=dt; 210 <a name="l00290"></a>00290 <span class="keywordflow">return</span> pred.<a class="code" href="class eDirich.html#7ce60be7119ffc639ede4e583c1f6e77" title="logarithm of the normalizing constant, ">lognc</a>()-lll;210 <a name="l00290"></a>00290 <span class="keywordflow">return</span> pred.<a class="code" href="classbdm_1_1eDirich.html#279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>()-lll; 211 211 <a name="l00291"></a>00291 } 212 <a name="l00292"></a><a class="code" href="class multiBM.html#3988322f8f51b153622036f461f62a67">00292</a> <span class="keywordtype">void</span> <a class="code" href="classmultiBM.html#3988322f8f51b153622036f461f62a67" title="Flatten the posterior according to the given BMEF (of the same type!).">flatten</a> ( <span class="keyword">const</span> <a class="code" href="classBMEF.html" title="Estimator for Exponential family.">BMEF</a>* B ) {213 <a name="l00293"></a>00293 <span class="keyword">const</span> <a class="code" href="class multiBM.html" title="Estimator for Multinomial density.">multiBM</a>* E=<span class="keyword">dynamic_cast<</span><span class="keyword">const </span><a class="code" href="classmultiBM.html" title="Estimator for Multinomial density.">multiBM</a>*<span class="keyword">></span> ( B );212 <a name="l00292"></a><a class="code" href="classbdm_1_1multiBM.html#aaeb18c989088feb8d26d300e4971732">00292</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1multiBM.html#aaeb18c989088feb8d26d300e4971732" title="Flatten the posterior according to the given BMEF (of the same type!).">flatten</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a>* B ) { 213 <a name="l00293"></a>00293 <span class="keyword">const</span> <a class="code" href="classbdm_1_1multiBM.html" title="Estimator for Multinomial density.">multiBM</a>* E=<span class="keyword">dynamic_cast<</span><span class="keyword">const </span><a class="code" href="classbdm_1_1multiBM.html" title="Estimator for Multinomial density.">multiBM</a>*<span class="keyword">></span> ( B ); 214 214 <a name="l00294"></a>00294 <span class="comment">// sum(beta) should be equal to sum(B.beta)</span> 215 <a name="l00295"></a>00295 <span class="keyword">const</span> vec &Eb=E-><a class="code" href="class multiBM.html#7b606116aed7e8834a339cbb0424b1d6" title="Pointer inside est to sufficient statistics.">beta</a>;<span class="comment">//const_cast<multiBM*> ( E )->_beta();</span>216 <a name="l00296"></a>00296 <a class="code" href="class multiBM.html#7b606116aed7e8834a339cbb0424b1d6" title="Pointer inside est to sufficient statistics.">beta</a>*= ( sum ( Eb ) /sum ( <a class="code" href="classmultiBM.html#7b606116aed7e8834a339cbb0424b1d6" title="Pointer inside est to sufficient statistics.">beta</a> ) );217 <a name="l00297"></a>00297 <span class="keywordflow">if</span> ( <a class="code" href="class BM.html#bf6fb59b30141074f8ee1e2f43d03129" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a> ) {<a class="code" href="classBMEF.html#308cf5d4133cd471fdf1ecd5dfa09d02" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>=<a class="code" href="classmultiBM.html#eddee08a724170de63f36e40c57b27b5" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classeDirich.html#7ce60be7119ffc639ede4e583c1f6e77" title="logarithm of the normalizing constant, ">lognc</a>();}215 <a name="l00295"></a>00295 <span class="keyword">const</span> vec &Eb=E-><a class="code" href="classbdm_1_1multiBM.html#044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a>;<span class="comment">//const_cast<multiBM*> ( E )->_beta();</span> 216 <a name="l00296"></a>00296 <a class="code" href="classbdm_1_1multiBM.html#044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a>*= ( sum ( Eb ) /sum ( <a class="code" href="classbdm_1_1multiBM.html#044263356944c92209eecd39a5187d25" title="Pointer inside est to sufficient statistics.">beta</a> ) ); 217 <a name="l00297"></a>00297 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1BM.html#faff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a> ) {<a class="code" href="classbdm_1_1BMEF.html#06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>=<a class="code" href="classbdm_1_1multiBM.html#9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classbdm_1_1eDirich.html#279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>();} 218 218 <a name="l00298"></a>00298 } 219 <a name="l00299"></a><a class="code" href="class multiBM.html#66cdfd83a70bc281840ab0646b941684">00299</a> <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>& <a class="code" href="classmultiBM.html#66cdfd83a70bc281840ab0646b941684" title="Returns a reference to the epdf representing posterior density on parameters.">_epdf</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classmultiBM.html#eddee08a724170de63f36e40c57b27b5" title="Conjugate prior and posterior.">est</a>;};220 <a name="l00300"></a><a class="code" href="class multiBM.html#66a0fa6966e40bb6c3e7ba22d26e9d35">00300</a> <span class="keyword">const</span> <a class="code" href="classeDirich.html" title="Dirichlet posterior density.">eDirich</a>* <a class="code" href="classmultiBM.html#66a0fa6966e40bb6c3e7ba22d26e9d35" title="Returns a pointer to the epdf representing posterior density on parameters. Use with...">_e</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> &<a class="code" href="classmultiBM.html#eddee08a724170de63f36e40c57b27b5" title="Conjugate prior and posterior.">est</a>;};219 <a name="l00299"></a><a class="code" href="classbdm_1_1multiBM.html#98c22316ecfef589989baca261713c8d">00299</a> <span class="keyword">const</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>& <a class="code" href="classbdm_1_1multiBM.html#98c22316ecfef589989baca261713c8d" title="Returns a reference to the epdf representing posterior density on parameters.">_epdf</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1multiBM.html#9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>;}; 220 <a name="l00300"></a><a class="code" href="classbdm_1_1multiBM.html#c996f6b9ca930182030e1027318f1ca6">00300</a> <span class="keyword">const</span> <a class="code" href="classbdm_1_1eDirich.html" title="Dirichlet posterior density.">eDirich</a>* <a class="code" href="classbdm_1_1multiBM.html#c996f6b9ca930182030e1027318f1ca6" title="Returns a pointer to the epdf representing posterior density on parameters. Use with...">_e</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> &<a class="code" href="classbdm_1_1multiBM.html#9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>;}; 221 221 <a name="l00301"></a>00301 <span class="keywordtype">void</span> set_parameters ( <span class="keyword">const</span> vec &beta0 ) { 222 <a name="l00302"></a>00302 <a class="code" href="class multiBM.html#eddee08a724170de63f36e40c57b27b5" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classeDirich.html#c842acb2e1cce5cc9000769ff06c086d" title="Set internal parameters.">set_parameters</a> ( beta0 );223 <a name="l00303"></a>00303 <a class="code" href="class BM.html#af00f0612fabe66241dd507188cdbf88" title="Random variable of the posterior.">rv</a> = <a class="code" href="classmultiBM.html#eddee08a724170de63f36e40c57b27b5" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classepdf.html#ca0d32aabb4cbba347e0c37fe8607562" title="access function, possibly dangerous!">_rv</a>();224 <a name="l00304"></a>00304 <span class="keywordflow">if</span> ( <a class="code" href="class BM.html#bf6fb59b30141074f8ee1e2f43d03129" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a> ) {<a class="code" href="classBMEF.html#308cf5d4133cd471fdf1ecd5dfa09d02" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>=<a class="code" href="classmultiBM.html#eddee08a724170de63f36e40c57b27b5" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classeDirich.html#7ce60be7119ffc639ede4e583c1f6e77" title="logarithm of the normalizing constant, ">lognc</a>();}222 <a name="l00302"></a>00302 <a class="code" href="classbdm_1_1multiBM.html#9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classbdm_1_1eDirich.html#a06af2376976a33e1eceaed7e8da75a5" title="Set internal parameters.">set_parameters</a> ( beta0 ); 223 <a name="l00303"></a>00303 <a class="code" href="classbdm_1_1BM.html#18d6db4af8ee42077741d9e3618153ca" title="Random variable of the posterior.">rv</a> = <a class="code" href="classbdm_1_1multiBM.html#9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classbdm_1_1epdf.html#a4ab378d5e004c3ff3e2d4e64f7bba21" title="access function, possibly dangerous!">_rv</a>(); 224 <a name="l00304"></a>00304 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1BM.html#faff0ad12556fe7dc0e2807d4fd938ee" title="If true, the filter will compute likelihood of the data record and store it in ll...">evalll</a> ) {<a class="code" href="classbdm_1_1BMEF.html#06e7b3ac03e10017d4288c76888e2865" title="cached value of lognc() in the previous step (used in evaluation of ll )">last_lognc</a>=<a class="code" href="classbdm_1_1multiBM.html#9ecc6878abbd20eb8d8e43b6ab3f941a" title="Conjugate prior and posterior.">est</a>.<a class="code" href="classbdm_1_1eDirich.html#279a99f6266c82fe2273e83841f19eb2" title="logarithm of the normalizing constant, ">lognc</a>();} 225 225 <a name="l00305"></a>00305 } 226 226 <a name="l00306"></a>00306 }; 227 227 <a name="l00307"></a>00307 228 <a name="l00317"></a><a class="code" href="class egamma.html">00317</a> <span class="keyword">class </span><a class="code" href="classegamma.html" title="Gamma posterior density.">egamma</a> : <span class="keyword">public</span> <a class="code" href="classeEF.html" title="General conjugate exponential family posterior density.">eEF</a> {228 <a name="l00317"></a><a class="code" href="classbdm_1_1egamma.html">00317</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1egamma.html" title="Gamma posterior density.">egamma</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> { 229 229 <a name="l00318"></a>00318 <span class="keyword">protected</span>: 230 <a name="l00320"></a><a class="code" href="class egamma.html#376cebd8932546c440f21b182910b01b">00320</a> vec <a class="code" href="classegamma.html#376cebd8932546c440f21b182910b01b" title="Vector .">alpha</a>;231 <a name="l00322"></a><a class="code" href="class egamma.html#cfc5f136467488a421ab22f886323790">00322</a> vec <a class="code" href="classegamma.html#cfc5f136467488a421ab22f886323790" title="Vector .">beta</a>;230 <a name="l00320"></a><a class="code" href="classbdm_1_1egamma.html#0901ec983e66b8337aaa506e13b122fa">00320</a> vec <a class="code" href="classbdm_1_1egamma.html#0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>; 231 <a name="l00322"></a><a class="code" href="classbdm_1_1egamma.html#457bfb1ccb2057df85073e519a15ccc1">00322</a> vec <a class="code" href="classbdm_1_1egamma.html#457bfb1ccb2057df85073e519a15ccc1" title="Vector .">beta</a>; 232 232 <a name="l00323"></a>00323 <span class="keyword">public</span> : 233 <a name="l00325"></a><a class="code" href="class egamma.html#4b1d34f3b244ea51a58ec10c468788c1">00325</a> <a class="code" href="classegamma.html#4b1d34f3b244ea51a58ec10c468788c1" title="Default constructor.">egamma</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ) :<a class="code" href="classeEF.html" title="General conjugate exponential family posterior density.">eEF</a> ( rv ), <a class="code" href="classegamma.html#376cebd8932546c440f21b182910b01b" title="Vector .">alpha</a>(rv.count()), <a class="code" href="classegamma.html#cfc5f136467488a421ab22f886323790" title="Vector .">beta</a>(rv.count()) {};234 <a name="l00327"></a><a class="code" href="class egamma.html#8e348b89be82b70471fe8c5630f61339">00327</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 &a, <span class="keyword">const</span> vec &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;};235 <a name="l00328"></a>00328 vec <a class="code" href="class egamma.html#8e10c0021b5dfdd9cb62c6959b5ef425" title="Returns a sample, from density .">sample</a>() <span class="keyword">const</span>;233 <a name="l00325"></a><a class="code" href="classbdm_1_1egamma.html#4dafabaa0881300b18f791bc614ef487">00325</a> <a class="code" href="classbdm_1_1egamma.html#4dafabaa0881300b18f791bc614ef487" title="Default constructor.">egamma</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a> ) :<a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> ( rv ), <a class="code" href="classbdm_1_1egamma.html#0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>(rv.count()), <a class="code" href="classbdm_1_1egamma.html#457bfb1ccb2057df85073e519a15ccc1" title="Vector .">beta</a>(rv.count()) {}; 234 <a name="l00327"></a><a class="code" href="classbdm_1_1egamma.html#749f82293ff23a8319c1bf52489d2ed2">00327</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egamma.html#749f82293ff23a8319c1bf52489d2ed2" title="Sets parameters.">set_parameters</a> ( <span class="keyword">const</span> vec &a, <span class="keyword">const</span> vec &b ) {<a class="code" href="classbdm_1_1egamma.html#0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>=a,<a class="code" href="classbdm_1_1egamma.html#457bfb1ccb2057df85073e519a15ccc1" title="Vector .">beta</a>=b;}; 235 <a name="l00328"></a>00328 vec <a class="code" href="classbdm_1_1egamma.html#6ed82f0fd05f6002487256d8e75a0bbd" title="Returns a sample, from density .">sample</a>() <span class="keyword">const</span>; 236 236 <a name="l00330"></a>00330 <span class="comment">// mat sample ( int N ) const;</span> 237 <a name="l00331"></a>00331 <span class="keywordtype">double</span> <a class="code" href="class egamma.html#74a49a4c696f44e54bb6b0515e155a9b" title="TODO: is it used anywhere?">evallog</a> ( <span class="keyword">const</span> vec &val ) <span class="keyword">const</span>;238 <a name="l00332"></a>00332 <span class="keywordtype">double</span> <a class="code" href="class egamma.html#d6dbbdb72360f9e54d64501f80318bb6" title="logarithm of the normalizing constant, ">lognc</a> () <span class="keyword">const</span>;239 <a name="l00334"></a><a class="code" href="class egamma.html#44445c56e60b91b377f207f8d5089790">00334</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* &a, vec* &b ) {a=&<a class="code" href="classegamma.html#376cebd8932546c440f21b182910b01b" title="Vector .">alpha</a>;b=&<a class="code" href="classegamma.html#cfc5f136467488a421ab22f886323790" title="Vector .">beta</a>;};240 <a name="l00335"></a><a class="code" href="class egamma.html#6ab5ba56f7cdb2e5921c3e77524fa50a">00335</a> vec <a class="code" href="classegamma.html#6ab5ba56f7cdb2e5921c3e77524fa50a" title="return expected value">mean</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> elem_div(<a class="code" href="classegamma.html#376cebd8932546c440f21b182910b01b" title="Vector .">alpha</a>,<a class="code" href="classegamma.html#cfc5f136467488a421ab22f886323790" title="Vector .">beta</a>);}241 <a name="l00336"></a><a class="code" href="class egamma.html#1dee6186a084565de4f9ceb3410148e4">00336</a> vec <a class="code" href="classegamma.html#1dee6186a084565de4f9ceb3410148e4" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> elem_div(<a class="code" href="classegamma.html#376cebd8932546c440f21b182910b01b" title="Vector .">alpha</a>,elem_mult(<a class="code" href="classegamma.html#cfc5f136467488a421ab22f886323790" title="Vector .">beta</a>,<a class="code" href="classegamma.html#cfc5f136467488a421ab22f886323790" title="Vector .">beta</a>)); }237 <a name="l00331"></a>00331 <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1egamma.html#a8e11e5a580ff42a1b205974c60768c6" title="TODO: is it used anywhere?">evallog</a> ( <span class="keyword">const</span> vec &val ) <span class="keyword">const</span>; 238 <a name="l00332"></a>00332 <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1egamma.html#9a66cbd100e8520c769ccb3c451f86f8" title="logarithm of the normalizing constant, ">lognc</a> () <span class="keyword">const</span>; 239 <a name="l00334"></a><a class="code" href="classbdm_1_1egamma.html#498c1fe5e8382ab2f97d629849741855">00334</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egamma.html#498c1fe5e8382ab2f97d629849741855" title="Returns poiter to alpha and beta. Potentially dengerous: use with care!">_param</a> ( vec* &a, vec* &b ) {a=&<a class="code" href="classbdm_1_1egamma.html#0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>;b=&<a class="code" href="classbdm_1_1egamma.html#457bfb1ccb2057df85073e519a15ccc1" title="Vector .">beta</a>;}; 240 <a name="l00335"></a><a class="code" href="classbdm_1_1egamma.html#49d256c42cce14c6faa56ec242b57e85">00335</a> vec <a class="code" href="classbdm_1_1egamma.html#49d256c42cce14c6faa56ec242b57e85" title="return expected value">mean</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> elem_div(<a class="code" href="classbdm_1_1egamma.html#0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>,<a class="code" href="classbdm_1_1egamma.html#457bfb1ccb2057df85073e519a15ccc1" title="Vector .">beta</a>);} 241 <a name="l00336"></a><a class="code" href="classbdm_1_1egamma.html#36986cc01917cd0796fadc17125bdec1">00336</a> vec <a class="code" href="classbdm_1_1egamma.html#36986cc01917cd0796fadc17125bdec1" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> elem_div(<a class="code" href="classbdm_1_1egamma.html#0901ec983e66b8337aaa506e13b122fa" title="Vector .">alpha</a>,elem_mult(<a class="code" href="classbdm_1_1egamma.html#457bfb1ccb2057df85073e519a15ccc1" title="Vector .">beta</a>,<a class="code" href="classbdm_1_1egamma.html#457bfb1ccb2057df85073e519a15ccc1" title="Vector .">beta</a>)); } 242 242 <a name="l00337"></a>00337 }; 243 243 <a name="l00338"></a>00338 244 <a name="l00353"></a><a class="code" href="class eigamma.html">00353</a> <span class="keyword">class </span><a class="code" href="classeigamma.html" title="Inverse-Gamma posterior density.">eigamma</a> : <span class="keyword">public</span> <a class="code" href="classeEF.html" title="General conjugate exponential family posterior density.">eEF</a> {244 <a name="l00353"></a><a class="code" href="classbdm_1_1eigamma.html">00353</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1eigamma.html" title="Inverse-Gamma posterior density.">eigamma</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> { 245 245 <a name="l00354"></a>00354 <span class="keyword">protected</span>: 246 <a name="l00356"></a><a class="code" href="class eigamma.html#ea00e33f405ebd918e06cede968a735b">00356</a> vec* <a class="code" href="classeigamma.html#ea00e33f405ebd918e06cede968a735b" title="Vector .">alpha</a>;247 <a name="l00358"></a><a class="code" href="class eigamma.html#ee446ec667a4df391e0db41decb2d558">00358</a> vec* <a class="code" href="classeigamma.html#ee446ec667a4df391e0db41decb2d558" title="Vector (in fact it is 1/beta as used in definition of iG).">beta</a>;248 <a name="l00360"></a><a class="code" href="class eigamma.html#906f2a3a8fbf08b2af49776f2f1be5d4">00360</a> <a class="code" href="classegamma.html" title="Gamma posterior density.">egamma</a> <a class="code" href="classeigamma.html#906f2a3a8fbf08b2af49776f2f1be5d4" title="internal egamma">eg</a>;246 <a name="l00356"></a><a class="code" href="classbdm_1_1eigamma.html#e2c49c77e04a96a9e6a4a628318ceb73">00356</a> vec* <a class="code" href="classbdm_1_1eigamma.html#e2c49c77e04a96a9e6a4a628318ceb73" title="Vector .">alpha</a>; 247 <a name="l00358"></a><a class="code" href="classbdm_1_1eigamma.html#b2c62f2e869d1304a4055f6a7ac59cde">00358</a> vec* <a class="code" href="classbdm_1_1eigamma.html#b2c62f2e869d1304a4055f6a7ac59cde" title="Vector (in fact it is 1/beta as used in definition of iG).">beta</a>; 248 <a name="l00360"></a><a class="code" href="classbdm_1_1eigamma.html#3e5c03201f073033a7db894fa15ddb96">00360</a> <a class="code" href="classbdm_1_1egamma.html" title="Gamma posterior density.">egamma</a> <a class="code" href="classbdm_1_1eigamma.html#3e5c03201f073033a7db894fa15ddb96" title="internal egamma">eg</a>; 249 249 <a name="l00361"></a>00361 <span class="keyword">public</span> : 250 <a name="l00363"></a><a class="code" href="class eigamma.html#ea0edc0a1f32350219f55cf35d83a5f6">00363</a> <a class="code" href="classeigamma.html#ea0edc0a1f32350219f55cf35d83a5f6" title="Default constructor.">eigamma</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ) :<a class="code" href="classeEF.html" title="General conjugate exponential family posterior density.">eEF</a> ( rv ), <a class="code" href="classeigamma.html#906f2a3a8fbf08b2af49776f2f1be5d4" title="internal egamma">eg</a>(rv) {<a class="code" href="classeigamma.html#906f2a3a8fbf08b2af49776f2f1be5d4" title="internal egamma">eg</a>.<a class="code" href="classegamma.html#44445c56e60b91b377f207f8d5089790" title="Returns poiter to alpha and beta. Potentially dengerous: use with care!">_param</a>(<a class="code" href="classeigamma.html#ea00e33f405ebd918e06cede968a735b" title="Vector .">alpha</a>,<a class="code" href="classeigamma.html#ee446ec667a4df391e0db41decb2d558" title="Vector (in fact it is 1/beta as used in definition of iG).">beta</a>);};251 <a name="l00365"></a><a class="code" href="class eigamma.html#a86b94a5f9189cae1b6651838dc153aa">00365</a> <span class="keywordtype">void</span> <a class="code" href="classeigamma.html#a86b94a5f9189cae1b6651838dc153aa" title="Sets parameters.">set_parameters</a> ( <span class="keyword">const</span> vec &a, <span class="keyword">const</span> vec &b ) {*<a class="code" href="classeigamma.html#ea00e33f405ebd918e06cede968a735b" title="Vector .">alpha</a>=a,*<a class="code" href="classeigamma.html#ee446ec667a4df391e0db41decb2d558" title="Vector (in fact it is 1/beta as used in definition of iG).">beta</a>=b;};252 <a name="l00366"></a><a class="code" href="class eigamma.html#b70deffdf41b590377fd6743e4d306f1">00366</a> vec <a class="code" href="classeigamma.html#b70deffdf41b590377fd6743e4d306f1" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> 1.0/<a class="code" href="classeigamma.html#906f2a3a8fbf08b2af49776f2f1be5d4" title="internal egamma">eg</a>.<a class="code" href="classegamma.html#8e10c0021b5dfdd9cb62c6959b5ef425" title="Returns a sample, from density .">sample</a>();};250 <a name="l00363"></a><a class="code" href="classbdm_1_1eigamma.html#34a8d2cd08399c3449e2efcda6ea2f89">00363</a> <a class="code" href="classbdm_1_1eigamma.html#34a8d2cd08399c3449e2efcda6ea2f89" title="Default constructor.">eigamma</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a> ) :<a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> ( rv ), <a class="code" href="classbdm_1_1eigamma.html#3e5c03201f073033a7db894fa15ddb96" title="internal egamma">eg</a>(rv) {<a class="code" href="classbdm_1_1eigamma.html#3e5c03201f073033a7db894fa15ddb96" title="internal egamma">eg</a>.<a class="code" href="classbdm_1_1egamma.html#498c1fe5e8382ab2f97d629849741855" title="Returns poiter to alpha and beta. Potentially dengerous: use with care!">_param</a>(<a class="code" href="classbdm_1_1eigamma.html#e2c49c77e04a96a9e6a4a628318ceb73" title="Vector .">alpha</a>,<a class="code" href="classbdm_1_1eigamma.html#b2c62f2e869d1304a4055f6a7ac59cde" title="Vector (in fact it is 1/beta as used in definition of iG).">beta</a>);}; 251 <a name="l00365"></a><a class="code" href="classbdm_1_1eigamma.html#09e616c95f31acddf7dfef96d1c5d645">00365</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eigamma.html#09e616c95f31acddf7dfef96d1c5d645" title="Sets parameters.">set_parameters</a> ( <span class="keyword">const</span> vec &a, <span class="keyword">const</span> vec &b ) {*<a class="code" href="classbdm_1_1eigamma.html#e2c49c77e04a96a9e6a4a628318ceb73" title="Vector .">alpha</a>=a,*<a class="code" href="classbdm_1_1eigamma.html#b2c62f2e869d1304a4055f6a7ac59cde" title="Vector (in fact it is 1/beta as used in definition of iG).">beta</a>=b;}; 252 <a name="l00366"></a><a class="code" href="classbdm_1_1eigamma.html#3aff7bf25ddac27731c60826fcfd878f">00366</a> vec <a class="code" href="classbdm_1_1eigamma.html#3aff7bf25ddac27731c60826fcfd878f" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> 1.0/<a class="code" href="classbdm_1_1eigamma.html#3e5c03201f073033a7db894fa15ddb96" title="internal egamma">eg</a>.<a class="code" href="classbdm_1_1egamma.html#6ed82f0fd05f6002487256d8e75a0bbd" title="Returns a sample, from density .">sample</a>();}; 253 253 <a name="l00368"></a>00368 <span class="comment">// mat sample ( int N ) const;</span> 254 <a name="l00369"></a><a class="code" href="class eigamma.html#960cf366101389f58f11c5f748dd7e80">00369</a> <span class="keywordtype">double</span> <a class="code" href="classeigamma.html#960cf366101389f58f11c5f748dd7e80" title="TODO: is it used anywhere?">evallog</a> ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classeigamma.html#906f2a3a8fbf08b2af49776f2f1be5d4" title="internal egamma">eg</a>.<a class="code" href="classegamma.html#74a49a4c696f44e54bb6b0515e155a9b" title="TODO: is it used anywhere?">evallog</a>(val);};255 <a name="l00370"></a><a class="code" href="class eigamma.html#efcc280de487d8b81f9b31f286404c72">00370</a> <span class="keywordtype">double</span> <a class="code" href="classeigamma.html#efcc280de487d8b81f9b31f286404c72" title="logarithm of the normalizing constant, ">lognc</a> ()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classeigamma.html#906f2a3a8fbf08b2af49776f2f1be5d4" title="internal egamma">eg</a>.<a class="code" href="classegamma.html#d6dbbdb72360f9e54d64501f80318bb6" title="logarithm of the normalizing constant, ">lognc</a>();};256 <a name="l00372"></a><a class="code" href="class eigamma.html#86389685695f6948d2e52070cd89a9ed">00372</a> <span class="keywordtype">void</span> <a class="code" href="classeigamma.html#86389685695f6948d2e52070cd89a9ed" title="Returns poiter to alpha and beta. Potentially dangerous: use with care!">_param</a> ( vec* &a, vec* &b ) {a=<a class="code" href="classeigamma.html#ea00e33f405ebd918e06cede968a735b" title="Vector .">alpha</a>;b=<a class="code" href="classeigamma.html#ee446ec667a4df391e0db41decb2d558" title="Vector (in fact it is 1/beta as used in definition of iG).">beta</a>;};257 <a name="l00373"></a><a class="code" href="class eigamma.html#0ff10e82b0f0d07c2dd4ff5f23b3c70f">00373</a> vec <a class="code" href="classeigamma.html#0ff10e82b0f0d07c2dd4ff5f23b3c70f" title="return expected value">mean</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> elem_div(*<a class="code" href="classeigamma.html#ee446ec667a4df391e0db41decb2d558" title="Vector (in fact it is 1/beta as used in definition of iG).">beta</a>,*<a class="code" href="classeigamma.html#ea00e33f405ebd918e06cede968a735b" title="Vector .">alpha</a>-1);}258 <a name="l00374"></a><a class="code" href="class eigamma.html#a9ad6cb7514ffc46605f28316eda54ff">00374</a> vec <a class="code" href="classeigamma.html#a9ad6cb7514ffc46605f28316eda54ff" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{vec mea=<a class="code" href="classeigamma.html#0ff10e82b0f0d07c2dd4ff5f23b3c70f" title="return expected value">mean</a>(); <span class="keywordflow">return</span> elem_div(elem_mult(mea,mea),*<a class="code" href="classeigamma.html#ea00e33f405ebd918e06cede968a735b" title="Vector .">alpha</a>-2);}254 <a name="l00369"></a><a class="code" href="classbdm_1_1eigamma.html#9e26c80c8e6708bfcf2e684958af6f91">00369</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eigamma.html#9e26c80c8e6708bfcf2e684958af6f91" title="TODO: is it used anywhere?">evallog</a> ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eigamma.html#3e5c03201f073033a7db894fa15ddb96" title="internal egamma">eg</a>.<a class="code" href="classbdm_1_1egamma.html#a8e11e5a580ff42a1b205974c60768c6" title="TODO: is it used anywhere?">evallog</a>(val);}; 255 <a name="l00370"></a><a class="code" href="classbdm_1_1eigamma.html#a52ac6d523e2fe05642d1f50fe66aec2">00370</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eigamma.html#a52ac6d523e2fe05642d1f50fe66aec2" title="logarithm of the normalizing constant, ">lognc</a> ()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eigamma.html#3e5c03201f073033a7db894fa15ddb96" title="internal egamma">eg</a>.<a class="code" href="classbdm_1_1egamma.html#9a66cbd100e8520c769ccb3c451f86f8" title="logarithm of the normalizing constant, ">lognc</a>();}; 256 <a name="l00372"></a><a class="code" href="classbdm_1_1eigamma.html#57b9ee79ef5d2cea243bbe6b274a2abe">00372</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eigamma.html#57b9ee79ef5d2cea243bbe6b274a2abe" title="Returns poiter to alpha and beta. Potentially dangerous: use with care!">_param</a> ( vec* &a, vec* &b ) {a=<a class="code" href="classbdm_1_1eigamma.html#e2c49c77e04a96a9e6a4a628318ceb73" title="Vector .">alpha</a>;b=<a class="code" href="classbdm_1_1eigamma.html#b2c62f2e869d1304a4055f6a7ac59cde" title="Vector (in fact it is 1/beta as used in definition of iG).">beta</a>;}; 257 <a name="l00373"></a><a class="code" href="classbdm_1_1eigamma.html#46cecb295edbabd28120cb0f6f572bcb">00373</a> vec <a class="code" href="classbdm_1_1eigamma.html#46cecb295edbabd28120cb0f6f572bcb" title="return expected value">mean</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> elem_div(*<a class="code" href="classbdm_1_1eigamma.html#b2c62f2e869d1304a4055f6a7ac59cde" title="Vector (in fact it is 1/beta as used in definition of iG).">beta</a>,*<a class="code" href="classbdm_1_1eigamma.html#e2c49c77e04a96a9e6a4a628318ceb73" title="Vector .">alpha</a>-1);} 258 <a name="l00374"></a><a class="code" href="classbdm_1_1eigamma.html#c2c696f8c668e9f65392c9449f6a5133">00374</a> vec <a class="code" href="classbdm_1_1eigamma.html#c2c696f8c668e9f65392c9449f6a5133" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{vec mea=<a class="code" href="classbdm_1_1eigamma.html#46cecb295edbabd28120cb0f6f572bcb" title="return expected value">mean</a>(); <span class="keywordflow">return</span> elem_div(elem_mult(mea,mea),*<a class="code" href="classbdm_1_1eigamma.html#e2c49c77e04a96a9e6a4a628318ceb73" title="Vector .">alpha</a>-2);} 259 259 <a name="l00375"></a>00375 }; 260 260 <a name="l00376"></a>00376 <span class="comment">/*</span> … … 273 273 <a name="l00391"></a>00391 274 274 <a name="l00393"></a>00393 275 <a name="l00394"></a><a class="code" href="class euni.html">00394</a> <span class="keyword">class </span><a class="code" href="classeuni.html" title="Uniform distributed density on a rectangular support.">euni</a>: <span class="keyword">public</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> {275 <a name="l00394"></a><a class="code" href="classbdm_1_1euni.html">00394</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1euni.html" title="Uniform distributed density on a rectangular support.">euni</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> { 276 276 <a name="l00395"></a>00395 <span class="keyword">protected</span>: 277 <a name="l00397"></a><a class="code" href="class euni.html#ef42cd8d7645422048d46c46ec5cdac1">00397</a> vec <a class="code" href="classeuni.html#ef42cd8d7645422048d46c46ec5cdac1" title="lower bound on support">low</a>;278 <a name="l00399"></a><a class="code" href="class euni.html#71b6d6b41aeb61a7f76f682b72119231">00399</a> vec <a class="code" href="classeuni.html#71b6d6b41aeb61a7f76f682b72119231" title="upper bound on support">high</a>;279 <a name="l00401"></a><a class="code" href="class euni.html#52a6ff4a54010f88a6a19fca605c64a4">00401</a> vec <a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a>;280 <a name="l00403"></a><a class="code" href="class euni.html#63105490e946e43372d6187ad1bafdda">00403</a> <span class="keywordtype">double</span> <a class="code" href="classeuni.html#63105490e946e43372d6187ad1bafdda" title="normalizing coefficients">nk</a>;281 <a name="l00405"></a><a class="code" href="class euni.html#f445a0ce24f39d14c1a4eed53fc8e2c3">00405</a> <span class="keywordtype">double</span> <a class="code" href="classeuni.html#f445a0ce24f39d14c1a4eed53fc8e2c3" title="cache of log( nk )">lnk</a>;277 <a name="l00397"></a><a class="code" href="classbdm_1_1euni.html#ff7ce6a2ef5ef0015bbd1398bed12f32">00397</a> vec <a class="code" href="classbdm_1_1euni.html#ff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>; 278 <a name="l00399"></a><a class="code" href="classbdm_1_1euni.html#cfad2dea4a62db6872bda8abd75f0de1">00399</a> vec <a class="code" href="classbdm_1_1euni.html#cfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>; 279 <a name="l00401"></a><a class="code" href="classbdm_1_1euni.html#d3c27e331f90c754d80228108de8ed4c">00401</a> vec <a class="code" href="classbdm_1_1euni.html#d3c27e331f90c754d80228108de8ed4c" title="internal">distance</a>; 280 <a name="l00403"></a><a class="code" href="classbdm_1_1euni.html#31bb13e8449a8eff35246d46dae35c20">00403</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1euni.html#31bb13e8449a8eff35246d46dae35c20" title="normalizing coefficients">nk</a>; 281 <a name="l00405"></a><a class="code" href="classbdm_1_1euni.html#3e63be48dd58659663ca60cd18700476">00405</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1euni.html#3e63be48dd58659663ca60cd18700476" title="cache of log( nk )">lnk</a>; 282 282 <a name="l00406"></a>00406 <span class="keyword">public</span>: 283 <a name="l00408"></a><a class="code" href="class euni.html#2537a6c239cff52e3ba814851a1116cd">00408</a> <a class="code" href="classeuni.html#2537a6c239cff52e3ba814851a1116cd" title="Defualt constructor.">euni</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ) :<a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( rv ) {}284 <a name="l00409"></a>00409 <span class="keywordtype">double</span> eval ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="class euni.html#63105490e946e43372d6187ad1bafdda" title="normalizing coefficients">nk</a>;}285 <a name="l00410"></a><a class="code" href="class euni.html#357b36417ef4c9211d12e7a4a602fd6a">00410</a> <span class="keywordtype">double</span> <a class="code" href="classeuni.html#357b36417ef4c9211d12e7a4a602fd6a" title="Compute log-probability of argument val.">evallog</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>;}286 <a name="l00411"></a><a class="code" href="class euni.html#4a0e09392be17beaee120ba98fc038cd">00411</a> vec <a class="code" href="classeuni.html#4a0e09392be17beaee120ba98fc038cd" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{287 <a name="l00412"></a>00412 vec smp ( <a class="code" href="class epdf.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>() );283 <a name="l00408"></a><a class="code" href="classbdm_1_1euni.html#dca02eda833d6295e0c19f6e120b64e0">00408</a> <a class="code" href="classbdm_1_1euni.html#dca02eda833d6295e0c19f6e120b64e0" title="Defualt constructor.">euni</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a> ) :<a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( rv ) {} 284 <a name="l00409"></a>00409 <span class="keywordtype">double</span> eval ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1euni.html#31bb13e8449a8eff35246d46dae35c20" title="normalizing coefficients">nk</a>;} 285 <a name="l00410"></a><a class="code" href="classbdm_1_1euni.html#caa07b8307bd793d5339d6583e0aba81">00410</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1euni.html#caa07b8307bd793d5339d6583e0aba81" title="Compute log-probability of argument val.">evallog</a> ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1euni.html#3e63be48dd58659663ca60cd18700476" title="cache of log( nk )">lnk</a>;} 286 <a name="l00411"></a><a class="code" href="classbdm_1_1euni.html#fc5df80359ead2918384b2004ce67194">00411</a> vec <a class="code" href="classbdm_1_1euni.html#fc5df80359ead2918384b2004ce67194" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{ 287 <a name="l00412"></a>00412 vec smp ( <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>() ); 288 288 <a name="l00413"></a>00413 <span class="preprocessor">#pragma omp critical</span> 289 <a name="l00414"></a>00414 <span class="preprocessor"></span> UniRNG.sample_vector ( <a class="code" href="class epdf.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 );290 <a name="l00415"></a>00415 <span class="keywordflow">return</span> <a class="code" href="class euni.html#ef42cd8d7645422048d46c46ec5cdac1" title="lower bound on support">low</a>+elem_mult ( <a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a>,smp );289 <a name="l00414"></a>00414 <span class="preprocessor"></span> UniRNG.sample_vector ( <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>(),smp ); 290 <a name="l00415"></a>00415 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1euni.html#ff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>+elem_mult ( <a class="code" href="classbdm_1_1euni.html#d3c27e331f90c754d80228108de8ed4c" title="internal">distance</a>,smp ); 291 291 <a name="l00416"></a>00416 } 292 <a name="l00418"></a><a class="code" href="class euni.html#4fd7c6a05100616ad16ece405cad7bf2">00418</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 &low0, <span class="keyword">const</span> vec &high0 ) {293 <a name="l00419"></a>00419 <a class="code" href="class euni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a> = high0-low0;294 <a name="l00420"></a>00420 it_assert_debug ( min ( <a class="code" href="class euni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a> ) >0.0,<span class="stringliteral">"bad support"</span> );295 <a name="l00421"></a>00421 <a class="code" href="class euni.html#ef42cd8d7645422048d46c46ec5cdac1" title="lower bound on support">low</a> = low0;296 <a name="l00422"></a>00422 <a class="code" href="class euni.html#71b6d6b41aeb61a7f76f682b72119231" title="upper bound on support">high</a> = high0;297 <a name="l00423"></a>00423 <a class="code" href="class euni.html#63105490e946e43372d6187ad1bafdda" title="normalizing coefficients">nk</a> = prod ( 1.0/<a class="code" href="classeuni.html#52a6ff4a54010f88a6a19fca605c64a4" title="internal">distance</a> );298 <a name="l00424"></a>00424 <a class="code" href="class euni.html#f445a0ce24f39d14c1a4eed53fc8e2c3" title="cache of log( nk )">lnk</a> = log ( <a class="code" href="classeuni.html#63105490e946e43372d6187ad1bafdda" title="normalizing coefficients">nk</a> );292 <a name="l00418"></a><a class="code" href="classbdm_1_1euni.html#8e130b323c62b42f1699537f99af6f09">00418</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1euni.html#8e130b323c62b42f1699537f99af6f09" title="set values of low and high ">set_parameters</a> ( <span class="keyword">const</span> vec &low0, <span class="keyword">const</span> vec &high0 ) { 293 <a name="l00419"></a>00419 <a class="code" href="classbdm_1_1euni.html#d3c27e331f90c754d80228108de8ed4c" title="internal">distance</a> = high0-low0; 294 <a name="l00420"></a>00420 it_assert_debug ( min ( <a class="code" href="classbdm_1_1euni.html#d3c27e331f90c754d80228108de8ed4c" title="internal">distance</a> ) >0.0,<span class="stringliteral">"bad support"</span> ); 295 <a name="l00421"></a>00421 <a class="code" href="classbdm_1_1euni.html#ff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a> = low0; 296 <a name="l00422"></a>00422 <a class="code" href="classbdm_1_1euni.html#cfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a> = high0; 297 <a name="l00423"></a>00423 <a class="code" href="classbdm_1_1euni.html#31bb13e8449a8eff35246d46dae35c20" title="normalizing coefficients">nk</a> = prod ( 1.0/<a class="code" href="classbdm_1_1euni.html#d3c27e331f90c754d80228108de8ed4c" title="internal">distance</a> ); 298 <a name="l00424"></a>00424 <a class="code" href="classbdm_1_1euni.html#3e63be48dd58659663ca60cd18700476" title="cache of log( nk )">lnk</a> = log ( <a class="code" href="classbdm_1_1euni.html#31bb13e8449a8eff35246d46dae35c20" title="normalizing coefficients">nk</a> ); 299 299 <a name="l00425"></a>00425 } 300 <a name="l00426"></a><a class="code" href="class euni.html#8050087e421a9cfd1b4b1f8bd33b1cc1">00426</a> vec <a class="code" href="classeuni.html#8050087e421a9cfd1b4b1f8bd33b1cc1" title="return expected value">mean</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> (<a class="code" href="classeuni.html#71b6d6b41aeb61a7f76f682b72119231" title="upper bound on support">high</a>-<a class="code" href="classeuni.html#ef42cd8d7645422048d46c46ec5cdac1" title="lower bound on support">low</a>)/2.0;}301 <a name="l00427"></a><a class="code" href="class euni.html#15d7d8b2c8f13a0b1535ebc35551f01c">00427</a> vec <a class="code" href="classeuni.html#15d7d8b2c8f13a0b1535ebc35551f01c" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> (pow(<a class="code" href="classeuni.html#71b6d6b41aeb61a7f76f682b72119231" title="upper bound on support">high</a>,2)+pow(<a class="code" href="classeuni.html#ef42cd8d7645422048d46c46ec5cdac1" title="lower bound on support">low</a>,2)+elem_mult(<a class="code" href="classeuni.html#71b6d6b41aeb61a7f76f682b72119231" title="upper bound on support">high</a>,<a class="code" href="classeuni.html#ef42cd8d7645422048d46c46ec5cdac1" title="lower bound on support">low</a>))/3.0;}300 <a name="l00426"></a><a class="code" href="classbdm_1_1euni.html#46caa8c13aba2e6228f964208918b226">00426</a> vec <a class="code" href="classbdm_1_1euni.html#46caa8c13aba2e6228f964208918b226" title="return expected value">mean</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> (<a class="code" href="classbdm_1_1euni.html#cfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>-<a class="code" href="classbdm_1_1euni.html#ff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>)/2.0;} 301 <a name="l00427"></a><a class="code" href="classbdm_1_1euni.html#951f932155111f6053c980f672b4c22c">00427</a> vec <a class="code" href="classbdm_1_1euni.html#951f932155111f6053c980f672b4c22c" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> (pow(<a class="code" href="classbdm_1_1euni.html#cfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>,2)+pow(<a class="code" href="classbdm_1_1euni.html#ff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>,2)+elem_mult(<a class="code" href="classbdm_1_1euni.html#cfad2dea4a62db6872bda8abd75f0de1" title="upper bound on support">high</a>,<a class="code" href="classbdm_1_1euni.html#ff7ce6a2ef5ef0015bbd1398bed12f32" title="lower bound on support">low</a>))/3.0;} 302 302 <a name="l00428"></a>00428 }; 303 303 <a name="l00429"></a>00429 304 304 <a name="l00430"></a>00430 305 305 <a name="l00436"></a>00436 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> 306 <a name="l00437"></a><a class="code" href="class mlnorm.html">00437</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> {306 <a name="l00437"></a><a class="code" href="classbdm_1_1mlnorm.html">00437</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mEF.html" title="Exponential family model.">mEF</a> { 307 307 <a name="l00438"></a>00438 <span class="keyword">protected</span>: 308 <a name="l00440"></a><a class="code" href="class mlnorm.html#b76ee2171ace4fb3ff95a131ae8fc421">00440</a> <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>;308 <a name="l00440"></a><a class="code" href="classbdm_1_1mlnorm.html#150ad6acb223b0a0abeaf92346686dcd">00440</a> <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T></a> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>; 309 309 <a name="l00441"></a>00441 mat A; 310 310 <a name="l00442"></a>00442 vec mu_const; 311 311 <a name="l00443"></a>00443 vec& _mu; <span class="comment">//cached epdf.mu;</span> 312 312 <a name="l00444"></a>00444 <span class="keyword">public</span>: 313 <a name="l00446"></a>00446 <a class="code" href="class mlnorm.html#3a5ad4798d8a3878c5e93b8e796c8837" title="Constructor.">mlnorm</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> );314 <a name="l00448"></a>00448 <span class="keywordtype">void</span> <a class="code" href="class mlnorm.html#f95dfce0b500636a44ecd7e5210de999" title="Set A and R.">set_parameters</a> ( <span class="keyword">const</span> mat &A, <span class="keyword">const</span> vec &mu0, <span class="keyword">const</span> sq_T &R );313 <a name="l00446"></a>00446 <a class="code" href="classbdm_1_1mlnorm.html#64d965df6811ff65b94718c427048f4a" title="Constructor.">mlnorm</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1mpdf.html#9bcfb45435d30983f436d41c298cbb51" title="modeled random variable">rv</a>, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a> ); 314 <a name="l00448"></a>00448 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlnorm.html#5d18dec3167584338a4775c1d165d96f" title="Set A and R.">set_parameters</a> ( <span class="keyword">const</span> mat &A, <span class="keyword">const</span> vec &mu0, <span class="keyword">const</span> sq_T &R ); 315 315 <a name="l00449"></a>00449 <span class="comment">// //!Generate one sample of the posterior</span> 316 316 <a name="l00450"></a>00450 <span class="comment">// vec samplecond (const vec &cond, double &lik );</span> 317 317 <a name="l00451"></a>00451 <span class="comment">// //!Generate matrix of samples of the posterior</span> 318 318 <a name="l00452"></a>00452 <span class="comment">// mat samplecond (const vec &cond, vec &lik, int n );</span> 319 <a name="l00454"></a>00454 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="class mlnorm.html#d41126455ac64b888a38f677886e1b40" title="Set value of rvc . Result of this operation is stored in epdf use function _ep to...">condition</a> ( <span class="keyword">const</span> vec &cond );319 <a name="l00454"></a>00454 <span class="comment"></span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlnorm.html#0dafc0196e7e07fd06dc6716e0e18bc2" title="Set value of rvc . Result of this operation is stored in epdf use function _ep to...">condition</a> ( <span class="keyword">const</span> vec &cond ); 320 320 <a name="l00455"></a>00455 321 <a name="l00457"></a><a class="code" href="class mlnorm.html#2732ae47835dd25d5784bf08fde0a546">00457</a> vec& <a class="code" href="classmlnorm.html#2732ae47835dd25d5784bf08fde0a546" title="access function">_mu_const</a>() {<span class="keywordflow">return</span> mu_const;}322 <a name="l00459"></a><a class="code" href="class mlnorm.html#65ec3840c21b21102896bfd2282b47b3">00459</a> mat& <a class="code" href="classmlnorm.html#65ec3840c21b21102896bfd2282b47b3" title="access function">_A</a>() {<span class="keywordflow">return</span> A;}323 <a name="l00461"></a><a class="code" href="class mlnorm.html#3ff2b03fbb5e1133a5fe1bf831939f63">00461</a> mat <a class="code" href="classmlnorm.html#3ff2b03fbb5e1133a5fe1bf831939f63" title="access function">_R</a>() {<span class="keywordflow">return</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>._R().to_mat();}321 <a name="l00457"></a><a class="code" href="classbdm_1_1mlnorm.html#56e587952f94fcac6cfc999eae6dbced">00457</a> vec& <a class="code" href="classbdm_1_1mlnorm.html#56e587952f94fcac6cfc999eae6dbced" title="access function">_mu_const</a>() {<span class="keywordflow">return</span> mu_const;} 322 <a name="l00459"></a><a class="code" href="classbdm_1_1mlnorm.html#262a2a486bff585f34bb6a5005b02614">00459</a> mat& <a class="code" href="classbdm_1_1mlnorm.html#262a2a486bff585f34bb6a5005b02614" title="access function">_A</a>() {<span class="keywordflow">return</span> A;} 323 <a name="l00461"></a><a class="code" href="classbdm_1_1mlnorm.html#78120ecd1c2b1d7e80124b4603504604">00461</a> mat <a class="code" href="classbdm_1_1mlnorm.html#78120ecd1c2b1d7e80124b4603504604" title="access function">_R</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>._R().to_mat();} 324 324 <a name="l00462"></a>00462 325 325 <a name="l00463"></a>00463 <span class="keyword">template</span><<span class="keyword">class</span> sq_M> … … 327 327 <a name="l00465"></a>00465 }; 328 328 <a name="l00466"></a>00466 329 <a name="l00469"></a><a class="code" href="class mlstudent.html">00469</a> <span class="keyword">class </span><a class="code" href="classmlstudent.html">mlstudent</a> : <span class="keyword">public</span> <a class="code" href="classmlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm</a><ldmat> {329 <a name="l00469"></a><a class="code" href="classbdm_1_1mlstudent.html">00469</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mlstudent.html">mlstudent</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm</a><ldmat> { 330 330 <a name="l00470"></a>00470 <span class="keyword">protected</span>: 331 331 <a name="l00471"></a>00471 <a class="code" href="classldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a> Lambda; 332 <a name="l00472"></a>00472 <a class="code" href="classldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a> &<a class="code" href="class mlnorm.html#3ff2b03fbb5e1133a5fe1bf831939f63" title="access function">_R</a>;332 <a name="l00472"></a>00472 <a class="code" href="classldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a> &<a class="code" href="classbdm_1_1mlnorm.html#78120ecd1c2b1d7e80124b4603504604" title="access function">_R</a>; 333 333 <a name="l00473"></a>00473 <a class="code" href="classldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a> Re; 334 334 <a name="l00474"></a>00474 <span class="keyword">public</span>: 335 <a name="l00475"></a>00475 <a class="code" href="class mlstudent.html">mlstudent</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv0, <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rvc0 ) :<a class="code" href="classmlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm<ldmat></a> ( rv0,rvc0 ),336 <a name="l00476"></a>00476 Lambda ( rv0.<a class="code" href="class RV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>() ),337 <a name="l00477"></a>00477 <a class="code" href="class mlnorm.html#3ff2b03fbb5e1133a5fe1bf831939f63" title="access function">_R</a> ( <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>._R() ) {}335 <a name="l00475"></a>00475 <a class="code" href="classbdm_1_1mlstudent.html">mlstudent</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv0, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rvc0 ) :<a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm<ldmat></a> ( rv0,rvc0 ), 336 <a name="l00476"></a>00476 Lambda ( rv0.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>() ), 337 <a name="l00477"></a>00477 <a class="code" href="classbdm_1_1mlnorm.html#78120ecd1c2b1d7e80124b4603504604" title="access function">_R</a> ( <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>._R() ) {} 338 338 <a name="l00478"></a>00478 <span class="keywordtype">void</span> set_parameters ( <span class="keyword">const</span> mat &A0, <span class="keyword">const</span> vec &mu0, <span class="keyword">const</span> <a class="code" href="classldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a> &R0, <span class="keyword">const</span> <a class="code" href="classldmat.html" title="Matrix stored in LD form, (commonly known as UD).">ldmat</a>& Lambda0) { 339 <a name="l00479"></a>00479 <a class="code" href="class epdf.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>() ),Lambda );339 <a name="l00479"></a>00479 <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.set_parameters ( zeros ( <a class="code" href="classbdm_1_1mpdf.html#9bcfb45435d30983f436d41c298cbb51" title="modeled random variable">rv</a>.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>() ),Lambda ); 340 340 <a name="l00480"></a>00480 A = A0; 341 341 <a name="l00481"></a>00481 mu_const = mu0; … … 343 343 <a name="l00483"></a>00483 Lambda = Lambda0; 344 344 <a name="l00484"></a>00484 } 345 <a name="l00485"></a><a class="code" href="class mlstudent.html#d153460ae0180f4bc7f28301f5cde876">00485</a> <span class="keywordtype">void</span> <a class="code" href="classmlstudent.html#d153460ae0180f4bc7f28301f5cde876" title="Set value of rvc . Result of this operation is stored in epdf use function _ep to...">condition</a> ( <span class="keyword">const</span> vec &cond ) {345 <a name="l00485"></a><a class="code" href="classbdm_1_1mlstudent.html#efd37560585c8613897f30d3c2f58d0d">00485</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlstudent.html#efd37560585c8613897f30d3c2f58d0d" title="Set value of rvc . Result of this operation is stored in epdf use function _ep to...">condition</a> ( <span class="keyword">const</span> vec &cond ) { 346 346 <a name="l00486"></a>00486 _mu = A*cond + mu_const; 347 347 <a name="l00487"></a>00487 <span class="keywordtype">double</span> zeta; 348 348 <a name="l00488"></a>00488 <span class="comment">//ugly hack!</span> 349 349 <a name="l00489"></a>00489 <span class="keywordflow">if</span> ((cond.length()+1)==Lambda.<a class="code" href="group__math.html#g96dfb21865db4f5bd36fa70f9b0b1163" title="access function">rows</a>()){ 350 <a name="l00490"></a>00490 zeta = Lambda.<a class="code" href="classldmat.html#d876c5f83e02b3e809b35c9de5068f14" title="Evaluates quadratic form ;.">invqform</a> ( <a class="code" href="group__core.html#g33c114e83980d883c5b211c47d5322a4" title="Concat two random variables.">concat</a>(cond, vec_1(1.0)) );350 <a name="l00490"></a>00490 zeta = Lambda.<a class="code" href="classldmat.html#d876c5f83e02b3e809b35c9de5068f14" title="Evaluates quadratic form ;.">invqform</a> ( concat(cond, vec_1(1.0)) ); 351 351 <a name="l00491"></a>00491 } <span class="keywordflow">else</span> { 352 352 <a name="l00492"></a>00492 zeta = Lambda.<a class="code" href="classldmat.html#d876c5f83e02b3e809b35c9de5068f14" title="Evaluates quadratic form ;.">invqform</a> ( cond ); 353 353 <a name="l00493"></a>00493 } 354 <a name="l00494"></a>00494 <a class="code" href="class mlnorm.html#3ff2b03fbb5e1133a5fe1bf831939f63" title="access function">_R</a> = Re;355 <a name="l00495"></a>00495 <a class="code" href="class mlnorm.html#3ff2b03fbb5e1133a5fe1bf831939f63" title="access function">_R</a>*=( 1+zeta );<span class="comment">// / ( nu ); << nu is in Re!!!!!!</span>354 <a name="l00494"></a>00494 <a class="code" href="classbdm_1_1mlnorm.html#78120ecd1c2b1d7e80124b4603504604" title="access function">_R</a> = Re; 355 <a name="l00495"></a>00495 <a class="code" href="classbdm_1_1mlnorm.html#78120ecd1c2b1d7e80124b4603504604" title="access function">_R</a>*=( 1+zeta );<span class="comment">// / ( nu ); << nu is in Re!!!!!!</span> 356 356 <a name="l00496"></a>00496 }; 357 357 <a name="l00497"></a>00497 358 358 <a name="l00498"></a>00498 }; 359 <a name="l00508"></a><a class="code" href="class mgamma.html">00508</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> {359 <a name="l00508"></a><a class="code" href="classbdm_1_1mgamma.html">00508</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mgamma.html" title="Gamma random walk.">mgamma</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mEF.html" title="Exponential family model.">mEF</a> { 360 360 <a name="l00509"></a>00509 <span class="keyword">protected</span>: 361 <a name="l00511"></a><a class="code" href="class mgamma.html#612dbf35c770a780027619aaac2c443e">00511</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>;362 <a name="l00513"></a><a class="code" href="class mgamma.html#43f733cce0245a52363d566099add687">00513</a> <span class="keywordtype">double</span> <a class="code" href="classmgamma.html#43f733cce0245a52363d566099add687" title="Constant .">k</a>;363 <a name="l00515"></a><a class="code" href="class mgamma.html#5e90652837448bcc29707e7412f99691">00515</a> vec* <a class="code" href="classmgamma.html#5e90652837448bcc29707e7412f99691" title="cache of epdf.beta">_beta</a>;361 <a name="l00511"></a><a class="code" href="classbdm_1_1mgamma.html#bdc9f1e9e03c09e91103fee269864438">00511</a> <a class="code" href="classbdm_1_1egamma.html" title="Gamma posterior density.">egamma</a> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>; 362 <a name="l00513"></a><a class="code" href="classbdm_1_1mgamma.html#b20cf88cca1fe9b0b8f2a412608bfd09">00513</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mgamma.html#b20cf88cca1fe9b0b8f2a412608bfd09" title="Constant .">k</a>; 363 <a name="l00515"></a><a class="code" href="classbdm_1_1mgamma.html#f6a652ce70fa2eb4d2c7ba6d5a6ae343">00515</a> vec* <a class="code" href="classbdm_1_1mgamma.html#f6a652ce70fa2eb4d2c7ba6d5a6ae343" title="cache of epdf.beta">_beta</a>; 364 364 <a name="l00516"></a>00516 365 365 <a name="l00517"></a>00517 <span class="keyword">public</span>: 366 <a name="l00519"></a><a class="code" href="class mgamma.html#af43e61b86900c0398d5c0ffc83b94e6">00519</a> <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> ): <a class="code" href="classmEF.html" title="Exponential family model.">mEF</a> ( rv,rvc ), <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( rv ) {vec* tmp; <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>._param ( tmp,<a class="code" href="classmgamma.html#5e90652837448bcc29707e7412f99691" title="cache of epdf.beta">_beta</a> );<a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a>=&<a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>;};367 <a name="l00521"></a>00521 <span class="keywordtype">void</span> <a class="code" href="class mgamma.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> );368 <a name="l00522"></a><a class="code" href="class mgamma.html#a61094c9f7a2d64ea77b130cbc031f97">00522</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;};366 <a name="l00519"></a><a class="code" href="classbdm_1_1mgamma.html#2f6425cd966191b0be4c6ea91a40b6d9">00519</a> <a class="code" href="classbdm_1_1mgamma.html#2f6425cd966191b0be4c6ea91a40b6d9" title="Constructor.">mgamma</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1mpdf.html#9bcfb45435d30983f436d41c298cbb51" title="modeled random variable">rv</a>,<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a> ): <a class="code" href="classbdm_1_1mEF.html" title="Exponential family model.">mEF</a> ( rv,rvc ), <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( rv ) {vec* tmp; <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>._param ( tmp,<a class="code" href="classbdm_1_1mgamma.html#f6a652ce70fa2eb4d2c7ba6d5a6ae343" title="cache of epdf.beta">_beta</a> );<a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>=&<a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>;}; 367 <a name="l00521"></a>00521 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgamma.html#0b486f7e52a3d8a39adbcbd325461c0d" title="Set value of k.">set_parameters</a> ( <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mgamma.html#b20cf88cca1fe9b0b8f2a412608bfd09" title="Constant .">k</a> ); 368 <a name="l00522"></a><a class="code" href="classbdm_1_1mgamma.html#8996500f1885e39cde30221b20900bff">00522</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgamma.html#8996500f1885e39cde30221b20900bff" 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="classbdm_1_1mgamma.html#f6a652ce70fa2eb4d2c7ba6d5a6ae343" title="cache of epdf.beta">_beta</a>=<a class="code" href="classbdm_1_1mgamma.html#b20cf88cca1fe9b0b8f2a412608bfd09" title="Constant .">k</a>/val;}; 369 369 <a name="l00523"></a>00523 }; 370 370 <a name="l00524"></a>00524 371 <a name="l00534"></a><a class="code" href="class migamma.html">00534</a> <span class="keyword">class </span><a class="code" href="classmigamma.html" title="Inverse-Gamma random walk.">migamma</a> : <span class="keyword">public</span> <a class="code" href="classmEF.html" title="Exponential family model.">mEF</a> {371 <a name="l00534"></a><a class="code" href="classbdm_1_1migamma.html">00534</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1migamma.html" title="Inverse-Gamma random walk.">migamma</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mEF.html" title="Exponential family model.">mEF</a> { 372 372 <a name="l00535"></a>00535 <span class="keyword">protected</span>: 373 <a name="l00537"></a><a class="code" href="class migamma.html#74712a98f587efdf35da540f7f5b5d0d">00537</a> <a class="code" href="classeigamma.html" title="Inverse-Gamma posterior density.">eigamma</a> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>;374 <a name="l00539"></a><a class="code" href="class migamma.html#8425bc642c6f7876b578e666c841fa9c">00539</a> <span class="keywordtype">double</span> <a class="code" href="classmigamma.html#8425bc642c6f7876b578e666c841fa9c" title="Constant .">k</a>;375 <a name="l00541"></a><a class="code" href="class migamma.html#92c2e81705d8edb58181b61af75574e0">00541</a> vec* <a class="code" href="classmigamma.html#92c2e81705d8edb58181b61af75574e0" title="cache of epdf.beta">_beta</a>;376 <a name="l00543"></a><a class="code" href="class migamma.html#fb9bf89eb2c15fc267c97eef2218ebfa">00543</a> vec* <a class="code" href="classmigamma.html#fb9bf89eb2c15fc267c97eef2218ebfa" title="chaceh of epdf.alpha">_alpha</a>;373 <a name="l00537"></a><a class="code" href="classbdm_1_1migamma.html#a31b39d4179551b593c9e0d7d756783a">00537</a> <a class="code" href="classbdm_1_1eigamma.html" title="Inverse-Gamma posterior density.">eigamma</a> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>; 374 <a name="l00539"></a><a class="code" href="classbdm_1_1migamma.html#dc56bc9da542e0103ec16b9be8e5e38c">00539</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1migamma.html#dc56bc9da542e0103ec16b9be8e5e38c" title="Constant .">k</a>; 375 <a name="l00541"></a><a class="code" href="classbdm_1_1migamma.html#4825c0ef11a148bad9b802a496f56f96">00541</a> vec* <a class="code" href="classbdm_1_1migamma.html#4825c0ef11a148bad9b802a496f56f96" title="cache of epdf.beta">_beta</a>; 376 <a name="l00543"></a><a class="code" href="classbdm_1_1migamma.html#b6c265b132ff79963bf51dff4c3ef252">00543</a> vec* <a class="code" href="classbdm_1_1migamma.html#b6c265b132ff79963bf51dff4c3ef252" title="chaceh of epdf.alpha">_alpha</a>; 377 377 <a name="l00544"></a>00544 378 378 <a name="l00545"></a>00545 <span class="keyword">public</span>: 379 <a name="l00547"></a><a class="code" href="class migamma.html#81d6f9fe46acec656ccde245220b7090">00547</a> <a class="code" href="classmigamma.html#81d6f9fe46acec656ccde245220b7090" title="Constructor.">migamma</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> ): <a class="code" href="classmEF.html" title="Exponential family model.">mEF</a> ( rv,rvc ), <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( rv ) {<a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>._param ( <a class="code" href="classmigamma.html#fb9bf89eb2c15fc267c97eef2218ebfa" title="chaceh of epdf.alpha">_alpha</a>,<a class="code" href="classmigamma.html#92c2e81705d8edb58181b61af75574e0" title="cache of epdf.beta">_beta</a> );<a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a>=&<a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>;};380 <a name="l00549"></a><a class="code" href="class migamma.html#6cf801c0319ffcfc6317e9f2ecef4cf8">00549</a> <span class="keywordtype">void</span> <a class="code" href="classmigamma.html#6cf801c0319ffcfc6317e9f2ecef4cf8" title="Set value of k.">set_parameters</a> ( <span class="keywordtype">double</span> k0 ){<a class="code" href="classmigamma.html#8425bc642c6f7876b578e666c841fa9c" title="Constant .">k</a>=k0;*<a class="code" href="classmigamma.html#fb9bf89eb2c15fc267c97eef2218ebfa" title="chaceh of epdf.alpha">_alpha</a>=1.0/(<a class="code" href="classmigamma.html#8425bc642c6f7876b578e666c841fa9c" title="Constant .">k</a>*<a class="code" href="classmigamma.html#8425bc642c6f7876b578e666c841fa9c" title="Constant .">k</a>)+2;};381 <a name="l00550"></a><a class="code" href="class migamma.html#739c196dfcc586dec49043150da6ed0d">00550</a> <span class="keywordtype">void</span> <a class="code" href="classmigamma.html#739c196dfcc586dec49043150da6ed0d" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a> ( <span class="keyword">const</span> vec &val ) {382 <a name="l00551"></a>00551 *<a class="code" href="class migamma.html#92c2e81705d8edb58181b61af75574e0" title="cache of epdf.beta">_beta</a>=elem_mult(val,(*<a class="code" href="classmigamma.html#fb9bf89eb2c15fc267c97eef2218ebfa" title="chaceh of epdf.alpha">_alpha</a>-1));379 <a name="l00547"></a><a class="code" href="classbdm_1_1migamma.html#07c5970da0e578ce8a428f1ebf46a459">00547</a> <a class="code" href="classbdm_1_1migamma.html#07c5970da0e578ce8a428f1ebf46a459" title="Constructor.">migamma</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1mpdf.html#9bcfb45435d30983f436d41c298cbb51" title="modeled random variable">rv</a>,<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a> ): <a class="code" href="classbdm_1_1mEF.html" title="Exponential family model.">mEF</a> ( rv,rvc ), <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( rv ) {<a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>._param ( <a class="code" href="classbdm_1_1migamma.html#b6c265b132ff79963bf51dff4c3ef252" title="chaceh of epdf.alpha">_alpha</a>,<a class="code" href="classbdm_1_1migamma.html#4825c0ef11a148bad9b802a496f56f96" title="cache of epdf.beta">_beta</a> );<a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>=&<a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>;}; 380 <a name="l00549"></a><a class="code" href="classbdm_1_1migamma.html#1d7023b1565551d0260eb1ba832bebaf">00549</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1migamma.html#1d7023b1565551d0260eb1ba832bebaf" title="Set value of k.">set_parameters</a> ( <span class="keywordtype">double</span> k0 ){<a class="code" href="classbdm_1_1migamma.html#dc56bc9da542e0103ec16b9be8e5e38c" title="Constant .">k</a>=k0;*<a class="code" href="classbdm_1_1migamma.html#b6c265b132ff79963bf51dff4c3ef252" title="chaceh of epdf.alpha">_alpha</a>=1.0/(<a class="code" href="classbdm_1_1migamma.html#dc56bc9da542e0103ec16b9be8e5e38c" title="Constant .">k</a>*<a class="code" href="classbdm_1_1migamma.html#dc56bc9da542e0103ec16b9be8e5e38c" title="Constant .">k</a>)+2;}; 381 <a name="l00550"></a><a class="code" href="classbdm_1_1migamma.html#7a34b1e2e3aa2250d7c0ed7df1665b8c">00550</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1migamma.html#7a34b1e2e3aa2250d7c0ed7df1665b8c" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a> ( <span class="keyword">const</span> vec &val ) { 382 <a name="l00551"></a>00551 *<a class="code" href="classbdm_1_1migamma.html#4825c0ef11a148bad9b802a496f56f96" title="cache of epdf.beta">_beta</a>=elem_mult(val,(*<a class="code" href="classbdm_1_1migamma.html#b6c265b132ff79963bf51dff4c3ef252" title="chaceh of epdf.alpha">_alpha</a>-1)); 383 383 <a name="l00552"></a>00552 }; 384 384 <a name="l00553"></a>00553 }; 385 385 <a name="l00554"></a>00554 386 <a name="l00566"></a><a class="code" href="class mgamma__fix.html">00566</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> {386 <a name="l00566"></a><a class="code" href="classbdm_1_1mgamma__fix.html">00566</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mgamma__fix.html" title="Gamma random walk around a fixed point.">mgamma_fix</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mgamma.html" title="Gamma random walk.">mgamma</a> { 387 387 <a name="l00567"></a>00567 <span class="keyword">protected</span>: 388 <a name="l00569"></a><a class="code" href="class mgamma__fix.html#3f48c09caddc298901ad75fe7c0529f6">00569</a> <span class="keywordtype">double</span> <a class="code" href="classmgamma__fix.html#3f48c09caddc298901ad75fe7c0529f6" title="parameter l">l</a>;389 <a name="l00571"></a><a class="code" href="class mgamma__fix.html#81ce49029ecc385418619b200dcafeb0">00571</a> vec <a class="code" href="classmgamma__fix.html#81ce49029ecc385418619b200dcafeb0" title="reference vector">refl</a>;388 <a name="l00569"></a><a class="code" href="classbdm_1_1mgamma__fix.html#1eb701506aabb2e6af007e487212d6fa">00569</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mgamma__fix.html#1eb701506aabb2e6af007e487212d6fa" title="parameter l">l</a>; 389 <a name="l00571"></a><a class="code" href="classbdm_1_1mgamma__fix.html#018c6f901a04e419455308a07eb3b0b2">00571</a> vec <a class="code" href="classbdm_1_1mgamma__fix.html#018c6f901a04e419455308a07eb3b0b2" title="reference vector">refl</a>; 390 390 <a name="l00572"></a>00572 <span class="keyword">public</span>: 391 <a name="l00574"></a><a class="code" href="class mgamma__fix.html#b92c3d2e5fd0381033a072e5ef3bcf80">00574</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> &<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> ) : <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() ) {};392 <a name="l00576"></a><a class="code" href="class mgamma__fix.html#ec6f846896749e27cb7be9fa48dd1cb1">00576</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 ) {393 <a name="l00577"></a>00577 <a class="code" href="class mgamma.html#a9d646cf758a70126dde7c48790b6e94" title="Set value of k.">mgamma::set_parameters</a> ( k0 );394 <a name="l00578"></a>00578 <a class="code" href="class mgamma__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;391 <a name="l00574"></a><a class="code" href="classbdm_1_1mgamma__fix.html#c73571f45ab2926e5a7fb9c3791b5614">00574</a> <a class="code" href="classbdm_1_1mgamma__fix.html#c73571f45ab2926e5a7fb9c3791b5614" title="Constructor.">mgamma_fix</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1mpdf.html#9bcfb45435d30983f436d41c298cbb51" title="modeled random variable">rv</a>,<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a> ) : <a class="code" href="classbdm_1_1mgamma.html" title="Gamma random walk.">mgamma</a> ( rv,rvc ),<a class="code" href="classbdm_1_1mgamma__fix.html#018c6f901a04e419455308a07eb3b0b2" title="reference vector">refl</a> ( rv.count() ) {}; 392 <a name="l00576"></a><a class="code" href="classbdm_1_1mgamma__fix.html#1bfd30e90db9dc1fbda4a9fbb0b716b2">00576</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgamma__fix.html#1bfd30e90db9dc1fbda4a9fbb0b716b2" title="Set value of k.">set_parameters</a> ( <span class="keywordtype">double</span> k0 , vec ref0, <span class="keywordtype">double</span> l0 ) { 393 <a name="l00577"></a>00577 <a class="code" href="classbdm_1_1mgamma.html#0b486f7e52a3d8a39adbcbd325461c0d" title="Set value of k.">mgamma::set_parameters</a> ( k0 ); 394 <a name="l00578"></a>00578 <a class="code" href="classbdm_1_1mgamma__fix.html#018c6f901a04e419455308a07eb3b0b2" title="reference vector">refl</a>=pow ( ref0,1.0-l0 );<a class="code" href="classbdm_1_1mgamma__fix.html#1eb701506aabb2e6af007e487212d6fa" title="parameter l">l</a>=l0; 395 395 <a name="l00579"></a>00579 }; 396 396 <a name="l00580"></a>00580 397 <a name="l00581"></a><a class="code" href="class mgamma__fix.html#6ea3931eec7b7da7b693e45981052460">00581</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 ( <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;};397 <a name="l00581"></a><a class="code" href="classbdm_1_1mgamma__fix.html#1d539591deb7a38bb3403c2b396c8ff7">00581</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mgamma__fix.html#1d539591deb7a38bb3403c2b396c8ff7" 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 ( <a class="code" href="classbdm_1_1mgamma__fix.html#018c6f901a04e419455308a07eb3b0b2" title="reference vector">refl</a>,pow ( val,<a class="code" href="classbdm_1_1mgamma__fix.html#1eb701506aabb2e6af007e487212d6fa" title="parameter l">l</a> ) ); *<a class="code" href="classbdm_1_1mgamma.html#f6a652ce70fa2eb4d2c7ba6d5a6ae343" title="cache of epdf.beta">_beta</a>=<a class="code" href="classbdm_1_1mgamma.html#b20cf88cca1fe9b0b8f2a412608bfd09" title="Constant .">k</a>/mean;}; 398 398 <a name="l00582"></a>00582 }; 399 399 <a name="l00583"></a>00583 400 400 <a name="l00584"></a>00584 401 <a name="l00597"></a><a class="code" href="class migamma__fix.html">00597</a> <span class="keyword">class </span><a class="code" href="classmigamma__fix.html" title="Inverse-Gamma random walk around a fixed point.">migamma_fix</a> : <span class="keyword">public</span> <a class="code" href="classmigamma.html" title="Inverse-Gamma random walk.">migamma</a> {401 <a name="l00597"></a><a class="code" href="classbdm_1_1migamma__fix.html">00597</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1migamma__fix.html" title="Inverse-Gamma random walk around a fixed point.">migamma_fix</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1migamma.html" title="Inverse-Gamma random walk.">migamma</a> { 402 402 <a name="l00598"></a>00598 <span class="keyword">protected</span>: 403 <a name="l00600"></a><a class="code" href="class migamma__fix.html#13e0b9e3faf370a5ac24f2d8534047ec">00600</a> <span class="keywordtype">double</span> <a class="code" href="classmigamma__fix.html#13e0b9e3faf370a5ac24f2d8534047ec" title="parameter l">l</a>;404 <a name="l00602"></a><a class="code" href="class migamma__fix.html#7d0576daba2a1de5dc040dbfbd7dd446">00602</a> vec <a class="code" href="classmigamma__fix.html#7d0576daba2a1de5dc040dbfbd7dd446" title="reference vector">refl</a>;403 <a name="l00600"></a><a class="code" href="classbdm_1_1migamma__fix.html#e1c344accac36d7ccc3ffa502e8d2f4e">00600</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1migamma__fix.html#e1c344accac36d7ccc3ffa502e8d2f4e" title="parameter l">l</a>; 404 <a name="l00602"></a><a class="code" href="classbdm_1_1migamma__fix.html#5d453e5a2bdfc9a16c8acb8842dc9780">00602</a> vec <a class="code" href="classbdm_1_1migamma__fix.html#5d453e5a2bdfc9a16c8acb8842dc9780" title="reference vector">refl</a>; 405 405 <a name="l00603"></a>00603 <span class="keyword">public</span>: 406 <a name="l00605"></a><a class="code" href="class migamma__fix.html#85ff4fae4d3faefed060c515f255207e">00605</a> <a class="code" href="classmigamma__fix.html#85ff4fae4d3faefed060c515f255207e" title="Constructor.">migamma_fix</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> ) : <a class="code" href="classmigamma.html" title="Inverse-Gamma random walk.">migamma</a> ( rv,rvc ),<a class="code" href="classmigamma__fix.html#7d0576daba2a1de5dc040dbfbd7dd446" title="reference vector">refl</a> ( rv.count() ) {};407 <a name="l00607"></a><a class="code" href="class migamma__fix.html#6266e14eb59fe36f494cfb5934a8e987">00607</a> <span class="keywordtype">void</span> <a class="code" href="classmigamma__fix.html#6266e14eb59fe36f494cfb5934a8e987" title="Set value of k.">set_parameters</a> ( <span class="keywordtype">double</span> k0 , vec ref0, <span class="keywordtype">double</span> l0 ) {408 <a name="l00608"></a>00608 <a class="code" href="class migamma.html#6cf801c0319ffcfc6317e9f2ecef4cf8" title="Set value of k.">migamma::set_parameters</a> ( k0 );409 <a name="l00609"></a>00609 <a class="code" href="class migamma__fix.html#7d0576daba2a1de5dc040dbfbd7dd446" title="reference vector">refl</a>=pow ( ref0,1.0-l0 );<a class="code" href="classmigamma__fix.html#13e0b9e3faf370a5ac24f2d8534047ec" title="parameter l">l</a>=l0;406 <a name="l00605"></a><a class="code" href="classbdm_1_1migamma__fix.html#3c6aacebccbe6d73f8d442e82d3cb53a">00605</a> <a class="code" href="classbdm_1_1migamma__fix.html#3c6aacebccbe6d73f8d442e82d3cb53a" title="Constructor.">migamma_fix</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1mpdf.html#9bcfb45435d30983f436d41c298cbb51" title="modeled random variable">rv</a>,<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a> ) : <a class="code" href="classbdm_1_1migamma.html" title="Inverse-Gamma random walk.">migamma</a> ( rv,rvc ),<a class="code" href="classbdm_1_1migamma__fix.html#5d453e5a2bdfc9a16c8acb8842dc9780" title="reference vector">refl</a> ( rv.count() ) {}; 407 <a name="l00607"></a><a class="code" href="classbdm_1_1migamma__fix.html#17f9ce1068660a4e8c05173bef7d7440">00607</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1migamma__fix.html#17f9ce1068660a4e8c05173bef7d7440" title="Set value of k.">set_parameters</a> ( <span class="keywordtype">double</span> k0 , vec ref0, <span class="keywordtype">double</span> l0 ) { 408 <a name="l00608"></a>00608 <a class="code" href="classbdm_1_1migamma.html#1d7023b1565551d0260eb1ba832bebaf" title="Set value of k.">migamma::set_parameters</a> ( k0 ); 409 <a name="l00609"></a>00609 <a class="code" href="classbdm_1_1migamma__fix.html#5d453e5a2bdfc9a16c8acb8842dc9780" title="reference vector">refl</a>=pow ( ref0,1.0-l0 );<a class="code" href="classbdm_1_1migamma__fix.html#e1c344accac36d7ccc3ffa502e8d2f4e" title="parameter l">l</a>=l0; 410 410 <a name="l00610"></a>00610 }; 411 411 <a name="l00611"></a>00611 412 <a name="l00612"></a><a class="code" href="class migamma__fix.html#a69739eebfe05835db11bc3544cec6a1">00612</a> <span class="keywordtype">void</span> <a class="code" href="classmigamma__fix.html#a69739eebfe05835db11bc3544cec6a1" 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 ( <a class="code" href="classmigamma__fix.html#7d0576daba2a1de5dc040dbfbd7dd446" title="reference vector">refl</a>,pow ( val,<a class="code" href="classmigamma__fix.html#13e0b9e3faf370a5ac24f2d8534047ec" title="parameter l">l</a> ) ); <a class="code" href="classmigamma.html#739c196dfcc586dec49043150da6ed0d" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">migamma::condition</a>(mean);};412 <a name="l00612"></a><a class="code" href="classbdm_1_1migamma__fix.html#cfbabd293795d44aae1b7c874e57c4b8">00612</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1migamma__fix.html#cfbabd293795d44aae1b7c874e57c4b8" 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 ( <a class="code" href="classbdm_1_1migamma__fix.html#5d453e5a2bdfc9a16c8acb8842dc9780" title="reference vector">refl</a>,pow ( val,<a class="code" href="classbdm_1_1migamma__fix.html#e1c344accac36d7ccc3ffa502e8d2f4e" title="parameter l">l</a> ) ); <a class="code" href="classbdm_1_1migamma.html#7a34b1e2e3aa2250d7c0ed7df1665b8c" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">migamma::condition</a>(mean);}; 413 413 <a name="l00613"></a>00613 }; 414 <a name="l00615"></a> <a class="code" href="libEF_8h.html#99497a3ff630f761cf6bff7babd23212">00615</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 };415 <a name="l00621"></a><a class="code" href="class eEmp.html">00621</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> {414 <a name="l00615"></a>00615 <span class="keyword">enum</span> RESAMPLING_METHOD { MULTINOMIAL = 0, STRATIFIED = 1, SYSTEMATIC = 3 }; 415 <a name="l00621"></a><a class="code" href="classbdm_1_1eEmp.html">00621</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1eEmp.html" title="Weighted empirical density.">eEmp</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> { 416 416 <a name="l00622"></a>00622 <span class="keyword">protected</span> : 417 <a name="l00624"></a><a class="code" href="class eEmp.html#8c33034de0e35f03f8bb85d3d67438fd">00624</a> <span class="keywordtype">int</span> <a class="code" href="classeEmp.html#8c33034de0e35f03f8bb85d3d67438fd" title="Number of particles.">n</a>;418 <a name="l00626"></a><a class="code" href="class eEmp.html#ae78d144404ddba843c93b171b215de8">00626</a> vec <a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8" title="Sample weights .">w</a>;419 <a name="l00628"></a><a class="code" href="class eEmp.html#a4d6f4bbd6a6824fc39f14676701279a">00628</a> Array<vec> <a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a" title="Samples .">samples</a>;417 <a name="l00624"></a><a class="code" href="classbdm_1_1eEmp.html#9798006271ca77629855113f1283a031">00624</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1eEmp.html#9798006271ca77629855113f1283a031" title="Number of particles.">n</a>; 418 <a name="l00626"></a><a class="code" href="classbdm_1_1eEmp.html#9d39241aab7c4bbeb07c6d516421c67d">00626</a> vec <a class="code" href="classbdm_1_1eEmp.html#9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a>; 419 <a name="l00628"></a><a class="code" href="classbdm_1_1eEmp.html#73d819553a0f268b055a087d2d4486f3">00628</a> Array<vec> <a class="code" href="classbdm_1_1eEmp.html#73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a>; 420 420 <a name="l00629"></a>00629 <span class="keyword">public</span>: 421 <a name="l00631"></a><a class="code" href="class eEmp.html#0c04b073ecd0dae3d498e680ae27e9e4">00631</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> ) {};422 <a name="l00633"></a>00633 <span class="keywordtype">void</span> <a class="code" href="class eEmp.html#eab03bd3381aaea11ce34d5a26556353" title="Set samples and weights.">set_parameters</a> ( <span class="keyword">const</span> vec &w0, <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* pdf0 );423 <a name="l00635"></a>00635 <span class="keywordtype">void</span> <a class="code" href="class eEmp.html#e31bc9e6196173c3480b06a761a3e716" title="Set sample.">set_samples</a> ( <span class="keyword">const</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* pdf0 );424 <a name="l00637"></a><a class="code" href="class eEmp.html#a4215f6a5a04d07b43f7ebaa942e15f1">00637</a> <span class="keywordtype">void</span> <a class="code" href="classeEmp.html#a4215f6a5a04d07b43f7ebaa942e15f1" title="Set sample.">set_n</a> ( <span class="keywordtype">int</span> n0, <span class="keywordtype">bool</span> copy=<span class="keyword">true</span> ){<a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8" title="Sample weights .">w</a>.set_size(n0,copy);<a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a" title="Samples .">samples</a>.set_size(n0,copy);};425 <a name="l00639"></a><a class="code" href="class eEmp.html#31b2bfb73b72486a5c89f2ab850c7a9b">00639</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>;};426 <a name="l00641"></a><a class="code" href="class eEmp.html#d6f4ae1a67ecd2bff8b9f176ee261afc">00641</a> <span class="keyword">const</span> vec& <a class="code" href="classeEmp.html#31b2bfb73b72486a5c89f2ab850c7a9b" title="Potentially dangerous, use with care.">_w</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8" title="Sample weights .">w</a>;};427 <a name="l00643"></a><a class="code" href="class eEmp.html#31b747eca73b16f30370827ba4cc3575">00643</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>;};428 <a name="l00645"></a><a class="code" href="class eEmp.html#bd48c1c36e2e9e78dbcea7df66dcbf25">00645</a> <span class="keyword">const</span> Array<vec>& <a class="code" href="classeEmp.html#31b747eca73b16f30370827ba4cc3575" title="access function">_samples</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a" title="Samples .">samples</a>;};429 <a name="l00647"></a>00647 ivec <a class="code" href="class eEmp.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 );430 <a name="l00649"></a><a class="code" href="class eEmp.html#83f9283f92b805508d896479dc1ccf12">00649</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;}431 <a name="l00651"></a><a class="code" href="class eEmp.html#884f16c9fc1f888408686a660a95dacd">00651</a> <span class="keywordtype">double</span> <a class="code" href="classeEmp.html#884f16c9fc1f888408686a660a95dacd" title="inherited operation : NOT implemneted">evallog</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;}432 <a name="l00652"></a><a class="code" href="class eEmp.html#ba055c19038cc72628d98e25197e982d">00652</a> vec <a class="code" href="classeEmp.html#ba055c19038cc72628d98e25197e982d" title="return expected value">mean</a>()<span class="keyword"> const </span>{433 <a name="l00653"></a>00653 vec pom=zeros ( <a class="code" href="class epdf.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>() );434 <a name="l00654"></a>00654 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="class eEmp.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 );}421 <a name="l00631"></a><a class="code" href="classbdm_1_1eEmp.html#47ee4feee19b3f3e2d371f8fc9f9a863">00631</a> <a class="code" href="classbdm_1_1eEmp.html#47ee4feee19b3f3e2d371f8fc9f9a863" title="Default constructor.">eEmp</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv0 ,<span class="keywordtype">int</span> n0 ) :<a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( rv0 ),<a class="code" href="classbdm_1_1eEmp.html#9798006271ca77629855113f1283a031" title="Number of particles.">n</a> ( n0 ),<a class="code" href="classbdm_1_1eEmp.html#9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a> ( <a class="code" href="classbdm_1_1eEmp.html#9798006271ca77629855113f1283a031" title="Number of particles.">n</a> ),<a class="code" href="classbdm_1_1eEmp.html#73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a> ( <a class="code" href="classbdm_1_1eEmp.html#9798006271ca77629855113f1283a031" title="Number of particles.">n</a> ) {}; 422 <a name="l00633"></a>00633 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eEmp.html#82320074a9b0ad7e1bb33a6e885b65d7" title="Set samples and weights.">set_parameters</a> ( <span class="keyword">const</span> vec &w0, <span class="keyword">const</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* pdf0 ); 423 <a name="l00635"></a>00635 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eEmp.html#b62d802b8ef39f7c4dcbeb366c90951a" title="Set sample.">set_samples</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* pdf0 ); 424 <a name="l00637"></a><a class="code" href="classbdm_1_1eEmp.html#dccd02eaa4c45e858a6351723686ac85">00637</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eEmp.html#dccd02eaa4c45e858a6351723686ac85" title="Set sample.">set_n</a> ( <span class="keywordtype">int</span> n0, <span class="keywordtype">bool</span> copy=<span class="keyword">true</span> ){<a class="code" href="classbdm_1_1eEmp.html#9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a>.set_size(n0,copy);<a class="code" href="classbdm_1_1eEmp.html#73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a>.set_size(n0,copy);}; 425 <a name="l00639"></a><a class="code" href="classbdm_1_1eEmp.html#d7f83cc0415cd44ae7cc8b4bdad93aef">00639</a> vec& <a class="code" href="classbdm_1_1eEmp.html#d7f83cc0415cd44ae7cc8b4bdad93aef" title="Potentially dangerous, use with care.">_w</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eEmp.html#9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a>;}; 426 <a name="l00641"></a><a class="code" href="classbdm_1_1eEmp.html#b7d7106f486e3fad38590914a693d714">00641</a> <span class="keyword">const</span> vec& <a class="code" href="classbdm_1_1eEmp.html#d7f83cc0415cd44ae7cc8b4bdad93aef" title="Potentially dangerous, use with care.">_w</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eEmp.html#9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a>;}; 427 <a name="l00643"></a><a class="code" href="classbdm_1_1eEmp.html#c24966b0aaeb767bc8a6b4fd60931be2">00643</a> Array<vec>& <a class="code" href="classbdm_1_1eEmp.html#c24966b0aaeb767bc8a6b4fd60931be2" title="access function">_samples</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eEmp.html#73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a>;}; 428 <a name="l00645"></a><a class="code" href="classbdm_1_1eEmp.html#b59af0efdb009d98ea8ebfa965e74ae2">00645</a> <span class="keyword">const</span> Array<vec>& <a class="code" href="classbdm_1_1eEmp.html#c24966b0aaeb767bc8a6b4fd60931be2" title="access function">_samples</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eEmp.html#73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a>;}; 429 <a name="l00647"></a>00647 ivec <a class="code" href="classbdm_1_1eEmp.html#f06ce255de5dbb2313f52ee51f82ba3d" title="Function performs resampling, i.e. removal of low-weight samples and duplication...">resample</a> ( RESAMPLING_METHOD method = SYSTEMATIC ); 430 <a name="l00649"></a><a class="code" href="classbdm_1_1eEmp.html#97f1e07b5ae6eebc91c7365f0f88d270">00649</a> vec <a class="code" href="classbdm_1_1eEmp.html#97f1e07b5ae6eebc91c7365f0f88d270" 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;} 431 <a name="l00651"></a><a class="code" href="classbdm_1_1eEmp.html#01654c014d3aa068f8d4ecba4be86d09">00651</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eEmp.html#01654c014d3aa068f8d4ecba4be86d09" title="inherited operation : NOT implemneted">evallog</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;} 432 <a name="l00652"></a><a class="code" href="classbdm_1_1eEmp.html#bbfcb4f868c7381298c281a256d8c4b9">00652</a> vec <a class="code" href="classbdm_1_1eEmp.html#bbfcb4f868c7381298c281a256d8c4b9" title="return expected value">mean</a>()<span class="keyword"> const </span>{ 433 <a name="l00653"></a>00653 vec pom=zeros ( <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>() ); 434 <a name="l00654"></a>00654 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eEmp.html#9798006271ca77629855113f1283a031" title="Number of particles.">n</a>;i++ ) {pom+=<a class="code" href="classbdm_1_1eEmp.html#73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a> ( i ) *<a class="code" href="classbdm_1_1eEmp.html#9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a> ( i );} 435 435 <a name="l00655"></a>00655 <span class="keywordflow">return</span> pom; 436 436 <a name="l00656"></a>00656 } 437 <a name="l00657"></a><a class="code" href="class eEmp.html#738f6ec90cf1a8306ed8c259142a2f79">00657</a> vec <a class="code" href="classeEmp.html#738f6ec90cf1a8306ed8c259142a2f79" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{438 <a name="l00658"></a>00658 vec pom=zeros ( <a class="code" href="class epdf.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>() );439 <a name="l00659"></a>00659 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="class eEmp.html#8c33034de0e35f03f8bb85d3d67438fd" title="Number of particles.">n</a>;i++ ) {pom+=pow(<a class="code" href="classeEmp.html#a4d6f4bbd6a6824fc39f14676701279a" title="Samples .">samples</a> ( i ),2) *<a class="code" href="classeEmp.html#ae78d144404ddba843c93b171b215de8" title="Sample weights .">w</a> ( i );}440 <a name="l00660"></a>00660 <span class="keywordflow">return</span> pom-pow(<a class="code" href="class eEmp.html#ba055c19038cc72628d98e25197e982d" title="return expected value">mean</a>(),2);437 <a name="l00657"></a><a class="code" href="classbdm_1_1eEmp.html#05e9ebf467ede737cb6a3621d7fd3c87">00657</a> vec <a class="code" href="classbdm_1_1eEmp.html#05e9ebf467ede737cb6a3621d7fd3c87" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{ 438 <a name="l00658"></a>00658 vec pom=zeros ( <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>() ); 439 <a name="l00659"></a>00659 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eEmp.html#9798006271ca77629855113f1283a031" title="Number of particles.">n</a>;i++ ) {pom+=pow(<a class="code" href="classbdm_1_1eEmp.html#73d819553a0f268b055a087d2d4486f3" title="Samples .">samples</a> ( i ),2) *<a class="code" href="classbdm_1_1eEmp.html#9d39241aab7c4bbeb07c6d516421c67d" title="Sample weights .">w</a> ( i );} 440 <a name="l00660"></a>00660 <span class="keywordflow">return</span> pom-pow(<a class="code" href="classbdm_1_1eEmp.html#bbfcb4f868c7381298c281a256d8c4b9" title="return expected value">mean</a>(),2); 441 441 <a name="l00661"></a>00661 } 442 442 <a name="l00662"></a>00662 }; … … 445 445 <a name="l00666"></a>00666 446 446 <a name="l00667"></a>00667 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> 447 <a name="l00668"></a><a class="code" href="class enorm.html#0caf54fed9e48f9fe28b534b2027df2f">00668</a> <a class="code" href="classenorm.html#0caf54fed9e48f9fe28b534b2027df2f" title="Default constructor.">enorm<sq_T>::enorm</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv ) :<a class="code" href="classeEF.html" title="General conjugate exponential family posterior density.">eEF</a> ( rv ), mu ( rv.count() ),R ( rv.count() ),dim ( rv.count() ) {};447 <a name="l00668"></a><a class="code" href="classbdm_1_1enorm.html#7d433390d6bbad337986945b63d7fbe9">00668</a> <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T>::enorm</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv ) :<a class="code" href="classbdm_1_1eEF.html" title="General conjugate exponential family posterior density.">eEF</a> ( rv ), mu ( rv.count() ),R ( rv.count() ),dim ( rv.count() ) {}; 448 448 <a name="l00669"></a>00669 449 449 <a name="l00670"></a>00670 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> 450 <a name="l00671"></a><a class="code" href="class enorm.html#1394a65caa6e00d42e00cc99b12227af">00671</a> <span class="keywordtype">void</span> <a class="code" href="classenorm.html#1394a65caa6e00d42e00cc99b12227af" title="Set mean value mu and covariance R.">enorm<sq_T>::set_parameters</a> ( <span class="keyword">const</span> vec &mu0, <span class="keyword">const</span> sq_T &R0 ) {450 <a name="l00671"></a><a class="code" href="classbdm_1_1enorm.html#b8322f2c11560871dd922c660f4771bb">00671</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T>::set_parameters</a> ( <span class="keyword">const</span> vec &mu0, <span class="keyword">const</span> sq_T &R0 ) { 451 451 <a name="l00672"></a>00672 <span class="comment">//Fixme test dimensions of mu0 and R0;</span> 452 <a name="l00673"></a>00673 <a class="code" href="class enorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a> = mu0;453 <a name="l00674"></a>00674 <a class="code" href="class enorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a> = R0;452 <a name="l00673"></a>00673 <a class="code" href="classbdm_1_1enorm.html#c702a194720853570d08b65482f842c7" title="mean value">mu</a> = mu0; 453 <a name="l00674"></a>00674 <a class="code" href="classbdm_1_1enorm.html#2d92dde696b2a7a5b10ddef5d22ba2c2" title="Covariance matrix in decomposed form.">R</a> = R0; 454 454 <a name="l00675"></a>00675 }; 455 455 <a name="l00676"></a>00676 456 456 <a name="l00677"></a>00677 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> 457 <a name="l00678"></a><a class="code" href="class enorm.html#5bf185e31e5954fceb90ada3debd2ff2">00678</a> <span class="keywordtype">void</span> <a class="code" href="classenorm.html#5bf185e31e5954fceb90ada3debd2ff2" title="dupdate in exponential form (not really handy)">enorm<sq_T>::dupdate</a> ( mat &v, <span class="keywordtype">double</span> nu ) {457 <a name="l00678"></a><a class="code" href="classbdm_1_1enorm.html#d2e0d3a1e30ab3ab04df2d0c43ae74a2">00678</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T>::dupdate</a> ( mat &v, <span class="keywordtype">double</span> nu ) { 458 458 <a name="l00679"></a>00679 <span class="comment">//</span> 459 459 <a name="l00680"></a>00680 }; … … 465 465 <a name="l00686"></a>00686 466 466 <a name="l00687"></a>00687 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> 467 <a name="l00688"></a><a class="code" href="class enorm.html#60b47544f6181ffd4530d3e415ce12c5">00688</a> vec <a class="code" href="classenorm.html#60b47544f6181ffd4530d3e415ce12c5" title="Returns a sample, from density.">enorm<sq_T>::sample</a>()<span class="keyword"> const </span>{468 <a name="l00689"></a>00689 vec x ( <a class="code" href="class enorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a> );469 <a name="l00690"></a>00690 NorRNG.sample_vector ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a>,x );470 <a name="l00691"></a>00691 vec smp = <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.sqrt_mult (x );471 <a name="l00692"></a>00692 472 <a name="l00693"></a>00693 smp += <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>;473 <a name="l00694"></a>00694 <span class="keywordflow">return</span> smp;474 <a name="l00695"></a>00695 };475 <a name="l00696"></a>00696 476 <a name="l00697"></a>00697 <span class="keyword">template</span><<span class="keyword">class</span> sq_T>477 <a name="l00698"></a> <a class="code" href="classenorm.html#60f0f3bfa53d6e65843eea9532b16d36">00698</a> mat <a class="code" href="classenorm.html#60b47544f6181ffd4530d3e415ce12c5" title="Returns a sample, from density .">enorm<sq_T>::sample</a> ( <span class="keywordtype">int</span> N )<span class="keyword"> const </span>{478 <a name="l00699"></a> 00699 mat X ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a>,N );479 <a name="l00700"></a>00700 vec x ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a>);480 <a name="l00701"></a>00701 vec pom;481 <a name="l00702"></a>00702 <span class="keywordtype">int</span> i;482 <a name="l00703"></a>00703 483 <a name="l00704"></a>00704 <span class="keywordflow">for</span> ( i=0;i<N;i++ ) {484 <a name="l00705"></a>00705 NorRNG.sample_vector ( <a class="code" href="classenorm.html#6938fc390a19cdaf6ad4503fcbaada4e" title="dimension (redundant from rv.count() for easier coding )">dim</a>,x );485 <a name="l00706"></a>00706 pom = <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.sqrt_mult ( x );486 <a name="l00707"></a>00707 pom +=<a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a>;487 <a name="l00708"></a>00708 X.set_col ( i, pom);488 <a name="l00709"></a>00709 }489 <a name="l00710"></a>00710 490 <a name="l00711"></a>00711 <span class="keywordflow">return</span> X;491 <a name="l00712"></a>00712 };492 <a name="l00713"></a>00713 493 <a name="l00714"></a>00714 <span class="comment">// template<class sq_T></span>494 <a name="l00715"></a>00715 <span class="comment">// double enorm<sq_T>::eval ( const vec &val ) const {</span>495 <a name="l00716"></a>00716 <span class="comment">// double pdfl,e;</span>496 <a name="l00717"></a>00717 <span class="comment">// pdfl = evallog ( val );</span>497 <a name="l00718"></a>00718 <span class="comment">// e = exp ( pdfl );</span>498 <a name="l00719"></a>00719 <span class="comment">// return e;</span>499 <a name="l00720"></a>00720 <span class="comment">// };</span>500 <a name="l00721"></a>00721 501 <a name="l00722"></a>00722 <span class=" keyword">template</span><<span class="keyword">class</span> sq_T>502 <a name="l00723"></a> <a class="code" href="classenorm.html#50cb0a083d97a7adbbd97c92e712c46c">00723</a> <span class="keywordtype">double</span> <a class="code" href="classenorm.html#50cb0a083d97a7adbbd97c92e712c46c" title="Evaluate normalized log-probability.">enorm<sq_T>::evallog_nn</a> ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{503 <a name="l00724"></a>00724 <span class="comment">// 1.83787706640935 = log(2pi)</span>504 <a name="l00725"></a> 00725 <span class="keywordtype">double</span> tmp=-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 ) );<span class="comment">// - lognc();</span>505 <a name="l00726"></a>00726 <span class=" keywordflow">return</span> tmp;506 <a name="l00727"></a>00727 };507 <a name="l00728"></a>00728 508 <a name="l00729"></a>00729 <span class="keyword">template</span><<span class="keyword">class</span> sq_T>509 <a name="l00730"></a> <a class="code" href="classenorm.html#b289a36a69db59d182bb6eba9c05d4a8">00730</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<sq_T>::lognc</a> ()<span class="keyword"> const </span>{510 <a name="l00731"></a>00731 <span class="comment">// 1.83787706640935 = log(2pi)</span>511 <a name="l00732"></a> 00732 <span class="keywordtype">double</span> tmp=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() );512 <a name="l00733"></a>00733 <span class=" keywordflow">return</span> tmp;513 <a name="l00734"></a>00734 };514 <a name="l00735"></a>00735 515 <a name="l00736"></a>00736 <span class="keyword">template</span><<span class="keyword">class</span> sq_T>516 <a name="l00737"></a> <a class="code" href="classmlnorm.html#3a5ad4798d8a3878c5e93b8e796c8837">00737</a> <a class="code" href="classmlnorm.html#3a5ad4798d8a3878c5e93b8e796c8837" title="Constructor.">mlnorm<sq_T>::mlnorm</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rv0, <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rvc0 ) :<a class="code" href="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>() ) {517 <a name="l00738"></a>00738 <a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a> =&<a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>;518 <a name="l00739"></a> 00739 }519 <a name="l00740"></a>00740 520 <a name="l00741"></a>00741 <span class="keyword">template</span><<span class="keyword">class</span> sq_T>521 <a name="l00742"></a> <a class="code" href="classmlnorm.html#f95dfce0b500636a44ecd7e5210de999">00742</a> <span class="keywordtype">void</span> <a class="code" href="classmlnorm.html#f95dfce0b500636a44ecd7e5210de999" title="Set A and R.">mlnorm<sq_T>::set_parameters</a> ( <span class="keyword">const</span> mat &A0, <span class="keyword">const</span> vec &mu0, <span class="keyword">const</span> sq_T &R0 ) {522 <a name="l00743"></a>00743 <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 );523 <a name="l00744"></a> 00744 A = A0;524 <a name="l00745"></a>00745 mu_const = mu0;525 <a name="l00746"></a>00746 }526 <a name="l00747"></a>00747 527 <a name="l00748"></a>00748 <span class="comment">// template<class sq_T></span>528 <a name="l00749"></a>00749 <span class="comment">// vec mlnorm<sq_T>::samplecond (const vec &cond, double &lik ) {</span>529 <a name="l00750"></a>00750 <span class="comment">// this->condition ( cond );</span>530 <a name="l00751"></a>00751 <span class="comment">// vec smp = epdf.sample();</span>531 <a name="l00752"></a>00752 <span class="comment">// lik = epdf.eval ( smp);</span>532 <a name="l00753"></a>00753 <span class="comment">// return smp;</span>533 <a name="l00754"></a>00754 <span class="comment">// }</span>534 <a name="l00755"></a>00755 535 <a name="l00756"></a>00756 <span class="comment">// template<class sq_T></span>536 <a name="l00757"></a>00757 <span class="comment">// mat mlnorm<sq_T>::samplecond (const vec &cond, vec &lik, int n ) {</span>537 <a name="l00758"></a>00758 <span class="comment">// int i;</span>538 <a name="l00759"></a>00759 <span class="comment">// int dim = rv.count();</span>539 <a name="l00760"></a>00760 <span class="comment">// mat Smp ( dim,n );</span>540 <a name="l00761"></a>00761 <span class="comment">// vec smp ( dim);</span>541 <a name="l00762"></a>00762 <span class="comment">// this->condition ( cond);</span>542 <a name="l00763"></a>00763 <span class="comment">// </span>543 <a name="l00764"></a>00764 <span class="comment">// for ( i=0; i<n; i++ ) {</span>544 <a name="l00765"></a>00765 <span class="comment">// smp = epdf.sample();</span>545 <a name="l00766"></a>00766 <span class="comment">// lik ( i ) = epdf.eval ( smp );</span>546 <a name="l00767"></a>00767 <span class="comment">// Smp.set_col ( i ,smp);</span>547 <a name="l00768"></a>00768 <span class="comment">// }</span>548 <a name="l00769"></a>00769 <span class="comment">// </span>549 <a name="l00770"></a>00770 <span class="comment">// return Smp;</span>550 <a name="l00771"></a>00771 <span class="comment">// }</span>551 <a name="l00772"></a>00772 552 <a name="l00773"></a>00773 <span class=" keyword">template</span><<span class="keyword">class</span> sq_T>553 <a name="l00774"></a> <a class="code" href="classmlnorm.html#d41126455ac64b888a38f677886e1b40">00774</a> <span class="keywordtype">void</span> <a class="code" href="classmlnorm.html#d41126455ac64b888a38f677886e1b40" title="Set value of rvc . Result of this operation is stored in epdf use function _ep to...">mlnorm<sq_T>::condition</a> ( <span class="keyword">const</span> vec &cond ) {554 <a name="l00775"></a>00775 _mu = A*cond + mu_const;555 <a name="l00776"></a> 00776 <span class="comment">//R is already assigned;</span>556 <a name="l00777"></a>00777 }557 <a name="l00778"></a>00778 558 <a name="l00779"></a>00779 <span class="keyword">template</span><<span class="keyword">class</span> sq_T>559 <a name="l00780"></a> <a class="code" href="classenorm.html#af50a6102846060bcb23a670bf38117b">00780</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#af50a6102846060bcb23a670bf38117b" title="Return marginal density on the given RV, the remainig rvs are intergrated out.">enorm<sq_T>::marginal</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rvn )<span class="keyword"> const </span>{560 <a name="l00781"></a>00781 ivec irvn = rvn.<a class="code" href="classRV.html#bb724fa4e2d9ed7bfd0993b5975018a4">dataind</a> ( <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> );561 <a name="l00782"></a> 00782562 <a name="l00783"></a>00783 sq_T Rn ( <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>,irvn);563 <a name="l00784"></a>00784 <a class="code" href="classenorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T></a>* tmp = <span class="keyword">new</span> <a class="code" href="classenorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T></a> ( rvn );564 <a name="l00785"></a>00785 tmp-><a class="code" href="classenorm.html#1394a65caa6e00d42e00cc99b12227af" title="Set mean value mu and covariance R.">set_parameters</a> ( <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a> ( irvn ), Rn );565 <a name="l00786"></a>00786 < span class="keywordflow">return</span> tmp;566 <a name="l00787"></a>00787 }567 <a name="l00788"></a>00788 568 <a name="l00789"></a>00789 <span class="keyword">template</span><<span class="keyword">class</span> sq_T>569 <a name="l00790"></a> <a class="code" href="classenorm.html#921024bd6d5a0e65f2af2e39bf38dfca">00790</a> <a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a>* <a class="code" href="classenorm.html#921024bd6d5a0e65f2af2e39bf38dfca" title="Return conditional density on the given RV, the remaining rvs will be in conditioning...">enorm<sq_T>::condition</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &rvn )<span class="keyword"> const </span>{570 <a name="l00791"></a>00791 571 <a name="l00792"></a> 00792 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvc = <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>.<a class="code" href="classRV.html#b9d175c327c21488b1e2fb756a84e149" title="Subtract another variable from the current one.">subt</a> ( rvn );572 <a name="l00793"></a>00793 it_assert_debug ( ( rvc.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>() +rvn.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>() ==<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>() ),<span class="stringliteral">"wrong rvn"</span> );573 <a name="l00794"></a>00794 < span class="comment">//Permutation vector of the new R</span>574 <a name="l00795"></a>00795 i vec irvn = rvn.<a class="code" href="classRV.html#bb724fa4e2d9ed7bfd0993b5975018a4">dataind</a> ( <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> );575 <a name="l00796"></a>00796 ivec irvc = rvc.<a class="code" href="classRV.html#bb724fa4e2d9ed7bfd0993b5975018a4">dataind</a> ( <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> );576 <a name="l00797"></a>00797 ivec perm=<a class="code" href="group__core.html#g33c114e83980d883c5b211c47d5322a4" title="Concat two random variables.">concat</a> ( irvn , irvc);577 <a name="l00798"></a>00798 sq_T Rn ( <a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>,perm);578 <a name="l00799"></a>00799 579 <a name="l00800"></a>00800 <span class="comment">//fixme - could this be done in general for all sq_T?</span>580 <a name="l00801"></a>00801 mat S=Rn.to_mat();581 <a name="l00802"></a>00802 <span class="comment">//fixme </span>582 <a name="l00803"></a>00803 <span class="keywordtype">int</span> n=rvn.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>()-1;583 <a name="l00804"></a>00804 <span class=" keywordtype">int</span> end=<a class="code" href="classenorm.html#4ccc8d8514d644ef1c98d8ab023748a1" title="Covariance matrix in decomposed form.">R</a>.rows()-1;584 <a name="l00805"></a>00805 mat S11 = S.get ( 0,n, 0, n );585 <a name="l00806"></a>00806 mat S12 = S.get ( 0, n , rvn.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>(), end );586 <a name="l00807"></a>00807 mat S 22 = S.get ( rvn.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>(), end, rvn.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>(), end);587 <a name="l00808"></a>00808 588 <a name="l00809"></a>00809 vec mu1 = <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a> ( irvn);589 <a name="l00810"></a>00810 vec mu2 = <a class="code" href="classenorm.html#71fde0d54bba147e00f612577f95ad20" title="mean value">mu</a> ( irvc );590 <a name="l00811"></a>00811 mat A=S12*inv ( S22);591 <a name="l00812"></a>00812 sq_T R_n ( S11 - A *S12.T());592 <a name="l00813"></a>00813 593 <a name="l00814"></a>00814 <a class="code" href="classmlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm<sq_T></a>* tmp=<span class="keyword">new</span> <a class="code" href="classmlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm<sq_T></a> ( rvn,rvc);467 <a name="l00688"></a><a class="code" href="classbdm_1_1enorm.html#e1a48f52351ec3a349bd443b713b1766">00688</a> vec <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T>::sample</a>()<span class="keyword"> const </span>{ 468 <a name="l00689"></a>00689 vec x ( <a class="code" href="classbdm_1_1enorm.html#91a2d4a91364b0144e1523cad4d1135b" title="dimension (redundant from rv.count() for easier coding )">dim</a> ); 469 <a name="l00690"></a>00690 <span class="preprocessor"> #pragma omp critical </span> 470 <a name="l00691"></a>00691 <span class="preprocessor"></span> NorRNG.sample_vector ( <a class="code" href="classbdm_1_1enorm.html#91a2d4a91364b0144e1523cad4d1135b" title="dimension (redundant from rv.count() for easier coding )">dim</a>,x ); 471 <a name="l00692"></a>00692 vec smp = <a class="code" href="classbdm_1_1enorm.html#2d92dde696b2a7a5b10ddef5d22ba2c2" title="Covariance matrix in decomposed form.">R</a>.sqrt_mult ( x ); 472 <a name="l00693"></a>00693 473 <a name="l00694"></a>00694 smp += <a class="code" href="classbdm_1_1enorm.html#c702a194720853570d08b65482f842c7" title="mean value">mu</a>; 474 <a name="l00695"></a>00695 <span class="keywordflow">return</span> smp; 475 <a name="l00696"></a>00696 }; 476 <a name="l00697"></a>00697 477 <a name="l00698"></a>00698 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> 478 <a name="l00699"></a><a class="code" href="classbdm_1_1enorm.html#ebd96125aed74f9504033bb3605849db">00699</a> mat <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T>::sample</a> ( <span class="keywordtype">int</span> N )<span class="keyword"> const </span>{ 479 <a name="l00700"></a>00700 mat X ( <a class="code" href="classbdm_1_1enorm.html#91a2d4a91364b0144e1523cad4d1135b" title="dimension (redundant from rv.count() for easier coding )">dim</a>,N ); 480 <a name="l00701"></a>00701 vec x ( <a class="code" href="classbdm_1_1enorm.html#91a2d4a91364b0144e1523cad4d1135b" title="dimension (redundant from rv.count() for easier coding )">dim</a> ); 481 <a name="l00702"></a>00702 vec pom; 482 <a name="l00703"></a>00703 <span class="keywordtype">int</span> i; 483 <a name="l00704"></a>00704 484 <a name="l00705"></a>00705 <span class="keywordflow">for</span> ( i=0;i<N;i++ ) { 485 <a name="l00706"></a>00706 <span class="preprocessor"> #pragma omp critical </span> 486 <a name="l00707"></a>00707 <span class="preprocessor"></span> NorRNG.sample_vector ( <a class="code" href="classbdm_1_1enorm.html#91a2d4a91364b0144e1523cad4d1135b" title="dimension (redundant from rv.count() for easier coding )">dim</a>,x ); 487 <a name="l00708"></a>00708 pom = <a class="code" href="classbdm_1_1enorm.html#2d92dde696b2a7a5b10ddef5d22ba2c2" title="Covariance matrix in decomposed form.">R</a>.sqrt_mult ( x ); 488 <a name="l00709"></a>00709 pom +=<a class="code" href="classbdm_1_1enorm.html#c702a194720853570d08b65482f842c7" title="mean value">mu</a>; 489 <a name="l00710"></a>00710 X.set_col ( i, pom ); 490 <a name="l00711"></a>00711 } 491 <a name="l00712"></a>00712 492 <a name="l00713"></a>00713 <span class="keywordflow">return</span> X; 493 <a name="l00714"></a>00714 }; 494 <a name="l00715"></a>00715 495 <a name="l00716"></a>00716 <span class="comment">// template<class sq_T></span> 496 <a name="l00717"></a>00717 <span class="comment">// double enorm<sq_T>::eval ( const vec &val ) const {</span> 497 <a name="l00718"></a>00718 <span class="comment">// double pdfl,e;</span> 498 <a name="l00719"></a>00719 <span class="comment">// pdfl = evallog ( val );</span> 499 <a name="l00720"></a>00720 <span class="comment">// e = exp ( pdfl );</span> 500 <a name="l00721"></a>00721 <span class="comment">// return e;</span> 501 <a name="l00722"></a>00722 <span class="comment">// };</span> 502 <a name="l00723"></a>00723 503 <a name="l00724"></a>00724 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> 504 <a name="l00725"></a><a class="code" href="classbdm_1_1enorm.html#e13aeed5b543b2179bacdc4fa2ae47a3">00725</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T>::evallog_nn</a> ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{ 505 <a name="l00726"></a>00726 <span class="comment">// 1.83787706640935 = log(2pi)</span> 506 <a name="l00727"></a>00727 <span class="keywordtype">double</span> tmp=-0.5* ( <a class="code" href="classbdm_1_1enorm.html#2d92dde696b2a7a5b10ddef5d22ba2c2" title="Covariance matrix in decomposed form.">R</a>.invqform ( <a class="code" href="classbdm_1_1enorm.html#c702a194720853570d08b65482f842c7" title="mean value">mu</a>-val ) );<span class="comment">// - lognc();</span> 507 <a name="l00728"></a>00728 <span class="keywordflow">return</span> tmp; 508 <a name="l00729"></a>00729 }; 509 <a name="l00730"></a>00730 510 <a name="l00731"></a>00731 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> 511 <a name="l00732"></a><a class="code" href="classbdm_1_1enorm.html#25785343aff102cc5df1cab08ba16d32">00732</a> <span class="keyword">inline</span> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T>::lognc</a> ()<span class="keyword"> const </span>{ 512 <a name="l00733"></a>00733 <span class="comment">// 1.83787706640935 = log(2pi)</span> 513 <a name="l00734"></a>00734 <span class="keywordtype">double</span> tmp=0.5* ( <a class="code" href="classbdm_1_1enorm.html#2d92dde696b2a7a5b10ddef5d22ba2c2" title="Covariance matrix in decomposed form.">R</a>.cols() * 1.83787706640935 +<a class="code" href="classbdm_1_1enorm.html#2d92dde696b2a7a5b10ddef5d22ba2c2" title="Covariance matrix in decomposed form.">R</a>.logdet() ); 514 <a name="l00735"></a>00735 <span class="keywordflow">return</span> tmp; 515 <a name="l00736"></a>00736 }; 516 <a name="l00737"></a>00737 517 <a name="l00738"></a>00738 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> 518 <a name="l00739"></a><a class="code" href="classbdm_1_1mlnorm.html#64d965df6811ff65b94718c427048f4a">00739</a> <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm<sq_T>::mlnorm</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rv0, <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rvc0 ) :<a class="code" href="classbdm_1_1mEF.html" title="Exponential family model.">mEF</a> ( rv0,rvc0 ),<a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( rv0 ),A ( rv0.count(),rv0.count() ),<a class="code" href="classbdm_1_1enorm.html#766127847e9482aea9226ea157295ea2" title="returns a pointer to the internal mean value. Use with Care!">_mu</a> ( <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.<a class="code" href="classbdm_1_1enorm.html#766127847e9482aea9226ea157295ea2" title="returns a pointer to the internal mean value. Use with Care!">_mu</a>() ) { 519 <a name="l00740"></a>00740 <a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a> =&<a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>; 520 <a name="l00741"></a>00741 } 521 <a name="l00742"></a>00742 522 <a name="l00743"></a>00743 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> 523 <a name="l00744"></a><a class="code" href="classbdm_1_1mlnorm.html#5d18dec3167584338a4775c1d165d96f">00744</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm<sq_T>::set_parameters</a> ( <span class="keyword">const</span> mat &A0, <span class="keyword">const</span> vec &mu0, <span class="keyword">const</span> sq_T &R0 ) { 524 <a name="l00745"></a>00745 <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>.set_parameters ( zeros ( <a class="code" href="classbdm_1_1mpdf.html#9bcfb45435d30983f436d41c298cbb51" title="modeled random variable">rv</a>.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>() ),R0 ); 525 <a name="l00746"></a>00746 A = A0; 526 <a name="l00747"></a>00747 mu_const = mu0; 527 <a name="l00748"></a>00748 } 528 <a name="l00749"></a>00749 529 <a name="l00750"></a>00750 <span class="comment">// template<class sq_T></span> 530 <a name="l00751"></a>00751 <span class="comment">// vec mlnorm<sq_T>::samplecond (const vec &cond, double &lik ) {</span> 531 <a name="l00752"></a>00752 <span class="comment">// this->condition ( cond );</span> 532 <a name="l00753"></a>00753 <span class="comment">// vec smp = epdf.sample();</span> 533 <a name="l00754"></a>00754 <span class="comment">// lik = epdf.eval ( smp );</span> 534 <a name="l00755"></a>00755 <span class="comment">// return smp;</span> 535 <a name="l00756"></a>00756 <span class="comment">// }</span> 536 <a name="l00757"></a>00757 537 <a name="l00758"></a>00758 <span class="comment">// template<class sq_T></span> 538 <a name="l00759"></a>00759 <span class="comment">// mat mlnorm<sq_T>::samplecond (const vec &cond, vec &lik, int n ) {</span> 539 <a name="l00760"></a>00760 <span class="comment">// int i;</span> 540 <a name="l00761"></a>00761 <span class="comment">// int dim = rv.count();</span> 541 <a name="l00762"></a>00762 <span class="comment">// mat Smp ( dim,n );</span> 542 <a name="l00763"></a>00763 <span class="comment">// vec smp ( dim );</span> 543 <a name="l00764"></a>00764 <span class="comment">// this->condition ( cond );</span> 544 <a name="l00765"></a>00765 <span class="comment">//</span> 545 <a name="l00766"></a>00766 <span class="comment">// for ( i=0; i<n; i++ ) {</span> 546 <a name="l00767"></a>00767 <span class="comment">// smp = epdf.sample();</span> 547 <a name="l00768"></a>00768 <span class="comment">// lik ( i ) = epdf.eval ( smp );</span> 548 <a name="l00769"></a>00769 <span class="comment">// Smp.set_col ( i ,smp );</span> 549 <a name="l00770"></a>00770 <span class="comment">// }</span> 550 <a name="l00771"></a>00771 <span class="comment">//</span> 551 <a name="l00772"></a>00772 <span class="comment">// return Smp;</span> 552 <a name="l00773"></a>00773 <span class="comment">// }</span> 553 <a name="l00774"></a>00774 554 <a name="l00775"></a>00775 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> 555 <a name="l00776"></a><a class="code" href="classbdm_1_1mlnorm.html#0dafc0196e7e07fd06dc6716e0e18bc2">00776</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm<sq_T>::condition</a> ( <span class="keyword">const</span> vec &cond ) { 556 <a name="l00777"></a>00777 _mu = A*cond + mu_const; 557 <a name="l00778"></a>00778 <span class="comment">//R is already assigned;</span> 558 <a name="l00779"></a>00779 } 559 <a name="l00780"></a>00780 560 <a name="l00781"></a>00781 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> 561 <a name="l00782"></a><a class="code" href="classbdm_1_1enorm.html#cd02d76e9d4f96bdd3fa6b604e273039">00782</a> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T>::marginal</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rvn )<span class="keyword"> const </span>{ 562 <a name="l00783"></a>00783 ivec irvn = rvn.<a class="code" href="classbdm_1_1RV.html#cbebdb5e0d30101a6eb63550ef701c55">dataind</a> ( <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a> ); 563 <a name="l00784"></a>00784 564 <a name="l00785"></a>00785 sq_T Rn ( <a class="code" href="classbdm_1_1enorm.html#2d92dde696b2a7a5b10ddef5d22ba2c2" title="Covariance matrix in decomposed form.">R</a>,irvn ); 565 <a name="l00786"></a>00786 <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T></a>* tmp = <span class="keyword">new</span> <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T></a> ( rvn ); 566 <a name="l00787"></a>00787 tmp-><a class="code" href="classbdm_1_1enorm.html#b8322f2c11560871dd922c660f4771bb" title="Set mean value mu and covariance R.">set_parameters</a> ( <a class="code" href="classbdm_1_1enorm.html#c702a194720853570d08b65482f842c7" title="mean value">mu</a> ( irvn ), Rn ); 567 <a name="l00788"></a>00788 <span class="keywordflow">return</span> tmp; 568 <a name="l00789"></a>00789 } 569 <a name="l00790"></a>00790 570 <a name="l00791"></a>00791 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> 571 <a name="l00792"></a><a class="code" href="classbdm_1_1enorm.html#baea4d49c657342b58297d68cda16d26">00792</a> <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a>* <a class="code" href="classbdm_1_1enorm.html" title="Gaussian density with positive definite (decomposed) covariance matrix.">enorm<sq_T>::condition</a> ( <span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &rvn )<span class="keyword"> const </span>{ 572 <a name="l00793"></a>00793 573 <a name="l00794"></a>00794 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> rvc = <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#aec44dabdf0a6d90fbae95e1356eda39" title="Subtract another variable from the current one.">subt</a> ( rvn ); 574 <a name="l00795"></a>00795 it_assert_debug ( ( rvc.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>() +rvn.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>() ==<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>() ),<span class="stringliteral">"wrong rvn"</span> ); 575 <a name="l00796"></a>00796 <span class="comment">//Permutation vector of the new R</span> 576 <a name="l00797"></a>00797 ivec irvn = rvn.<a class="code" href="classbdm_1_1RV.html#cbebdb5e0d30101a6eb63550ef701c55">dataind</a> ( <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a> ); 577 <a name="l00798"></a>00798 ivec irvc = rvc.<a class="code" href="classbdm_1_1RV.html#cbebdb5e0d30101a6eb63550ef701c55">dataind</a> ( <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a> ); 578 <a name="l00799"></a>00799 ivec perm=concat ( irvn , irvc ); 579 <a name="l00800"></a>00800 sq_T Rn ( <a class="code" href="classbdm_1_1enorm.html#2d92dde696b2a7a5b10ddef5d22ba2c2" title="Covariance matrix in decomposed form.">R</a>,perm ); 580 <a name="l00801"></a>00801 581 <a name="l00802"></a>00802 <span class="comment">//fixme - could this be done in general for all sq_T?</span> 582 <a name="l00803"></a>00803 mat S=Rn.to_mat(); 583 <a name="l00804"></a>00804 <span class="comment">//fixme</span> 584 <a name="l00805"></a>00805 <span class="keywordtype">int</span> n=rvn.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>()-1; 585 <a name="l00806"></a>00806 <span class="keywordtype">int</span> end=<a class="code" href="classbdm_1_1enorm.html#2d92dde696b2a7a5b10ddef5d22ba2c2" title="Covariance matrix in decomposed form.">R</a>.rows()-1; 586 <a name="l00807"></a>00807 mat S11 = S.get ( 0,n, 0, n ); 587 <a name="l00808"></a>00808 mat S12 = S.get ( 0, n , rvn.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>(), end ); 588 <a name="l00809"></a>00809 mat S22 = S.get ( rvn.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>(), end, rvn.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>(), end ); 589 <a name="l00810"></a>00810 590 <a name="l00811"></a>00811 vec mu1 = <a class="code" href="classbdm_1_1enorm.html#c702a194720853570d08b65482f842c7" title="mean value">mu</a> ( irvn ); 591 <a name="l00812"></a>00812 vec mu2 = <a class="code" href="classbdm_1_1enorm.html#c702a194720853570d08b65482f842c7" title="mean value">mu</a> ( irvc ); 592 <a name="l00813"></a>00813 mat A=S12*inv ( S22 ); 593 <a name="l00814"></a>00814 sq_T R_n ( S11 - A *S12.T() ); 594 594 <a name="l00815"></a>00815 595 <a name="l00816"></a>00816 tmp->set_parameters ( A,mu1-A*mu2,R_n ); 596 <a name="l00817"></a>00817 <span class="keywordflow">return</span> tmp; 597 <a name="l00818"></a>00818 } 598 <a name="l00819"></a>00819 595 <a name="l00816"></a>00816 <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm<sq_T></a>* tmp=<span class="keyword">new</span> <a class="code" href="classbdm_1_1mlnorm.html" title="Normal distributed linear function with linear function of mean value;.">mlnorm<sq_T></a> ( rvn,rvc ); 596 <a name="l00817"></a>00817 597 <a name="l00818"></a>00818 tmp->set_parameters ( A,mu1-A*mu2,R_n ); 598 <a name="l00819"></a>00819 <span class="keywordflow">return</span> tmp; 599 <a name="l00820"></a>00820 } 599 600 <a name="l00821"></a>00821 600 <a name="l00822"></a>00822 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> 601 <a name="l00823"></a>00823 std::ostream &operator<< ( std::ostream &os, mlnorm<sq_T> &ml ) { 602 <a name="l00824"></a>00824 os << <span class="stringliteral">"A:"</span><< ml.A<<endl; 603 <a name="l00825"></a>00825 os << <span class="stringliteral">"mu:"</span><< ml.mu_const<<endl; 604 <a name="l00826"></a>00826 os << <span class="stringliteral">"R:"</span> << ml.epdf._R().to_mat() <<endl; 605 <a name="l00827"></a>00827 <span class="keywordflow">return</span> os; 606 <a name="l00828"></a>00828 }; 607 <a name="l00829"></a>00829 608 <a name="l00830"></a>00830 <span class="preprocessor">#endif //EF_H</span> 601 <a name="l00823"></a>00823 602 <a name="l00824"></a>00824 <span class="keyword">template</span><<span class="keyword">class</span> sq_T> 603 <a name="l00825"></a>00825 std::ostream &operator<< ( std::ostream &os, mlnorm<sq_T> &ml ) { 604 <a name="l00826"></a>00826 os << <span class="stringliteral">"A:"</span><< ml.A<<endl; 605 <a name="l00827"></a>00827 os << <span class="stringliteral">"mu:"</span><< ml.mu_const<<endl; 606 <a name="l00828"></a>00828 os << <span class="stringliteral">"R:"</span> << ml.epdf._R().to_mat() <<endl; 607 <a name="l00829"></a>00829 <span class="keywordflow">return</span> os; 608 <a name="l00830"></a>00830 }; 609 <a name="l00831"></a>00831 610 <a name="l00832"></a>00832 } 611 <a name="l00833"></a>00833 <span class="preprocessor">#endif //EF_H</span> 609 612 </pre></div></div> 610 <hr size="1"><address style="text-align: right;"><small>Generated on T hu Jan 15 10:50:252009 for mixpp by 613 <hr size="1"><address style="text-align: right;"><small>Generated on Tue Jan 27 16:29:53 2009 for mixpp by 611 614 <a href="http://www.doxygen.org/index.html"> 612 615 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>