32 | | <a name="l00039"></a><a class="code" href="classmratio.html#8a3e60f5a532237e4450cd06039a28db">00039</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="classmratio.html#8a3e60f5a532237e4450cd06039a28db" title="Nominator in the form of mpdf.">nom</a>; |
33 | | <a name="l00041"></a><a class="code" href="classmratio.html#d34916f6403460fbcac71902f32aa791">00041</a> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* <a class="code" href="classmratio.html#d34916f6403460fbcac71902f32aa791" title="Denominator in the form of epdf.">den</a>; |
34 | | <a name="l00043"></a><a class="code" href="classmratio.html#f8ea9dd72239dc24b1d83ae034424285">00043</a> <span class="keywordtype">bool</span> <a class="code" href="classmratio.html#f8ea9dd72239dc24b1d83ae034424285" title="flag for destructor">destroynom</a>; |
35 | | <a name="l00045"></a><a class="code" href="classmratio.html#aa50f2cca2b959391f449241ef89012d">00045</a> <a class="code" href="classdatalink__m2e.html" title="data link between">datalink_m2e</a> <a class="code" href="classmratio.html#aa50f2cca2b959391f449241ef89012d" title="datalink between conditional and nom">dl</a>; |
| 32 | <a name="l00039"></a><a class="code" href="classbdm_1_1mratio.html#f31caba90a2aa10fbf7631832404fe54">00039</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_1mratio.html#f31caba90a2aa10fbf7631832404fe54" title="Nominator in the form of mpdf.">nom</a>; |
| 33 | <a name="l00041"></a><a class="code" href="classbdm_1_1mratio.html#7daa5d02d3a3be9d15fd4156d886ed88">00041</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_1mratio.html#7daa5d02d3a3be9d15fd4156d886ed88" title="Denominator in the form of epdf.">den</a>; |
| 34 | <a name="l00043"></a><a class="code" href="classbdm_1_1mratio.html#51bfe6675e724f7fbeaaeacce5a9f9b8">00043</a> <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1mratio.html#51bfe6675e724f7fbeaaeacce5a9f9b8" title="flag for destructor">destroynom</a>; |
| 35 | <a name="l00045"></a><a class="code" href="classbdm_1_1mratio.html#cda5bd23ba60146d69e1f804ff7710c7">00045</a> <a class="code" href="classbdm_1_1datalink__m2e.html" title="data link between">datalink_m2e</a> <a class="code" href="classbdm_1_1mratio.html#cda5bd23ba60146d69e1f804ff7710c7" title="datalink between conditional and nom">dl</a>; |
37 | | <a name="l00049"></a><a class="code" href="classmratio.html#c2452f4fc3046cfe8f2453deb343b3ac">00049</a> <a class="code" href="classmratio.html#c2452f4fc3046cfe8f2453deb343b3ac">mratio</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>* nom0, <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="keywordtype">bool</span> copy=<span class="keyword">false</span> ) :<a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> ( rv,nom0-><a class="code" href="classmpdf.html#71256ffb5fbd08f41d650e606a5bd585" title="access function">_rv</a>().subt ( rv ) ), <a class="code" href="classmratio.html#aa50f2cca2b959391f449241ef89012d" title="datalink between conditional and nom">dl</a> ( rv,<a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab" title="random variable in condition">rvc</a>,nom0-><a class="code" href="classmpdf.html#71256ffb5fbd08f41d650e606a5bd585" title="access function">_rv</a>() ) { |
| 37 | <a name="l00049"></a><a class="code" href="classbdm_1_1mratio.html#0ff56d13f9515d7e5f23b7a4cc5529b4">00049</a> <a class="code" href="classbdm_1_1mratio.html#0ff56d13f9515d7e5f23b7a4cc5529b4">mratio</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>* nom0, <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="keywordtype">bool</span> copy=<span class="keyword">false</span> ) :<a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> ( rv,nom0-><a class="code" href="classbdm_1_1mpdf.html#222d5280e309c5a053ba73841e98c151" title="access function">_rv</a>().subt ( rv ) ), <a class="code" href="classbdm_1_1mratio.html#cda5bd23ba60146d69e1f804ff7710c7" title="datalink between conditional and nom">dl</a> ( rv,<a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a>,nom0-><a class="code" href="classbdm_1_1mpdf.html#222d5280e309c5a053ba73841e98c151" title="access function">_rv</a>() ) { |
47 | | <a name="l00059"></a>00059 it_assert_debug ( <a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab" title="random variable in condition">rvc</a>.<a class="code" href="classRV.html#c114a6f3ff06796cc2f4dacba74291eb" title="Return length (number of entries) of the RV.">length</a>() >0,<span class="stringliteral">"Makes no sense to use this object!"</span> ); |
48 | | <a name="l00060"></a>00060 <a class="code" href="classmratio.html#d34916f6403460fbcac71902f32aa791" title="Denominator in the form of epdf.">den</a> = <a class="code" href="classmratio.html#8a3e60f5a532237e4450cd06039a28db" title="Nominator in the form of mpdf.">nom</a>-><a class="code" href="classepdf.html#38de9f59b65ee06028554f3f74b66025" title="Return marginal density on the given RV, the remainig rvs are intergrated out.">marginal</a> ( <a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab" title="random variable in condition">rvc</a> ); |
| 47 | <a name="l00059"></a>00059 it_assert_debug ( <a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a>.<a class="code" href="classbdm_1_1RV.html#e9ec8c3e756651ff352ab5e3d3acda4b" title="Return length (number of entries) of the RV.">length</a>() >0,<span class="stringliteral">"Makes no sense to use this object!"</span> ); |
| 48 | <a name="l00060"></a>00060 <a class="code" href="classbdm_1_1mratio.html#7daa5d02d3a3be9d15fd4156d886ed88" title="Denominator in the form of epdf.">den</a> = <a class="code" href="classbdm_1_1mratio.html#f31caba90a2aa10fbf7631832404fe54" title="Nominator in the form of mpdf.">nom</a>-><a class="code" href="classbdm_1_1epdf.html#3fb2ece54f720b62ad325e61214fa0a1" title="Return marginal density on the given RV, the remainig rvs are intergrated out.">marginal</a> ( <a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a> ); |
52 | | <a name="l00064"></a>00064 vec nom_val ( <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>() +<a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab" title="random variable in condition">rvc</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>() ); |
53 | | <a name="l00065"></a>00065 <a class="code" href="classmratio.html#aa50f2cca2b959391f449241ef89012d" title="datalink between conditional and nom">dl</a>.<a class="code" href="classdatalink__m2e.html#bbe57e0c65273ff237ca6c98bdf0b09c">fill_val_cond</a> ( nom_val,val,cond ); |
54 | | <a name="l00066"></a>00066 tmp = exp ( <a class="code" href="classmratio.html#8a3e60f5a532237e4450cd06039a28db" title="Nominator in the form of mpdf.">nom</a>-><a class="code" href="classepdf.html#e1996af1da1fa1214270066a96ca113e" title="Compute log-probability of argument val.">evallog</a> ( nom_val ) - <a class="code" href="classmratio.html#d34916f6403460fbcac71902f32aa791" title="Denominator in the form of epdf.">den</a>-><a class="code" href="classepdf.html#e1996af1da1fa1214270066a96ca113e" title="Compute log-probability of argument val.">evallog</a> ( cond ) ); |
| 52 | <a name="l00064"></a>00064 vec nom_val ( <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>() +<a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a>.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>() ); |
| 53 | <a name="l00065"></a>00065 <a class="code" href="classbdm_1_1mratio.html#cda5bd23ba60146d69e1f804ff7710c7" title="datalink between conditional and nom">dl</a>.<a class="code" href="classbdm_1_1datalink__m2e.html#d6803ec2e8c9e844d54d99b6686b0701">fill_val_cond</a> ( nom_val,val,cond ); |
| 54 | <a name="l00066"></a>00066 tmp = exp ( <a class="code" href="classbdm_1_1mratio.html#f31caba90a2aa10fbf7631832404fe54" title="Nominator in the form of mpdf.">nom</a>-><a class="code" href="classbdm_1_1epdf.html#a8e39e2ff5e5cf5471bc159530d3b2d3" title="Compute log-probability of argument val.">evallog</a> ( nom_val ) - <a class="code" href="classbdm_1_1mratio.html#7daa5d02d3a3be9d15fd4156d886ed88" title="Denominator in the form of epdf.">den</a>-><a class="code" href="classbdm_1_1epdf.html#a8e39e2ff5e5cf5471bc159530d3b2d3" title="Compute log-probability of argument val.">evallog</a> ( cond ) ); |
58 | | <a name="l00071"></a><a class="code" href="classmratio.html#41d6d8f4245f67c732299ba7167aacb9">00071</a> <span class="keywordtype">void</span> <a class="code" href="classmratio.html#41d6d8f4245f67c732299ba7167aacb9" title="Object takes ownership of nom and will destroy it.">ownnom</a>() {<a class="code" href="classmratio.html#f8ea9dd72239dc24b1d83ae034424285" title="flag for destructor">destroynom</a>=<span class="keyword">true</span>;} |
59 | | <a name="l00073"></a><a class="code" href="classmratio.html#e62904f18041e73228d8db671e517280">00073</a> <a class="code" href="classmratio.html#e62904f18041e73228d8db671e517280" title="Default destructor.">~mratio</a>() {<span class="keyword">delete</span> <a class="code" href="classmratio.html#d34916f6403460fbcac71902f32aa791" title="Denominator in the form of epdf.">den</a>; <span class="keywordflow">if</span> ( <a class="code" href="classmratio.html#f8ea9dd72239dc24b1d83ae034424285" title="flag for destructor">destroynom</a> ) {<span class="keyword">delete</span> <a class="code" href="classmratio.html#8a3e60f5a532237e4450cd06039a28db" title="Nominator in the form of mpdf.">nom</a>;}} |
| 58 | <a name="l00071"></a><a class="code" href="classbdm_1_1mratio.html#c8b39fea586d4258bb3c881406edaf15">00071</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mratio.html#c8b39fea586d4258bb3c881406edaf15" title="Object takes ownership of nom and will destroy it.">ownnom</a>() {<a class="code" href="classbdm_1_1mratio.html#51bfe6675e724f7fbeaaeacce5a9f9b8" title="flag for destructor">destroynom</a>=<span class="keyword">true</span>;} |
| 59 | <a name="l00073"></a><a class="code" href="classbdm_1_1mratio.html#c0cc0b25dbdc54751466616655454c5c">00073</a> <a class="code" href="classbdm_1_1mratio.html#c0cc0b25dbdc54751466616655454c5c" title="Default destructor.">~mratio</a>() {<span class="keyword">delete</span> <a class="code" href="classbdm_1_1mratio.html#7daa5d02d3a3be9d15fd4156d886ed88" title="Denominator in the form of epdf.">den</a>; <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1mratio.html#51bfe6675e724f7fbeaaeacce5a9f9b8" title="flag for destructor">destroynom</a> ) {<span class="keyword">delete</span> <a class="code" href="classbdm_1_1mratio.html#f31caba90a2aa10fbf7631832404fe54" title="Nominator in the form of mpdf.">nom</a>;}} |
64 | | <a name="l00089"></a><a class="code" href="classemix.html#cdc8f4e2a5e43595ac5450d8a7f9d1ab">00089</a> vec <a class="code" href="classemix.html#cdc8f4e2a5e43595ac5450d8a7f9d1ab" title="weights of the components">w</a>; |
65 | | <a name="l00091"></a><a class="code" href="classemix.html#7155d827417b53fb6aa5cff1459e6eb4">00091</a> Array<epdf*> <a class="code" href="classemix.html#7155d827417b53fb6aa5cff1459e6eb4" title="Component (epdfs).">Coms</a>; |
66 | | <a name="l00093"></a><a class="code" href="classemix.html#7d0d863e6066ee02947914ff06ac34e8">00093</a> <span class="keywordtype">bool</span> <a class="code" href="classemix.html#7d0d863e6066ee02947914ff06ac34e8" title="Flag if owning Coms.">destroyComs</a>; |
| 64 | <a name="l00089"></a><a class="code" href="classbdm_1_1emix.html#bb7270345c76da627cd77ddf020bcf46">00089</a> vec <a class="code" href="classbdm_1_1emix.html#bb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a>; |
| 65 | <a name="l00091"></a><a class="code" href="classbdm_1_1emix.html#e2966a6a44b250e22e55bc9fb6af5c3e">00091</a> Array<epdf*> <a class="code" href="classbdm_1_1emix.html#e2966a6a44b250e22e55bc9fb6af5c3e" title="Component (epdfs).">Coms</a>; |
| 66 | <a name="l00093"></a><a class="code" href="classbdm_1_1emix.html#47189df41a4616c2fed5972f015743f4">00093</a> <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1emix.html#47189df41a4616c2fed5972f015743f4" title="Flag if owning Coms.">destroyComs</a>; |
68 | | <a name="l00096"></a><a class="code" href="classemix.html#62194619791d5f1da88cad01cfc9339d">00096</a> <a class="code" href="classemix.html#62194619791d5f1da88cad01cfc9339d" title="Default constructor.">emix</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 ) {}; |
69 | | <a name="l00099"></a>00099 <span class="keywordtype">void</span> <a class="code" href="classemix.html#d3789d50a3327a6de552db077af5e4c5">set_parameters</a> ( <span class="keyword">const</span> vec &<a class="code" href="classemix.html#cdc8f4e2a5e43595ac5450d8a7f9d1ab" title="weights of the components">w</a>, <span class="keyword">const</span> Array<epdf*> &<a class="code" href="classemix.html#7155d827417b53fb6aa5cff1459e6eb4" title="Component (epdfs).">Coms</a>, <span class="keywordtype">bool</span> copy=<span class="keyword">true</span> ); |
| 68 | <a name="l00096"></a><a class="code" href="classbdm_1_1emix.html#38649cee71ed9d8c32cfe8bb4b78a98b">00096</a> <a class="code" href="classbdm_1_1emix.html#38649cee71ed9d8c32cfe8bb4b78a98b" title="Default constructor.">emix</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 ) {}; |
| 69 | <a name="l00099"></a>00099 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1emix.html#d8c1aefba8302759836b5f26999ce840">set_parameters</a> ( <span class="keyword">const</span> vec &<a class="code" href="classbdm_1_1emix.html#bb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a>, <span class="keyword">const</span> Array<epdf*> &<a class="code" href="classbdm_1_1emix.html#e2966a6a44b250e22e55bc9fb6af5c3e" title="Component (epdfs).">Coms</a>, <span class="keywordtype">bool</span> copy=<span class="keyword">true</span> ); |
71 | | <a name="l00101"></a>00101 vec <a class="code" href="classemix.html#0650601f24e633e0ab09aa1e46c14483" title="Returns a sample, from density .">sample</a>() <span class="keyword">const</span>; |
72 | | <a name="l00102"></a><a class="code" href="classemix.html#b662a51d042b062020460e64bff4e9e8">00102</a> vec <a class="code" href="classemix.html#b662a51d042b062020460e64bff4e9e8" title="return expected value">mean</a>()<span class="keyword"> const </span>{ |
73 | | <a name="l00103"></a>00103 <span class="keywordtype">int</span> i; vec mu = zeros ( <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>() ); |
74 | | <a name="l00104"></a>00104 <span class="keywordflow">for</span> ( i = 0;i < <a class="code" href="classemix.html#cdc8f4e2a5e43595ac5450d8a7f9d1ab" title="weights of the components">w</a>.length();i++ ) {mu += <a class="code" href="classemix.html#cdc8f4e2a5e43595ac5450d8a7f9d1ab" title="weights of the components">w</a> ( i ) * <a class="code" href="classemix.html#7155d827417b53fb6aa5cff1459e6eb4" title="Component (epdfs).">Coms</a> ( i )->mean(); } |
| 71 | <a name="l00101"></a>00101 vec <a class="code" href="classbdm_1_1emix.html#e8839dbbb0d1276a8dbe957a67cfe0dc" title="Returns a sample, from density .">sample</a>() <span class="keyword">const</span>; |
| 72 | <a name="l00102"></a><a class="code" href="classbdm_1_1emix.html#a3a5390bc56e81ef3b0debc0f185fa8a">00102</a> vec <a class="code" href="classbdm_1_1emix.html#a3a5390bc56e81ef3b0debc0f185fa8a" title="return expected value">mean</a>()<span class="keyword"> const </span>{ |
| 73 | <a name="l00103"></a>00103 <span class="keywordtype">int</span> i; vec mu = 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>() ); |
| 74 | <a name="l00104"></a>00104 <span class="keywordflow">for</span> ( i = 0;i < <a class="code" href="classbdm_1_1emix.html#bb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a>.length();i++ ) {mu += <a class="code" href="classbdm_1_1emix.html#bb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a> ( i ) * <a class="code" href="classbdm_1_1emix.html#e2966a6a44b250e22e55bc9fb6af5c3e" title="Component (epdfs).">Coms</a> ( i )->mean(); } |
79 | | <a name="l00109"></a>00109 vec mom2 = zeros(<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>()); |
80 | | <a name="l00110"></a>00110 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0;i < <a class="code" href="classemix.html#cdc8f4e2a5e43595ac5450d8a7f9d1ab" title="weights of the components">w</a>.length();i++ ) {mom2 += <a class="code" href="classemix.html#cdc8f4e2a5e43595ac5450d8a7f9d1ab" title="weights of the components">w</a> ( i ) * pow(<a class="code" href="classemix.html#7155d827417b53fb6aa5cff1459e6eb4" title="Component (epdfs).">Coms</a> ( i )-><a class="code" href="classemix.html#b662a51d042b062020460e64bff4e9e8" title="return expected value">mean</a>(),2); } |
| 79 | <a name="l00109"></a>00109 vec mom2 = 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>()); |
| 80 | <a name="l00110"></a>00110 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0;i < <a class="code" href="classbdm_1_1emix.html#bb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a>.length();i++ ) {mom2 += <a class="code" href="classbdm_1_1emix.html#bb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a> ( i ) * pow(<a class="code" href="classbdm_1_1emix.html#e2966a6a44b250e22e55bc9fb6af5c3e" title="Component (epdfs).">Coms</a> ( i )-><a class="code" href="classbdm_1_1emix.html#a3a5390bc56e81ef3b0debc0f185fa8a" title="return expected value">mean</a>(),2); } |
100 | | <a name="l00131"></a><a class="code" href="classemix.html#44ae2b86c650c2ccb967969c1859d268">00131</a> mat <a class="code" href="classemix.html#44ae2b86c650c2ccb967969c1859d268" title="Auxiliary function that returns pdflog for each component.">evallog_M</a> ( <span class="keyword">const</span> mat &Val )<span class="keyword"> const </span>{ |
101 | | <a name="l00132"></a>00132 mat X ( <a class="code" href="classemix.html#cdc8f4e2a5e43595ac5450d8a7f9d1ab" title="weights of the components">w</a>.length(), Val.cols() ); |
102 | | <a name="l00133"></a>00133 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classemix.html#cdc8f4e2a5e43595ac5450d8a7f9d1ab" title="weights of the components">w</a>.length(); i++ ) { |
103 | | <a name="l00134"></a>00134 X.set_row ( i, <a class="code" href="classemix.html#cdc8f4e2a5e43595ac5450d8a7f9d1ab" title="weights of the components">w</a> ( i ) *exp ( <a class="code" href="classemix.html#7155d827417b53fb6aa5cff1459e6eb4" title="Component (epdfs).">Coms</a> ( i )-><a class="code" href="classemix.html#b3eb9e153e8bfdb6bb47adecc278cbca" title="Compute log-probability of multiple values argument val.">evallog_m</a> ( Val ) ) ); |
| 100 | <a name="l00131"></a><a class="code" href="classbdm_1_1emix.html#e64c1d5a73f541e469792e23d4677af2">00131</a> mat <a class="code" href="classbdm_1_1emix.html#e64c1d5a73f541e469792e23d4677af2" title="Auxiliary function that returns pdflog for each component.">evallog_M</a> ( <span class="keyword">const</span> mat &Val )<span class="keyword"> const </span>{ |
| 101 | <a name="l00132"></a>00132 mat X ( <a class="code" href="classbdm_1_1emix.html#bb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a>.length(), Val.cols() ); |
| 102 | <a name="l00133"></a>00133 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1emix.html#bb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a>.length(); i++ ) { |
| 103 | <a name="l00134"></a>00134 X.set_row ( i, <a class="code" href="classbdm_1_1emix.html#bb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a> ( i ) *exp ( <a class="code" href="classbdm_1_1emix.html#e2966a6a44b250e22e55bc9fb6af5c3e" title="Component (epdfs).">Coms</a> ( i )-><a class="code" href="classbdm_1_1emix.html#23af1986e2afcbc8c7e1c30f610e703b" title="Compute log-probability of multiple values argument val.">evallog_m</a> ( Val ) ) ); |
108 | | <a name="l00139"></a>00139 <a class="code" href="classemix.html" title="Mixture of epdfs.">emix</a>* <a class="code" href="classemix.html#33afde698093d458ce71875f7ee7384a" 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>; |
109 | | <a name="l00140"></a>00140 <a class="code" href="classmratio.html" title="Class representing ratio of two densities which arise e.g. by applying the Bayes...">mratio</a>* <a class="code" href="classemix.html#ebf50c387034f72040c83d38738549b3" title="Return conditional density on the given RV, the remaining rvs will be in conditioning...">condition</a> ( <span class="keyword">const</span> <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ) <span class="keyword">const</span>; <span class="comment">//why not mratio!!</span> |
| 108 | <a name="l00139"></a>00139 <a class="code" href="classbdm_1_1emix.html" title="Mixture of epdfs.">emix</a>* <a class="code" href="classbdm_1_1emix.html#f7165371cc4f7be9292024b9f5431646" 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>; |
| 109 | <a name="l00140"></a>00140 <a class="code" href="classbdm_1_1mratio.html" title="Class representing ratio of two densities which arise e.g. by applying the Bayes...">mratio</a>* <a class="code" href="classbdm_1_1emix.html#fc7772a2972959cf19ba26882feacecf" 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> &<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a> ) <span class="keyword">const</span>; <span class="comment">//why not mratio!!</span> |
112 | | <a name="l00144"></a><a class="code" href="classemix.html#35baf0f62307455cebfbf462144b4dd8">00144</a> <span class="comment"></span> vec& <a class="code" href="classemix.html#35baf0f62307455cebfbf462144b4dd8" title="returns a pointer to the internal mean value. Use with Care!">_w</a>() {<span class="keywordflow">return</span> <a class="code" href="classemix.html#cdc8f4e2a5e43595ac5450d8a7f9d1ab" title="weights of the components">w</a>;} |
113 | | <a name="l00145"></a>00145 <span class="keyword">virtual</span> ~<a class="code" href="classemix.html" title="Mixture of epdfs.">emix</a>() {<span class="keywordflow">if</span> ( <a class="code" href="classemix.html#7d0d863e6066ee02947914ff06ac34e8" title="Flag if owning Coms.">destroyComs</a> ) {<span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classemix.html#7155d827417b53fb6aa5cff1459e6eb4" title="Component (epdfs).">Coms</a>.length();i++ ) {<span class="keyword">delete</span> <a class="code" href="classemix.html#7155d827417b53fb6aa5cff1459e6eb4" title="Component (epdfs).">Coms</a> ( i );}}} |
114 | | <a name="l00147"></a><a class="code" href="classemix.html#4d7baeb2a9e3fca1d8fd32a107df291d">00147</a> <span class="keywordtype">void</span> <a class="code" href="classemix.html#4d7baeb2a9e3fca1d8fd32a107df291d" title="Auxiliary function for taking ownership of the Coms().">ownComs</a>() {<a class="code" href="classemix.html#7d0d863e6066ee02947914ff06ac34e8" title="Flag if owning Coms.">destroyComs</a>=<span class="keyword">true</span>;} |
| 112 | <a name="l00144"></a><a class="code" href="classbdm_1_1emix.html#d9b584cb5b2471a4250fb127757f28be">00144</a> <span class="comment"></span> vec& <a class="code" href="classbdm_1_1emix.html#d9b584cb5b2471a4250fb127757f28be" title="returns a pointer to the internal mean value. Use with Care!">_w</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1emix.html#bb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a>;} |
| 113 | <a name="l00145"></a>00145 <span class="keyword">virtual</span> ~<a class="code" href="classbdm_1_1emix.html" title="Mixture of epdfs.">emix</a>() {<span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1emix.html#47189df41a4616c2fed5972f015743f4" title="Flag if owning Coms.">destroyComs</a> ) {<span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1emix.html#e2966a6a44b250e22e55bc9fb6af5c3e" title="Component (epdfs).">Coms</a>.length();i++ ) {<span class="keyword">delete</span> <a class="code" href="classbdm_1_1emix.html#e2966a6a44b250e22e55bc9fb6af5c3e" title="Component (epdfs).">Coms</a> ( i );}}} |
| 114 | <a name="l00147"></a><a class="code" href="classbdm_1_1emix.html#965fb16669250a3d28bc62cf76276d8e">00147</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1emix.html#965fb16669250a3d28bc62cf76276d8e" title="Auxiliary function for taking ownership of the Coms().">ownComs</a>() {<a class="code" href="classbdm_1_1emix.html#47189df41a4616c2fed5972f015743f4" title="Flag if owning Coms.">destroyComs</a>=<span class="keyword">true</span>;} |
124 | | <a name="l00170"></a><a class="code" href="classmprod.html#419b303581a91ad85200bdcb4b3186f4">00170</a> <a class="code" href="classmprod.html#419b303581a91ad85200bdcb4b3186f4" title="Constructor from list of mFacs,.">mprod</a> ( Array<mpdf*> mFacs ) : <a class="code" href="classcompositepdf.html" title="Abstract composition of pdfs, a base for specific classes this abstract class is...">compositepdf</a> ( mFacs ), <a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> ( <a class="code" href="classcompositepdf.html#635d219fb3e32852400d6f98aa4bdc93" title="find common rv, flag">getrv</a> ( true ),<a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a>() ), <a class="code" href="classmprod.html#0883ce383e8475546df138719918f70e" title="pointers to epdfs - shortcut to mpdfs()._epdf()">epdfs</a> ( <a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a> ), <a class="code" href="classmprod.html#5334777dda3dad9b9fa73e22e8d0f24c" title="Data link for each mpdfs.">dls</a> ( <a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a> ) { |
125 | | <a name="l00171"></a>00171 <a class="code" href="classcompositepdf.html#5a4479785c1fdb2cc351fbea07b899ac" title="common rvc of all mpdfs is written to rvc">setrvc</a> ( <a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>,<a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab" title="random variable in condition">rvc</a> ); |
| 124 | <a name="l00170"></a><a class="code" href="classbdm_1_1mprod.html#680c3e2d95b116c7cfb227c7f2984525">00170</a> <a class="code" href="classbdm_1_1mprod.html#680c3e2d95b116c7cfb227c7f2984525" title="Constructor from list of mFacs,.">mprod</a> ( Array<mpdf*> mFacs ) : <a class="code" href="classbdm_1_1compositepdf.html" title="Abstract composition of pdfs, a base for specific classes this abstract class is...">compositepdf</a> ( mFacs ), <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_1compositepdf.html#c73d39acc4378eee6a63155c3517d3c9" title="find common rv, flag">getrv</a> ( true ),<a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a>() ), <a class="code" href="classbdm_1_1mprod.html#eca722ed1b219727c6c0f8cbc6bf1e51" title="pointers to epdfs - shortcut to mpdfs()._epdf()">epdfs</a> ( <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a> ), <a class="code" href="classbdm_1_1mprod.html#acf679b3b1d48629c5a042d9ac0d973f" title="Data link for each mpdfs.">dls</a> ( <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a> ) { |
| 125 | <a name="l00171"></a>00171 <a class="code" href="classbdm_1_1compositepdf.html#c71fc2c51f49d797e61f479f543c75ce" title="common rvc of all mpdfs is written to rvc">setrvc</a> ( <a class="code" href="classbdm_1_1mpdf.html#9bcfb45435d30983f436d41c298cbb51" title="modeled random variable">rv</a>,<a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a> ); |
127 | | <a name="l00173"></a>00173 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0;i < <a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a>;i++ ) { |
128 | | <a name="l00174"></a>00174 <a class="code" href="classmprod.html#5334777dda3dad9b9fa73e22e8d0f24c" title="Data link for each mpdfs.">dls</a> ( i ) = <span class="keyword">new</span> <a class="code" href="classdatalink__m2m.html">datalink_m2m</a> ( <a class="code" href="classcompositepdf.html#637877061b917a16a0421bb5c4cd480d" title="Elements of composition.">mpdfs</a> ( i )-><a class="code" href="classmpdf.html#71256ffb5fbd08f41d650e606a5bd585" title="access function">_rv</a>(), <a class="code" href="classcompositepdf.html#637877061b917a16a0421bb5c4cd480d" title="Elements of composition.">mpdfs</a> ( i )-><a class="code" href="classmpdf.html#15ef062183b1ccdf794732d5fa0b77cd" title="access function">_rvc</a>(), <a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>, <a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab" title="random variable in condition">rvc</a> ); |
| 127 | <a name="l00173"></a>00173 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0;i < <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a>;i++ ) { |
| 128 | <a name="l00174"></a>00174 <a class="code" href="classbdm_1_1mprod.html#acf679b3b1d48629c5a042d9ac0d973f" title="Data link for each mpdfs.">dls</a> ( i ) = <span class="keyword">new</span> <a class="code" href="classbdm_1_1datalink__m2m.html">datalink_m2m</a> ( <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )-><a class="code" href="classbdm_1_1mpdf.html#222d5280e309c5a053ba73841e98c151" title="access function">_rv</a>(), <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )-><a class="code" href="classbdm_1_1mpdf.html#b3aba7311038bf990d706a64cab60cf8" title="access function">_rvc</a>(), <a class="code" href="classbdm_1_1mpdf.html#9bcfb45435d30983f436d41c298cbb51" title="modeled random variable">rv</a>, <a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a> ); |
145 | | <a name="l00191"></a>00191 res *= <a class="code" href="classcompositepdf.html#637877061b917a16a0421bb5c4cd480d" title="Elements of composition.">mpdfs</a> ( i )->evallogcond ( |
146 | | <a name="l00192"></a>00192 <a class="code" href="classmprod.html#5334777dda3dad9b9fa73e22e8d0f24c" title="Data link for each mpdfs.">dls</a> ( i )->get_val ( val ), |
147 | | <a name="l00193"></a>00193 <a class="code" href="classmprod.html#5334777dda3dad9b9fa73e22e8d0f24c" title="Data link for each mpdfs.">dls</a> ( i )->get_cond ( val, cond ) |
| 145 | <a name="l00191"></a>00191 res *= <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )->evallogcond ( |
| 146 | <a name="l00192"></a>00192 <a class="code" href="classbdm_1_1mprod.html#acf679b3b1d48629c5a042d9ac0d973f" title="Data link for each mpdfs.">dls</a> ( i )->get_val ( val ), |
| 147 | <a name="l00193"></a>00193 <a class="code" href="classbdm_1_1mprod.html#acf679b3b1d48629c5a042d9ac0d973f" title="Data link for each mpdfs.">dls</a> ( i )->get_cond ( val, cond ) |
152 | | <a name="l00198"></a><a class="code" href="classmprod.html#a48887eb8738a9e5550bfc38eb8e9d68">00198</a> vec <a class="code" href="classmprod.html#a48887eb8738a9e5550bfc38eb8e9d68" title="Returns a sample from the density conditioned on cond, .">samplecond</a> ( <span class="keyword">const</span> vec &cond, <span class="keywordtype">double</span> &ll ) { |
153 | | <a name="l00200"></a>00200 vec smp= std::numeric_limits<double>::infinity() * ones ( <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>() ); |
| 152 | <a name="l00198"></a><a class="code" href="classbdm_1_1mprod.html#1a37c2aaba8bde7fce5351c39b6e1168">00198</a> vec <a class="code" href="classbdm_1_1mprod.html#1a37c2aaba8bde7fce5351c39b6e1168" title="Returns a sample from the density conditioned on cond, .">samplecond</a> ( <span class="keyword">const</span> vec &cond, <span class="keywordtype">double</span> &ll ) { |
| 153 | <a name="l00200"></a>00200 vec smp= std::numeric_limits<double>::infinity() * ones ( <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>() ); |
157 | | <a name="l00204"></a>00204 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = ( <a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a> - 1 );i >= 0;i-- ) { |
158 | | <a name="l00205"></a>00205 <span class="keywordflow">if</span> ( <a class="code" href="classcompositepdf.html#637877061b917a16a0421bb5c4cd480d" title="Elements of composition.">mpdfs</a> ( i )->_rvc().count() ) { |
159 | | <a name="l00206"></a>00206 <a class="code" href="classcompositepdf.html#637877061b917a16a0421bb5c4cd480d" title="Elements of composition.">mpdfs</a> ( i )->condition ( <a class="code" href="classmprod.html#5334777dda3dad9b9fa73e22e8d0f24c" title="Data link for each mpdfs.">dls</a> ( i )->get_cond ( smp ,cond ) ); <span class="comment">// smp is val here!!</span> |
| 157 | <a name="l00204"></a>00204 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = ( <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a> - 1 );i >= 0;i-- ) { |
| 158 | <a name="l00205"></a>00205 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )->_rvc().count() ) { |
| 159 | <a name="l00206"></a>00206 <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )->condition ( <a class="code" href="classbdm_1_1mprod.html#acf679b3b1d48629c5a042d9ac0d973f" title="Data link for each mpdfs.">dls</a> ( i )->get_cond ( smp ,cond ) ); <span class="comment">// smp is val here!!</span> |
169 | | <a name="l00216"></a>00216 mat <a class="code" href="classmprod.html#a48887eb8738a9e5550bfc38eb8e9d68" title="Returns a sample from the density conditioned on cond, .">samplecond</a> ( <span class="keyword">const</span> vec &cond, vec &ll, <span class="keywordtype">int</span> N ) { |
170 | | <a name="l00217"></a>00217 mat Smp ( <a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>(),N ); |
171 | | <a name="l00218"></a>00218 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<N;i++ ) {Smp.set_col ( i,<a class="code" href="classmprod.html#a48887eb8738a9e5550bfc38eb8e9d68" title="Returns a sample from the density conditioned on cond, .">samplecond</a> ( cond,ll ( i ) ) );} |
| 169 | <a name="l00216"></a>00216 mat <a class="code" href="classbdm_1_1mprod.html#1a37c2aaba8bde7fce5351c39b6e1168" title="Returns a sample from the density conditioned on cond, .">samplecond</a> ( <span class="keyword">const</span> vec &cond, vec &ll, <span class="keywordtype">int</span> N ) { |
| 170 | <a name="l00217"></a>00217 mat Smp ( <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>(),N ); |
| 171 | <a name="l00218"></a>00218 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<N;i++ ) {Smp.set_col ( i,<a class="code" href="classbdm_1_1mprod.html#1a37c2aaba8bde7fce5351c39b6e1168" title="Returns a sample from the density conditioned on cond, .">samplecond</a> ( cond,ll ( i ) ) );} |
183 | | <a name="l00233"></a>00233 <a class="code" href="classeprod.html" title="Product of independent epdfs. For dependent pdfs, use mprod.">eprod</a> ( <span class="keyword">const</span> Array<const epdf*> epdfs0 ) : <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a>() ),<a class="code" href="classeprod.html#63fc0db078542bce1c5dff94f9c3a357" title="Components (epdfs).">epdfs</a> ( epdfs0 ),<a class="code" href="classeprod.html#852a8e1b5b52a992f56cd2ab6c0b4a29" title="Array of indeces.">dls</a> ( <a class="code" href="classeprod.html#63fc0db078542bce1c5dff94f9c3a357" title="Components (epdfs).">epdfs</a>.length() ) { |
| 183 | <a name="l00233"></a>00233 <a class="code" href="classbdm_1_1eprod.html" title="Product of independent epdfs. For dependent pdfs, use mprod.">eprod</a> ( <span class="keyword">const</span> Array<const epdf*> epdfs0 ) : <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_1RV.html" title="Class representing variables, most often random variables.">RV</a>() ),<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( epdfs0 ),<a class="code" href="classbdm_1_1eprod.html#a42b1820428ac06eecb6d938cb6896ff" title="Array of indeces.">dls</a> ( <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length() ) { |
185 | | <a name="l00235"></a>00235 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classeprod.html#63fc0db078542bce1c5dff94f9c3a357" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
186 | | <a name="l00236"></a>00236 independent=<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>.<a class="code" href="classRV.html#935790526b630dec4ffefa9ec0c2b6fb" title="Add (concat) another variable to the current one,.">add</a> ( <a class="code" href="classeprod.html#63fc0db078542bce1c5dff94f9c3a357" title="Components (epdfs).">epdfs</a> ( i )-><a class="code" href="classepdf.html#ca0d32aabb4cbba347e0c37fe8607562" title="access function, possibly dangerous!">_rv</a>() ); |
| 185 | <a name="l00235"></a>00235 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
| 186 | <a name="l00236"></a>00236 independent=<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#87841b5ee43997b79789c0c22047e224" title="Add (concat) another variable to the current one,.">add</a> ( <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )-><a class="code" href="classbdm_1_1epdf.html#a4ab378d5e004c3ff3e2d4e64f7bba21" title="access function, possibly dangerous!">_rv</a>() ); |
189 | | <a name="l00239"></a>00239 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classeprod.html#63fc0db078542bce1c5dff94f9c3a357" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
190 | | <a name="l00240"></a>00240 <a class="code" href="classeprod.html#852a8e1b5b52a992f56cd2ab6c0b4a29" title="Array of indeces.">dls</a> ( i ) = <span class="keyword">new</span> <a class="code" href="classdatalink__e2e.html">datalink_e2e</a> ( <a class="code" href="classeprod.html#63fc0db078542bce1c5dff94f9c3a357" title="Components (epdfs).">epdfs</a> ( i )-><a class="code" href="classepdf.html#ca0d32aabb4cbba347e0c37fe8607562" title="access function, possibly dangerous!">_rv</a>() , <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ); |
| 189 | <a name="l00239"></a>00239 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
| 190 | <a name="l00240"></a>00240 <a class="code" href="classbdm_1_1eprod.html#a42b1820428ac06eecb6d938cb6896ff" title="Array of indeces.">dls</a> ( i ) = <span class="keyword">new</span> <a class="code" href="classbdm_1_1datalink__e2e.html">datalink_e2e</a> ( <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )-><a class="code" href="classbdm_1_1epdf.html#a4ab378d5e004c3ff3e2d4e64f7bba21" title="access function, possibly dangerous!">_rv</a>() , <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a> ); |
194 | | <a name="l00244"></a><a class="code" href="classeprod.html#5752dd999e1f4638f9558b0cc35b64f7">00244</a> vec <a class="code" href="classeprod.html#5752dd999e1f4638f9558b0cc35b64f7" title="return expected value">mean</a>()<span class="keyword"> const </span>{ |
195 | | <a name="l00245"></a>00245 vec tmp ( <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>() ); |
196 | | <a name="l00246"></a>00246 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classeprod.html#63fc0db078542bce1c5dff94f9c3a357" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
197 | | <a name="l00247"></a>00247 vec pom = <a class="code" href="classeprod.html#63fc0db078542bce1c5dff94f9c3a357" title="Components (epdfs).">epdfs</a> ( i )->mean(); |
198 | | <a name="l00248"></a>00248 <a class="code" href="classeprod.html#852a8e1b5b52a992f56cd2ab6c0b4a29" title="Array of indeces.">dls</a> ( i )->fill_val ( tmp, pom ); |
| 194 | <a name="l00244"></a><a class="code" href="classbdm_1_1eprod.html#1d494351e7e385ad3382387c96915d24">00244</a> vec <a class="code" href="classbdm_1_1eprod.html#1d494351e7e385ad3382387c96915d24" title="return expected value">mean</a>()<span class="keyword"> const </span>{ |
| 195 | <a name="l00245"></a>00245 vec tmp ( <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>() ); |
| 196 | <a name="l00246"></a>00246 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
| 197 | <a name="l00247"></a>00247 vec pom = <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->mean(); |
| 198 | <a name="l00248"></a>00248 <a class="code" href="classbdm_1_1eprod.html#a42b1820428ac06eecb6d938cb6896ff" title="Array of indeces.">dls</a> ( i )->fill_val ( tmp, pom ); |
202 | | <a name="l00252"></a><a class="code" href="classeprod.html#71d37aa4676dc41bb4ff6ceb4ccdc594">00252</a> vec <a class="code" href="classeprod.html#71d37aa4676dc41bb4ff6ceb4ccdc594" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{ |
203 | | <a name="l00253"></a>00253 vec tmp ( <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="comment">//second moment</span> |
204 | | <a name="l00254"></a>00254 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classeprod.html#63fc0db078542bce1c5dff94f9c3a357" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
205 | | <a name="l00255"></a>00255 vec pom = <a class="code" href="classeprod.html#63fc0db078542bce1c5dff94f9c3a357" title="Components (epdfs).">epdfs</a> ( i )->mean(); |
206 | | <a name="l00256"></a>00256 <a class="code" href="classeprod.html#852a8e1b5b52a992f56cd2ab6c0b4a29" title="Array of indeces.">dls</a> ( i )->fill_val ( tmp, pow(pom,2) ); |
| 202 | <a name="l00252"></a><a class="code" href="classbdm_1_1eprod.html#cc53a151f5ac5dfba68d425acc3a5615">00252</a> vec <a class="code" href="classbdm_1_1eprod.html#cc53a151f5ac5dfba68d425acc3a5615" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{ |
| 203 | <a name="l00253"></a>00253 vec tmp ( <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="comment">//second moment</span> |
| 204 | <a name="l00254"></a>00254 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
| 205 | <a name="l00255"></a>00255 vec pom = <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->mean(); |
| 206 | <a name="l00256"></a>00256 <a class="code" href="classbdm_1_1eprod.html#a42b1820428ac06eecb6d938cb6896ff" title="Array of indeces.">dls</a> ( i )->fill_val ( tmp, pow(pom,2) ); |
210 | | <a name="l00260"></a><a class="code" href="classeprod.html#94a5b7c44056cf7f4e688d53ba6295b4">00260</a> vec <a class="code" href="classeprod.html#94a5b7c44056cf7f4e688d53ba6295b4" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{ |
211 | | <a name="l00261"></a>00261 vec tmp ( <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>() ); |
212 | | <a name="l00262"></a>00262 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classeprod.html#63fc0db078542bce1c5dff94f9c3a357" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
213 | | <a name="l00263"></a>00263 vec pom = <a class="code" href="classeprod.html#63fc0db078542bce1c5dff94f9c3a357" title="Components (epdfs).">epdfs</a> ( i )->sample(); |
214 | | <a name="l00264"></a>00264 <a class="code" href="classeprod.html#852a8e1b5b52a992f56cd2ab6c0b4a29" title="Array of indeces.">dls</a> ( i )->fill_val ( tmp, pom ); |
| 210 | <a name="l00260"></a><a class="code" href="classbdm_1_1eprod.html#af48debea25d3473bcb71b6a77fac741">00260</a> vec <a class="code" href="classbdm_1_1eprod.html#af48debea25d3473bcb71b6a77fac741" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{ |
| 211 | <a name="l00261"></a>00261 vec tmp ( <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>() ); |
| 212 | <a name="l00262"></a>00262 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
| 213 | <a name="l00263"></a>00263 vec pom = <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->sample(); |
| 214 | <a name="l00264"></a>00264 <a class="code" href="classbdm_1_1eprod.html#a42b1820428ac06eecb6d938cb6896ff" title="Array of indeces.">dls</a> ( i )->fill_val ( tmp, pom ); |
237 | | <a name="l00295"></a><a class="code" href="classmmix.html#6769a962f1f4d0ecc5b903b5f7d26ad3">00295</a> <a class="code" href="classmmix.html#6769a962f1f4d0ecc5b903b5f7d26ad3" title="Default constructor.">mmix</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classmpdf.html#f6687c07ff07d47812dd565368ca59eb" title="modeled random variable">rv</a>, <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classmpdf.html#acb7dda792b3cd5576f39fa3129abbab" title="random variable in condition">rvc</a> ) : <a class="code" href="classmpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> ( rv, rvc ), <a class="code" href="classmmix.html#507a5e6df53e6e9a6a330f1271cf0914" title="Internal epdf.">Epdf</a> ( rv ) {<a class="code" href="classmpdf.html#7aa894208a32f3487827df6d5054424c" title="pointer to internal epdf">ep</a> = &<a class="code" href="classmmix.html#507a5e6df53e6e9a6a330f1271cf0914" title="Internal epdf.">Epdf</a>;}; |
238 | | <a name="l00297"></a><a class="code" href="classmmix.html#e7681490a5c5b2d0a43f4e5842e10a9d">00297</a> <span class="keywordtype">void</span> <a class="code" href="classmmix.html#e7681490a5c5b2d0a43f4e5842e10a9d" title="Set weights w and components R.">set_parameters</a> ( <span class="keyword">const</span> vec &w, <span class="keyword">const</span> Array<mpdf*> &<a class="code" href="classmmix.html#460632c7a0afd41b7840902181a7d85f" title="Component (epdfs).">Coms</a> ) { |
| 237 | <a name="l00295"></a><a class="code" href="classbdm_1_1mmix.html#580a05ae61b179de3fccfcb60f11efd9">00295</a> <a class="code" href="classbdm_1_1mmix.html#580a05ae61b179de3fccfcb60f11efd9" title="Default constructor.">mmix</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_1mpdf.html#9bcfb45435d30983f436d41c298cbb51" title="modeled random variable">rv</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_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a> ) : <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> ( rv, rvc ), <a class="code" href="classbdm_1_1mmix.html#0c4dd6ca6556ddd8ae3c5f3257c04b60" title="Internal epdf.">Epdf</a> ( rv ) {<a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a> = &<a class="code" href="classbdm_1_1mmix.html#0c4dd6ca6556ddd8ae3c5f3257c04b60" title="Internal epdf.">Epdf</a>;}; |
| 238 | <a name="l00297"></a><a class="code" href="classbdm_1_1mmix.html#ad8d9df36cb0ca093a29af0eca12da32">00297</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mmix.html#ad8d9df36cb0ca093a29af0eca12da32" title="Set weights w and components R.">set_parameters</a> ( <span class="keyword">const</span> vec &w, <span class="keyword">const</span> Array<mpdf*> &<a class="code" href="classbdm_1_1mmix.html#52e0bcc70d5b26babeba08097579da9c" title="Component (epdfs).">Coms</a> ) { |
247 | | <a name="l00306"></a><a class="code" href="classmmix.html#1a66629ec5c2b6f4740606cf737f0193">00306</a> <span class="keywordtype">void</span> <a class="code" href="classmmix.html#1a66629ec5c2b6f4740606cf737f0193" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a> ( <span class="keyword">const</span> vec &cond ) { |
248 | | <a name="l00307"></a>00307 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0;i < <a class="code" href="classmmix.html#460632c7a0afd41b7840902181a7d85f" title="Component (epdfs).">Coms</a>.length();i++ ) {<a class="code" href="classmmix.html#460632c7a0afd41b7840902181a7d85f" title="Component (epdfs).">Coms</a> ( i )->condition ( cond );} |
| 247 | <a name="l00306"></a><a class="code" href="classbdm_1_1mmix.html#0a5241ecc9911e816b00b92d5c7c8df0">00306</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mmix.html#0a5241ecc9911e816b00b92d5c7c8df0" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a> ( <span class="keyword">const</span> vec &cond ) { |
| 248 | <a name="l00307"></a>00307 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0;i < <a class="code" href="classbdm_1_1mmix.html#52e0bcc70d5b26babeba08097579da9c" title="Component (epdfs).">Coms</a>.length();i++ ) {<a class="code" href="classbdm_1_1mmix.html#52e0bcc70d5b26babeba08097579da9c" title="Component (epdfs).">Coms</a> ( i )->condition ( cond );} |