Changeset 651 for library/doc/html/emix_8h_source.html
- Timestamp:
- 10/12/09 13:49:39 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/doc/html/emix_8h_source.html
r641 r651 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> 5 3 <title>mixpp: emix.h Source File</title> 6 <link href="tabs.css" rel="stylesheet" type="text/css"/> 7 <link href="doxygen.css" rel="stylesheet" type="text/css"/> 8 </head> 9 <body> 10 <!-- Generated by Doxygen 1.6.1 --> 4 <link href="tabs.css" rel="stylesheet" type="text/css"> 5 <link href="doxygen.css" rel="stylesheet" type="text/css"> 6 </head><body> 7 <!-- Generated by Doxygen 1.5.9 --> 11 8 <script type="text/javascript"> 12 9 <!-- … … 71 68 <a name="l00016"></a>00016 <span class="preprocessor">#define LOG2 0.69314718055995</span> 72 69 <a name="l00017"></a>00017 <span class="preprocessor"></span> 73 <a name="l00018"></a>00018 <span class="preprocessor">#include "../shared_ptr.h"</span>74 <a name="l00019"></a>00019 <span class="preprocessor">#include "<a class="code" href="exp__family_8h.html" title="Probability distributions for Exponential Family models.">exp_family.h</a>"</span>70 <a name="l00018"></a>00018 <span class="preprocessor">#include "../shared_ptr.h"</span> 71 <a name="l00019"></a>00019 <span class="preprocessor">#include "<a class="code" href="exp__family_8h.html" title="Probability distributions for Exponential Family models.">exp_family.h</a>"</span> 75 72 <a name="l00020"></a>00020 76 73 <a name="l00021"></a>00021 <span class="keyword">namespace </span>bdm { … … 80 77 <a name="l00037"></a><a class="code" href="classbdm_1_1mratio.html">00037</a> <span class="keyword">class </span><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>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling , where is random variable, rv, and...">mpdf</a> { 81 78 <a name="l00038"></a>00038 <span class="keyword">protected</span>: 82 <a name="l00040"></a><a class="code" href="classbdm_1_1mratio.html# af31caba90a2aa10fbf7631832404fe54">00040</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#af31caba90a2aa10fbf7631832404fe54" title="Nominator in the form of mpdf.">nom</a>;79 <a name="l00040"></a><a class="code" href="classbdm_1_1mratio.html#f31caba90a2aa10fbf7631832404fe54">00040</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>; 83 80 <a name="l00041"></a>00041 84 <a name="l00043"></a><a class="code" href="classbdm_1_1mratio.html# a873598797f36eddab44e342e14563fcb">00043</a> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<epdf></a> <a class="code" href="classbdm_1_1mratio.html#a873598797f36eddab44e342e14563fcb" title="Denominator in the form of epdf.">den</a>;81 <a name="l00043"></a><a class="code" href="classbdm_1_1mratio.html#873598797f36eddab44e342e14563fcb">00043</a> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<epdf></a> <a class="code" href="classbdm_1_1mratio.html#873598797f36eddab44e342e14563fcb" title="Denominator in the form of epdf.">den</a>; 85 82 <a name="l00044"></a>00044 86 <a name="l00046"></a><a class="code" href="classbdm_1_1mratio.html# a51bfe6675e724f7fbeaaeacce5a9f9b8">00046</a> <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1mratio.html#a51bfe6675e724f7fbeaaeacce5a9f9b8" title="flag for destructor">destroynom</a>;87 <a name="l00048"></a><a class="code" href="classbdm_1_1mratio.html# acda5bd23ba60146d69e1f804ff7710c7">00048</a> <a class="code" href="classbdm_1_1datalink__m2e.html" title="Data link with a condition.">datalink_m2e</a> <a class="code" href="classbdm_1_1mratio.html#acda5bd23ba60146d69e1f804ff7710c7" title="datalink between conditional and nom">dl</a>;88 <a name="l00050"></a><a class="code" href="classbdm_1_1mratio.html# a7a676422bc6cc426ffa6fddf52672409">00050</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#a7a676422bc6cc426ffa6fddf52672409" title="dummy epdf that stores only rv and dim">iepdf</a>;83 <a name="l00046"></a><a class="code" href="classbdm_1_1mratio.html#51bfe6675e724f7fbeaaeacce5a9f9b8">00046</a> <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1mratio.html#51bfe6675e724f7fbeaaeacce5a9f9b8" title="flag for destructor">destroynom</a>; 84 <a name="l00048"></a><a class="code" href="classbdm_1_1mratio.html#cda5bd23ba60146d69e1f804ff7710c7">00048</a> <a class="code" href="classbdm_1_1datalink__m2e.html" title="Data link with a condition.">datalink_m2e</a> <a class="code" href="classbdm_1_1mratio.html#cda5bd23ba60146d69e1f804ff7710c7" title="datalink between conditional and nom">dl</a>; 85 <a name="l00050"></a><a class="code" href="classbdm_1_1mratio.html#7a676422bc6cc426ffa6fddf52672409">00050</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#7a676422bc6cc426ffa6fddf52672409" title="dummy epdf that stores only rv and dim">iepdf</a>; 89 86 <a name="l00051"></a>00051 <span class="keyword">public</span>: 90 <a name="l00054"></a><a class="code" href="classbdm_1_1mratio.html# a0ff56d13f9515d7e5f23b7a4cc5529b4">00054</a> <a class="code" href="classbdm_1_1mratio.html#a0ff56d13f9515d7e5f23b7a4cc5529b4">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> &rv, <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 , where is random variable, rv, and...">mpdf</a> ( ), <a class="code" href="classbdm_1_1mratio.html#acda5bd23ba60146d69e1f804ff7710c7" title="datalink between conditional and nom">dl</a> ( ),<a class="code" href="classbdm_1_1mratio.html#a7a676422bc6cc426ffa6fddf52672409" title="dummy epdf that stores only rv and dim">iepdf</a>() {87 <a name="l00054"></a><a class="code" href="classbdm_1_1mratio.html#0ff56d13f9515d7e5f23b7a4cc5529b4">00054</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> &rv, <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 , where is random variable, rv, and...">mpdf</a> ( ), <a class="code" href="classbdm_1_1mratio.html#cda5bd23ba60146d69e1f804ff7710c7" title="datalink between conditional and nom">dl</a> ( ),<a class="code" href="classbdm_1_1mratio.html#7a676422bc6cc426ffa6fddf52672409" title="dummy epdf that stores only rv and dim">iepdf</a>() { 91 88 <a name="l00055"></a>00055 <span class="comment">// adjust rv and rvc</span> 92 <a name="l00056"></a>00056 <a class="code" href="classbdm_1_1mpdf.html# a5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a> = nom0-><a class="code" href="classbdm_1_1epdf.html#aa4ab378d5e004c3ff3e2d4e64f7bba21" title="Return name (fails when isnamed is false).">_rv</a>().<a class="code" href="classbdm_1_1RV.html#aaec44dabdf0a6d90fbae95e1356eda39" title="Subtract another variable from the current one.">subt</a> ( rv );93 <a name="l00057"></a>00057 <a class="code" href="classbdm_1_1mpdf.html# a7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a> = <a class="code" href="classbdm_1_1mpdf.html#a5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a>.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>();94 <a name="l00058"></a>00058 <a class="code" href="classbdm_1_1mpdf.html# a147afacb393324bb3f9a7a89e33f835e" title="set internal pointer ep to point to given iepdf ">set_ep</a> ( <a class="code" href="classbdm_1_1mratio.html#a7a676422bc6cc426ffa6fddf52672409" title="dummy epdf that stores only rv and dim">iepdf</a> );95 <a name="l00059"></a>00059 <a class="code" href="classbdm_1_1mratio.html# a7a676422bc6cc426ffa6fddf52672409" title="dummy epdf that stores only rv and dim">iepdf</a>.set_parameters ( rv.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>() );96 <a name="l00060"></a>00060 <a class="code" href="classbdm_1_1mratio.html# a7a676422bc6cc426ffa6fddf52672409" title="dummy epdf that stores only rv and dim">iepdf</a>.<a class="code" href="classbdm_1_1epdf.html#af423e28448dbb69ef4905295ec8de8ff" title="Name its rv.">set_rv</a> ( rv );89 <a name="l00056"></a>00056 <a class="code" href="classbdm_1_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a> = nom0-><a class="code" href="classbdm_1_1epdf.html#a4ab378d5e004c3ff3e2d4e64f7bba21" title="Return name (fails when isnamed is false).">_rv</a>().<a class="code" href="classbdm_1_1RV.html#aec44dabdf0a6d90fbae95e1356eda39" title="Subtract another variable from the current one.">subt</a> ( rv ); 90 <a name="l00057"></a>00057 <a class="code" href="classbdm_1_1mpdf.html#7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</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#de30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>(); 91 <a name="l00058"></a>00058 <a class="code" href="classbdm_1_1mpdf.html#147afacb393324bb3f9a7a89e33f835e" title="set internal pointer ep to point to given iepdf ">set_ep</a> ( <a class="code" href="classbdm_1_1mratio.html#7a676422bc6cc426ffa6fddf52672409" title="dummy epdf that stores only rv and dim">iepdf</a> ); 92 <a name="l00059"></a>00059 <a class="code" href="classbdm_1_1mratio.html#7a676422bc6cc426ffa6fddf52672409" title="dummy epdf that stores only rv and dim">iepdf</a>.set_parameters ( rv.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>() ); 93 <a name="l00060"></a>00060 <a class="code" href="classbdm_1_1mratio.html#7a676422bc6cc426ffa6fddf52672409" title="dummy epdf that stores only rv and dim">iepdf</a>.<a class="code" href="classbdm_1_1epdf.html#f423e28448dbb69ef4905295ec8de8ff" title="Name its rv.">set_rv</a> ( rv ); 97 94 <a name="l00061"></a>00061 98 95 <a name="l00062"></a>00062 <span class="comment">//prepare data structures</span> 99 96 <a name="l00063"></a>00063 <span class="keywordflow">if</span> ( copy ) { 100 <a name="l00064"></a>00064 <a class="code" href="bdmerror_8h.html# a7c43f3a72afe68ab0c85663a1bb3521a" title="Unconditionally throw std::runtime_error.">bdm_error</a> ( <span class="stringliteral">"todo"</span> );97 <a name="l00064"></a>00064 <a class="code" href="bdmerror_8h.html#7c43f3a72afe68ab0c85663a1bb3521a" title="Unconditionally throw std::runtime_error.">bdm_error</a> ( <span class="stringliteral">"todo"</span> ); 101 98 <a name="l00065"></a>00065 <span class="comment">// destroynom = true;</span> 102 99 <a name="l00066"></a>00066 } <span class="keywordflow">else</span> { 103 <a name="l00067"></a>00067 <a class="code" href="classbdm_1_1mratio.html# af31caba90a2aa10fbf7631832404fe54" title="Nominator in the form of mpdf.">nom</a> = nom0;104 <a name="l00068"></a>00068 <a class="code" href="classbdm_1_1mratio.html# a51bfe6675e724f7fbeaaeacce5a9f9b8" title="flag for destructor">destroynom</a> = <span class="keyword">false</span>;100 <a name="l00067"></a>00067 <a class="code" href="classbdm_1_1mratio.html#f31caba90a2aa10fbf7631832404fe54" title="Nominator in the form of mpdf.">nom</a> = nom0; 101 <a name="l00068"></a>00068 <a class="code" href="classbdm_1_1mratio.html#51bfe6675e724f7fbeaaeacce5a9f9b8" title="flag for destructor">destroynom</a> = <span class="keyword">false</span>; 105 102 <a name="l00069"></a>00069 } 106 <a name="l00070"></a>00070 <a class="code" href="bdmerror_8h.html# a89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</a> ( <a class="code" href="classbdm_1_1mpdf.html#a5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a>.<a class="code" href="classbdm_1_1RV.html#ae9ec8c3e756651ff352ab5e3d3acda4b" title="Number of named parts.">length</a>() > 0, <span class="stringliteral">"Makes no sense to use this object!"</span> );103 <a name="l00070"></a>00070 <a class="code" href="bdmerror_8h.html#89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</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#e9ec8c3e756651ff352ab5e3d3acda4b" title="Number of named parts.">length</a>() > 0, <span class="stringliteral">"Makes no sense to use this object!"</span> ); 107 104 <a name="l00071"></a>00071 108 105 <a name="l00072"></a>00072 <span class="comment">// build denominator</span> 109 <a name="l00073"></a>00073 <a class="code" href="classbdm_1_1mratio.html# a873598797f36eddab44e342e14563fcb" title="Denominator in the form of epdf.">den</a> = <a class="code" href="classbdm_1_1mratio.html#af31caba90a2aa10fbf7631832404fe54" title="Nominator in the form of mpdf.">nom</a>-><a class="code" href="classbdm_1_1epdf.html#aa84b05f5293cab2aeb4e07faffa60906" title="Return marginal density on the given RV, the remainig rvs are intergrated out.">marginal</a> ( <a class="code" href="classbdm_1_1mpdf.html#a5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a> );110 <a name="l00074"></a>00074 <a class="code" href="classbdm_1_1mratio.html# acda5bd23ba60146d69e1f804ff7710c7" title="datalink between conditional and nom">dl</a>.<a class="code" href="classbdm_1_1datalink__m2e.html#aadd918bf877c48714cff51ee4ad989b0" title="Set connection between vectors.">set_connection</a> ( rv, <a class="code" href="classbdm_1_1mpdf.html#a5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a>, nom0-><a class="code" href="classbdm_1_1epdf.html#aa4ab378d5e004c3ff3e2d4e64f7bba21" title="Return name (fails when isnamed is false).">_rv</a>() );106 <a name="l00073"></a>00073 <a class="code" href="classbdm_1_1mratio.html#873598797f36eddab44e342e14563fcb" 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#a84b05f5293cab2aeb4e07faffa60906" 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> ); 107 <a name="l00074"></a>00074 <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#add918bf877c48714cff51ee4ad989b0" title="Set connection between vectors.">set_connection</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_1epdf.html#a4ab378d5e004c3ff3e2d4e64f7bba21" title="Return name (fails when isnamed is false).">_rv</a>() ); 111 108 <a name="l00075"></a>00075 }; 112 <a name="l00076"></a><a class="code" href="classbdm_1_1mratio.html# a3a2cbce8c61ca9f592d9c2220f7c1204">00076</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mratio.html#a3a2cbce8c61ca9f592d9c2220f7c1204" title="Shortcut for conditioning and evaluation of the internal epdf. In some cases, this...">evallogcond</a> ( <span class="keyword">const</span> vec &val, <span class="keyword">const</span> vec &cond ) {109 <a name="l00076"></a><a class="code" href="classbdm_1_1mratio.html#3a2cbce8c61ca9f592d9c2220f7c1204">00076</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mratio.html#3a2cbce8c61ca9f592d9c2220f7c1204" title="Shortcut for conditioning and evaluation of the internal epdf. In some cases, this...">evallogcond</a> ( <span class="keyword">const</span> vec &val, <span class="keyword">const</span> vec &cond ) { 113 110 <a name="l00077"></a>00077 <span class="keywordtype">double</span> tmp; 114 <a name="l00078"></a>00078 vec nom_val ( dimension() + <a class="code" href="classbdm_1_1mpdf.html# a7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a> );115 <a name="l00079"></a>00079 <a class="code" href="classbdm_1_1mratio.html# acda5bd23ba60146d69e1f804ff7710c7" title="datalink between conditional and nom">dl</a>.<a class="code" href="classbdm_1_1datalink__m2e.html#ab29bc3c7bf2a1d87e77ccaa793d097d5" title="Copy corresponding values to Up.condition.">pushup_cond</a> ( nom_val, val, cond );116 <a name="l00080"></a>00080 tmp = exp ( <a class="code" href="classbdm_1_1mratio.html# af31caba90a2aa10fbf7631832404fe54" title="Nominator in the form of mpdf.">nom</a>-><a class="code" href="classbdm_1_1epdf.html#adeab266d63c236c277538867d5c3f249" title="Compute log-probability of argument val In case the argument is out of suport return...">evallog</a> ( nom_val ) - <a class="code" href="classbdm_1_1mratio.html#a873598797f36eddab44e342e14563fcb" title="Denominator in the form of epdf.">den</a>->evallog ( cond ) );111 <a name="l00078"></a>00078 vec nom_val ( dimension() + <a class="code" href="classbdm_1_1mpdf.html#7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a> ); 112 <a name="l00079"></a>00079 <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#b29bc3c7bf2a1d87e77ccaa793d097d5" title="Copy corresponding values to Up.condition.">pushup_cond</a> ( nom_val, val, cond ); 113 <a name="l00080"></a>00080 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#deab266d63c236c277538867d5c3f249" title="Compute log-probability of argument val In case the argument is out of suport return...">evallog</a> ( nom_val ) - <a class="code" href="classbdm_1_1mratio.html#873598797f36eddab44e342e14563fcb" title="Denominator in the form of epdf.">den</a>->evallog ( cond ) ); 117 114 <a name="l00081"></a>00081 <span class="keywordflow">return</span> tmp; 118 115 <a name="l00082"></a>00082 } 119 <a name="l00084"></a><a class="code" href="classbdm_1_1mratio.html# ac8b39fea586d4258bb3c881406edaf15">00084</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mratio.html#ac8b39fea586d4258bb3c881406edaf15" title="Object takes ownership of nom and will destroy it.">ownnom</a>() {120 <a name="l00085"></a>00085 <a class="code" href="classbdm_1_1mratio.html# a51bfe6675e724f7fbeaaeacce5a9f9b8" title="flag for destructor">destroynom</a> = <span class="keyword">true</span>;116 <a name="l00084"></a><a class="code" href="classbdm_1_1mratio.html#c8b39fea586d4258bb3c881406edaf15">00084</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>() { 117 <a name="l00085"></a>00085 <a class="code" href="classbdm_1_1mratio.html#51bfe6675e724f7fbeaaeacce5a9f9b8" title="flag for destructor">destroynom</a> = <span class="keyword">true</span>; 121 118 <a name="l00086"></a>00086 } 122 <a name="l00088"></a><a class="code" href="classbdm_1_1mratio.html# ac0cc0b25dbdc54751466616655454c5c">00088</a> <a class="code" href="classbdm_1_1mratio.html#ac0cc0b25dbdc54751466616655454c5c" title="Default destructor.">~mratio</a>() {123 <a name="l00089"></a>00089 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1mratio.html# a51bfe6675e724f7fbeaaeacce5a9f9b8" title="flag for destructor">destroynom</a> ) {124 <a name="l00090"></a>00090 <span class="keyword">delete</span> <a class="code" href="classbdm_1_1mratio.html# af31caba90a2aa10fbf7631832404fe54" title="Nominator in the form of mpdf.">nom</a>;119 <a name="l00088"></a><a class="code" href="classbdm_1_1mratio.html#c0cc0b25dbdc54751466616655454c5c">00088</a> <a class="code" href="classbdm_1_1mratio.html#c0cc0b25dbdc54751466616655454c5c" title="Default destructor.">~mratio</a>() { 120 <a name="l00089"></a>00089 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1mratio.html#51bfe6675e724f7fbeaaeacce5a9f9b8" title="flag for destructor">destroynom</a> ) { 121 <a name="l00090"></a>00090 <span class="keyword">delete</span> <a class="code" href="classbdm_1_1mratio.html#f31caba90a2aa10fbf7631832404fe54" title="Nominator in the form of mpdf.">nom</a>; 125 122 <a name="l00091"></a>00091 } 126 123 <a name="l00092"></a>00092 } … … 128 125 <a name="l00094"></a>00094 <span class="keyword">private</span>: 129 126 <a name="l00095"></a>00095 <span class="comment">// not implemented</span> 130 <a name="l00096"></a>00096 <a class="code" href="classbdm_1_1mratio.html# a0ff56d13f9515d7e5f23b7a4cc5529b4">mratio</a> ( <span class="keyword">const</span> <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> & );127 <a name="l00096"></a>00096 <a class="code" href="classbdm_1_1mratio.html#0ff56d13f9515d7e5f23b7a4cc5529b4">mratio</a> ( <span class="keyword">const</span> <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> & ); 131 128 <a name="l00097"></a>00097 <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> &operator=( <span class="keyword">const</span> <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> & ); 132 129 <a name="l00098"></a>00098 }; … … 134 131 <a name="l00110"></a><a class="code" href="classbdm_1_1emix.html">00110</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1emix.html" title="Mixture of epdfs.">emix</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> { 135 132 <a name="l00111"></a>00111 <span class="keyword">protected</span>: 136 <a name="l00113"></a><a class="code" href="classbdm_1_1emix.html# abb7270345c76da627cd77ddf020bcf46">00113</a> vec <a class="code" href="classbdm_1_1emix.html#abb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a>;133 <a name="l00113"></a><a class="code" href="classbdm_1_1emix.html#bb7270345c76da627cd77ddf020bcf46">00113</a> vec <a class="code" href="classbdm_1_1emix.html#bb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a>; 137 134 <a name="l00114"></a>00114 138 <a name="l00116"></a><a class="code" href="classbdm_1_1emix.html# a866e75dacba151942ead95104e57a897">00116</a> Array<shared_ptr<epdf> > <a class="code" href="classbdm_1_1emix.html#a866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a>;135 <a name="l00116"></a><a class="code" href="classbdm_1_1emix.html#866e75dacba151942ead95104e57a897">00116</a> Array<shared_ptr<epdf> > <a class="code" href="classbdm_1_1emix.html#866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a>; 139 136 <a name="l00117"></a>00117 140 137 <a name="l00118"></a>00118 <span class="keyword">public</span>: 141 <a name="l00120"></a><a class="code" href="classbdm_1_1emix.html# a4838f3a376ee0bd3c658bfb8f4ea4a3d">00120</a> <a class="code" href="classbdm_1_1emix.html#a4838f3a376ee0bd3c658bfb8f4ea4a3d" title="Default constructor.">emix</a> ( ) : <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( ) { }138 <a name="l00120"></a><a class="code" href="classbdm_1_1emix.html#4838f3a376ee0bd3c658bfb8f4ea4a3d">00120</a> <a class="code" href="classbdm_1_1emix.html#4838f3a376ee0bd3c658bfb8f4ea4a3d" title="Default constructor.">emix</a> ( ) : <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( ) { } 142 139 <a name="l00121"></a>00121 143 <a name="l00128"></a>00128 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1emix.html# a10b4e0c45dd8f7d78f73e325382c6922" title="Set weights w and components Coms.">set_parameters</a> ( <span class="keyword">const</span> vec &<a class="code" href="classbdm_1_1emix.html#abb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a>, <span class="keyword">const</span> Array<<a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<epdf></a> > &<a class="code" href="classbdm_1_1emix.html#a866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a> );140 <a name="l00128"></a>00128 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1emix.html#10b4e0c45dd8f7d78f73e325382c6922" title="Set weights w and components Coms.">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<<a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<epdf></a> > &<a class="code" href="classbdm_1_1emix.html#866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a> ); 144 141 <a name="l00129"></a>00129 145 <a name="l00130"></a>00130 vec <a class="code" href="classbdm_1_1emix.html# ae8839dbbb0d1276a8dbe957a67cfe0dc" title="Returns a sample, from density .">sample</a>() <span class="keyword">const</span>;146 <a name="l00131"></a><a class="code" href="classbdm_1_1emix.html#a a3a5390bc56e81ef3b0debc0f185fa8a">00131</a> vec <a class="code" href="classbdm_1_1emix.html#aa3a5390bc56e81ef3b0debc0f185fa8a" title="return expected value">mean</a>()<span class="keyword"> const </span>{142 <a name="l00130"></a>00130 vec <a class="code" href="classbdm_1_1emix.html#e8839dbbb0d1276a8dbe957a67cfe0dc" title="Returns a sample, from density .">sample</a>() <span class="keyword">const</span>; 143 <a name="l00131"></a><a class="code" href="classbdm_1_1emix.html#a3a5390bc56e81ef3b0debc0f185fa8a">00131</a> vec <a class="code" href="classbdm_1_1emix.html#a3a5390bc56e81ef3b0debc0f185fa8a" title="return expected value">mean</a>()<span class="keyword"> const </span>{ 147 144 <a name="l00132"></a>00132 <span class="keywordtype">int</span> i; 148 <a name="l00133"></a>00133 vec mu = zeros ( <a class="code" href="classbdm_1_1epdf.html# a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> );149 <a name="l00134"></a>00134 <span class="keywordflow">for</span> ( i = 0; i < <a class="code" href="classbdm_1_1emix.html# abb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a>.length(); i++ ) {150 <a name="l00135"></a>00135 mu += <a class="code" href="classbdm_1_1emix.html# abb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a> ( i ) * <a class="code" href="classbdm_1_1emix.html#a866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a> ( i )->mean();145 <a name="l00133"></a>00133 vec mu = zeros ( <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> ); 146 <a name="l00134"></a>00134 <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++ ) { 147 <a name="l00135"></a>00135 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#866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a> ( i )->mean(); 151 148 <a name="l00136"></a>00136 } 152 149 <a name="l00137"></a>00137 <span class="keywordflow">return</span> mu; 153 150 <a name="l00138"></a>00138 } 154 <a name="l00139"></a><a class="code" href="classbdm_1_1emix.html# ae9a627023cdf90c9ffd8eef726595c86">00139</a> vec <a class="code" href="classbdm_1_1emix.html#ae9a627023cdf90c9ffd8eef726595c86" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{151 <a name="l00139"></a><a class="code" href="classbdm_1_1emix.html#e9a627023cdf90c9ffd8eef726595c86">00139</a> vec <a class="code" href="classbdm_1_1emix.html#e9a627023cdf90c9ffd8eef726595c86" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{ 155 152 <a name="l00140"></a>00140 <span class="comment">//non-central moment</span> 156 <a name="l00141"></a>00141 vec mom2 = zeros ( <a class="code" href="classbdm_1_1epdf.html# a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> );157 <a name="l00142"></a>00142 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1emix.html# abb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a>.length(); i++ ) {158 <a name="l00143"></a>00143 mom2 += <a class="code" href="classbdm_1_1emix.html# abb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a> ( i ) * ( <a class="code" href="classbdm_1_1emix.html#a866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a> ( i )->variance() + pow ( <a class="code" href="classbdm_1_1emix.html#a866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a> ( i )-><a class="code" href="classbdm_1_1emix.html#aa3a5390bc56e81ef3b0debc0f185fa8a" title="return expected value">mean</a>(), 2 ) );153 <a name="l00141"></a>00141 vec mom2 = zeros ( <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> ); 154 <a name="l00142"></a>00142 <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++ ) { 155 <a name="l00143"></a>00143 mom2 += <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#866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a> ( i )->variance() + pow ( <a class="code" href="classbdm_1_1emix.html#866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a> ( i )-><a class="code" href="classbdm_1_1emix.html#a3a5390bc56e81ef3b0debc0f185fa8a" title="return expected value">mean</a>(), 2 ) ); 159 156 <a name="l00144"></a>00144 } 160 157 <a name="l00145"></a>00145 <span class="comment">//central moment</span> 161 <a name="l00146"></a>00146 <span class="keywordflow">return</span> mom2 - pow ( <a class="code" href="classbdm_1_1emix.html#a a3a5390bc56e81ef3b0debc0f185fa8a" title="return expected value">mean</a>(), 2 );158 <a name="l00146"></a>00146 <span class="keywordflow">return</span> mom2 - pow ( <a class="code" href="classbdm_1_1emix.html#a3a5390bc56e81ef3b0debc0f185fa8a" title="return expected value">mean</a>(), 2 ); 162 159 <a name="l00147"></a>00147 } 163 <a name="l00148"></a><a class="code" href="classbdm_1_1emix.html# a0f3db99f730bde6b7953931594537e8e">00148</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1emix.html#a0f3db99f730bde6b7953931594537e8e" title="Compute log-probability of argument val In case the argument is out of suport return...">evallog</a> ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{160 <a name="l00148"></a><a class="code" href="classbdm_1_1emix.html#0f3db99f730bde6b7953931594537e8e">00148</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1emix.html#0f3db99f730bde6b7953931594537e8e" title="Compute log-probability of argument val In case the argument is out of suport return...">evallog</a> ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{ 164 161 <a name="l00149"></a>00149 <span class="keywordtype">int</span> i; 165 162 <a name="l00150"></a>00150 <span class="keywordtype">double</span> sum = 0.0; 166 <a name="l00151"></a>00151 <span class="keywordflow">for</span> ( i = 0; i < <a class="code" href="classbdm_1_1emix.html# abb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a>.length(); i++ ) {167 <a name="l00152"></a>00152 sum += <a class="code" href="classbdm_1_1emix.html# abb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a> ( i ) * exp ( <a class="code" href="classbdm_1_1emix.html#a866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a> ( i )-><a class="code" href="classbdm_1_1emix.html#a0f3db99f730bde6b7953931594537e8e" title="Compute log-probability of argument val In case the argument is out of suport return...">evallog</a> ( val ) );163 <a name="l00151"></a>00151 <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++ ) { 164 <a name="l00152"></a>00152 sum += <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#866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a> ( i )-><a class="code" href="classbdm_1_1emix.html#0f3db99f730bde6b7953931594537e8e" title="Compute log-probability of argument val In case the argument is out of suport return...">evallog</a> ( val ) ); 168 165 <a name="l00153"></a>00153 } 169 166 <a name="l00154"></a>00154 <span class="keywordflow">if</span> ( sum == 0.0 ) { … … 171 168 <a name="l00156"></a>00156 } 172 169 <a name="l00157"></a>00157 <span class="keywordtype">double</span> tmp = log ( sum ); 173 <a name="l00158"></a>00158 <a class="code" href="bdmerror_8h.html# a89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</a> ( std::isfinite ( tmp ), <span class="stringliteral">"Infinite"</span> );170 <a name="l00158"></a>00158 <a class="code" href="bdmerror_8h.html#89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</a> ( std::isfinite ( tmp ), <span class="stringliteral">"Infinite"</span> ); 174 171 <a name="l00159"></a>00159 <span class="keywordflow">return</span> tmp; 175 172 <a name="l00160"></a>00160 }; 176 <a name="l00161"></a><a class="code" href="classbdm_1_1emix.html# a23af1986e2afcbc8c7e1c30f610e703b">00161</a> vec <a class="code" href="classbdm_1_1emix.html#a23af1986e2afcbc8c7e1c30f610e703b" title="Compute log-probability of multiple values argument val.">evallog_m</a> ( <span class="keyword">const</span> mat &Val )<span class="keyword"> const </span>{173 <a name="l00161"></a><a class="code" href="classbdm_1_1emix.html#23af1986e2afcbc8c7e1c30f610e703b">00161</a> vec <a class="code" href="classbdm_1_1emix.html#23af1986e2afcbc8c7e1c30f610e703b" title="Compute log-probability of multiple values argument val.">evallog_m</a> ( <span class="keyword">const</span> mat &Val )<span class="keyword"> const </span>{ 177 174 <a name="l00162"></a>00162 vec x = zeros ( Val.cols() ); 178 <a name="l00163"></a>00163 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1emix.html# abb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a>.length(); i++ ) {179 <a name="l00164"></a>00164 x += <a class="code" href="classbdm_1_1emix.html# abb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a> ( i ) * exp ( <a class="code" href="classbdm_1_1emix.html#a866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a> ( i )-><a class="code" href="classbdm_1_1emix.html#a23af1986e2afcbc8c7e1c30f610e703b" title="Compute log-probability of multiple values argument val.">evallog_m</a> ( Val ) );175 <a name="l00163"></a>00163 <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++ ) { 176 <a name="l00164"></a>00164 x += <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#866e75dacba151942ead95104e57a897" 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 ) ); 180 177 <a name="l00165"></a>00165 } 181 178 <a name="l00166"></a>00166 <span class="keywordflow">return</span> log ( x ); 182 179 <a name="l00167"></a>00167 }; 183 <a name="l00169"></a><a class="code" href="classbdm_1_1emix.html# ae64c1d5a73f541e469792e23d4677af2">00169</a> mat <a class="code" href="classbdm_1_1emix.html#ae64c1d5a73f541e469792e23d4677af2" title="Auxiliary function that returns pdflog for each component.">evallog_M</a> ( <span class="keyword">const</span> mat &Val )<span class="keyword"> const </span>{184 <a name="l00170"></a>00170 mat X ( <a class="code" href="classbdm_1_1emix.html# abb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a>.length(), Val.cols() );185 <a name="l00171"></a>00171 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1emix.html# abb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a>.length(); i++ ) {186 <a name="l00172"></a>00172 X.set_row ( i, <a class="code" href="classbdm_1_1emix.html# abb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a> ( i ) *exp ( <a class="code" href="classbdm_1_1emix.html#a866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a> ( i )-><a class="code" href="classbdm_1_1emix.html#a23af1986e2afcbc8c7e1c30f610e703b" title="Compute log-probability of multiple values argument val.">evallog_m</a> ( Val ) ) );180 <a name="l00169"></a><a class="code" href="classbdm_1_1emix.html#e64c1d5a73f541e469792e23d4677af2">00169</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>{ 181 <a name="l00170"></a>00170 mat X ( <a class="code" href="classbdm_1_1emix.html#bb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a>.length(), Val.cols() ); 182 <a name="l00171"></a>00171 <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++ ) { 183 <a name="l00172"></a>00172 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#866e75dacba151942ead95104e57a897" 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 ) ) ); 187 184 <a name="l00173"></a>00173 } 188 185 <a name="l00174"></a>00174 <span class="keywordflow">return</span> X; 189 186 <a name="l00175"></a>00175 }; 190 187 <a name="l00176"></a>00176 191 <a name="l00177"></a>00177 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<epdf></a> <a class="code" href="classbdm_1_1emix.html# a4edf5ceb3179a03f01b870c67eb53bb6" 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#a62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> ) <span class="keyword">const</span>;192 <a name="l00179"></a>00179 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1emix.html# a4edf5ceb3179a03f01b870c67eb53bb6" 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#a62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>, <a class="code" href="classbdm_1_1emix.html" title="Mixture of epdfs.">emix</a> &target ) <span class="keyword">const</span>;193 <a name="l00180"></a>00180 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<mpdf></a> <a class="code" href="classbdm_1_1emix.html# a4176e4dc11980db4200b9fab54402a09" 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#a62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> ) <span class="keyword">const</span>;188 <a name="l00177"></a>00177 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<epdf></a> <a class="code" href="classbdm_1_1emix.html#4edf5ceb3179a03f01b870c67eb53bb6" 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="Description of the random variable.">rv</a> ) <span class="keyword">const</span>; 189 <a name="l00179"></a>00179 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1emix.html#4edf5ceb3179a03f01b870c67eb53bb6" 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="Description of the random variable.">rv</a>, <a class="code" href="classbdm_1_1emix.html" title="Mixture of epdfs.">emix</a> &target ) <span class="keyword">const</span>; 190 <a name="l00180"></a>00180 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<mpdf></a> <a class="code" href="classbdm_1_1emix.html#4176e4dc11980db4200b9fab54402a09" 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="Description of the random variable.">rv</a> ) <span class="keyword">const</span>; 194 191 <a name="l00181"></a>00181 195 192 <a name="l00182"></a>00182 <span class="comment">//Access methods</span> 196 <a name="l00184"></a><a class="code" href="classbdm_1_1emix.html# ad9b584cb5b2471a4250fb127757f28be">00184</a> <span class="comment"></span> vec& <a class="code" href="classbdm_1_1emix.html#ad9b584cb5b2471a4250fb127757f28be" title="returns a pointer to the internal mean value. Use with Care!">_w</a>() {197 <a name="l00185"></a>00185 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1emix.html# abb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a>;193 <a name="l00184"></a><a class="code" href="classbdm_1_1emix.html#d9b584cb5b2471a4250fb127757f28be">00184</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>() { 194 <a name="l00185"></a>00185 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1emix.html#bb7270345c76da627cd77ddf020bcf46" title="weights of the components">w</a>; 198 195 <a name="l00186"></a>00186 } 199 196 <a name="l00187"></a>00187 200 <a name="l00189"></a><a class="code" href="classbdm_1_1emix.html# a579437ba18bf9975b3084e10bfe1b727">00189</a> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<epdf></a> <a class="code" href="classbdm_1_1emix.html#a579437ba18bf9975b3084e10bfe1b727" title="access function">_Coms</a> ( <span class="keywordtype">int</span> i ) {201 <a name="l00190"></a>00190 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1emix.html# a866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a> ( i );197 <a name="l00189"></a><a class="code" href="classbdm_1_1emix.html#579437ba18bf9975b3084e10bfe1b727">00189</a> <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<epdf></a> <a class="code" href="classbdm_1_1emix.html#579437ba18bf9975b3084e10bfe1b727" title="access function">_Coms</a> ( <span class="keywordtype">int</span> i ) { 198 <a name="l00190"></a>00190 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1emix.html#866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a> ( i ); 202 199 <a name="l00191"></a>00191 } 203 200 <a name="l00192"></a>00192 204 <a name="l00193"></a><a class="code" href="classbdm_1_1emix.html# a04a8632cfa9299ae937228eb732fd61e">00193</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1emix.html#a04a8632cfa9299ae937228eb732fd61e" title="Name its rv.">set_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_1epdf.html#a62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> ) {205 <a name="l00194"></a>00194 <a class="code" href="classbdm_1_1emix.html# a04a8632cfa9299ae937228eb732fd61e" title="Name its rv.">epdf::set_rv</a> ( rv );206 <a name="l00195"></a>00195 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1emix.html# a866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a>.length(); i++ ) {207 <a name="l00196"></a>00196 <a class="code" href="classbdm_1_1emix.html# a866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a> ( i )->set_rv ( rv );201 <a name="l00193"></a><a class="code" href="classbdm_1_1emix.html#04a8632cfa9299ae937228eb732fd61e">00193</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1emix.html#04a8632cfa9299ae937228eb732fd61e" title="Name its rv.">set_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_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> ) { 202 <a name="l00194"></a>00194 <a class="code" href="classbdm_1_1emix.html#04a8632cfa9299ae937228eb732fd61e" title="Name its rv.">epdf::set_rv</a> ( rv ); 203 <a name="l00195"></a>00195 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1emix.html#866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a>.length(); i++ ) { 204 <a name="l00196"></a>00196 <a class="code" href="classbdm_1_1emix.html#866e75dacba151942ead95104e57a897" title="Component (epdfs).">Coms</a> ( i )->set_rv ( rv ); 208 205 <a name="l00197"></a>00197 } 209 206 <a name="l00198"></a>00198 } … … 213 210 <a name="l00206"></a><a class="code" href="classbdm_1_1egiwmix.html">00206</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1egiwmix.html" title="Mixture of egiws.">egiwmix</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1egiw.html" title="Gauss-inverse-Wishart density stored in LD form.">egiw</a> { 214 211 <a name="l00207"></a>00207 <span class="keyword">protected</span>: 215 <a name="l00209"></a><a class="code" href="classbdm_1_1egiwmix.html# a2deb6d7cd689949b92450227de98afa4">00209</a> vec <a class="code" href="classbdm_1_1egiwmix.html#a2deb6d7cd689949b92450227de98afa4" title="weights of the components">w</a>;216 <a name="l00211"></a><a class="code" href="classbdm_1_1egiwmix.html# a8d0a3acd6ced68349b8f9950f4658280">00211</a> Array<egiw*> <a class="code" href="classbdm_1_1egiwmix.html#a8d0a3acd6ced68349b8f9950f4658280" title="Component (epdfs).">Coms</a>;217 <a name="l00213"></a><a class="code" href="classbdm_1_1egiwmix.html# a2a363169e5aa6c7cad1f4d7647fe9eec">00213</a> <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1egiwmix.html#a2a363169e5aa6c7cad1f4d7647fe9eec" title="Flag if owning Coms.">destroyComs</a>;212 <a name="l00209"></a><a class="code" href="classbdm_1_1egiwmix.html#2deb6d7cd689949b92450227de98afa4">00209</a> vec <a class="code" href="classbdm_1_1egiwmix.html#2deb6d7cd689949b92450227de98afa4" title="weights of the components">w</a>; 213 <a name="l00211"></a><a class="code" href="classbdm_1_1egiwmix.html#8d0a3acd6ced68349b8f9950f4658280">00211</a> Array<egiw*> <a class="code" href="classbdm_1_1egiwmix.html#8d0a3acd6ced68349b8f9950f4658280" title="Component (epdfs).">Coms</a>; 214 <a name="l00213"></a><a class="code" href="classbdm_1_1egiwmix.html#2a363169e5aa6c7cad1f4d7647fe9eec">00213</a> <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1egiwmix.html#2a363169e5aa6c7cad1f4d7647fe9eec" title="Flag if owning Coms.">destroyComs</a>; 218 215 <a name="l00214"></a>00214 <span class="keyword">public</span>: 219 <a name="l00216"></a><a class="code" href="classbdm_1_1egiwmix.html# a41f4cf7baf554e0a70bf495457179dbb">00216</a> <a class="code" href="classbdm_1_1egiwmix.html#a41f4cf7baf554e0a70bf495457179dbb" title="Default constructor.">egiwmix</a> ( ) : <a class="code" href="classbdm_1_1egiw.html" title="Gauss-inverse-Wishart density stored in LD form.">egiw</a> ( ) {};216 <a name="l00216"></a><a class="code" href="classbdm_1_1egiwmix.html#41f4cf7baf554e0a70bf495457179dbb">00216</a> <a class="code" href="classbdm_1_1egiwmix.html#41f4cf7baf554e0a70bf495457179dbb" title="Default constructor.">egiwmix</a> ( ) : <a class="code" href="classbdm_1_1egiw.html" title="Gauss-inverse-Wishart density stored in LD form.">egiw</a> ( ) {}; 220 217 <a name="l00217"></a>00217 221 <a name="l00220"></a>00220 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egiwmix.html# ac4627222e22df6e14f8f1496e13c4975">set_parameters</a> ( <span class="keyword">const</span> vec &<a class="code" href="classbdm_1_1egiwmix.html#a2deb6d7cd689949b92450227de98afa4" title="weights of the components">w</a>, <span class="keyword">const</span> Array<egiw*> &<a class="code" href="classbdm_1_1egiwmix.html#a8d0a3acd6ced68349b8f9950f4658280" title="Component (epdfs).">Coms</a>, <span class="keywordtype">bool</span> copy = <span class="keyword">false</span> );218 <a name="l00220"></a>00220 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egiwmix.html#c4627222e22df6e14f8f1496e13c4975">set_parameters</a> ( <span class="keyword">const</span> vec &<a class="code" href="classbdm_1_1egiwmix.html#2deb6d7cd689949b92450227de98afa4" title="weights of the components">w</a>, <span class="keyword">const</span> Array<egiw*> &<a class="code" href="classbdm_1_1egiwmix.html#8d0a3acd6ced68349b8f9950f4658280" title="Component (epdfs).">Coms</a>, <span class="keywordtype">bool</span> copy = <span class="keyword">false</span> ); 222 219 <a name="l00221"></a>00221 223 <a name="l00223"></a>00223 vec <a class="code" href="classbdm_1_1egiwmix.html# a74e7c77bd89a454a7fd984945c58df1c" title="return expected value">mean</a>() <span class="keyword">const</span>;220 <a name="l00223"></a>00223 vec <a class="code" href="classbdm_1_1egiwmix.html#74e7c77bd89a454a7fd984945c58df1c" title="return expected value">mean</a>() <span class="keyword">const</span>; 224 221 <a name="l00224"></a>00224 225 <a name="l00226"></a>00226 vec <a class="code" href="classbdm_1_1egiwmix.html# a8bd92fb4c94a46220e84d9a39ddd2e28" title="return a sample from the density">sample</a>() <span class="keyword">const</span>;222 <a name="l00226"></a>00226 vec <a class="code" href="classbdm_1_1egiwmix.html#8bd92fb4c94a46220e84d9a39ddd2e28" title="return a sample from the density">sample</a>() <span class="keyword">const</span>; 226 223 <a name="l00227"></a>00227 227 <a name="l00229"></a>00229 vec <a class="code" href="classbdm_1_1egiwmix.html# a96e1cfb7157b87f04e2957ca4d883425" title="return the expected variance">variance</a>() <span class="keyword">const</span>;224 <a name="l00229"></a>00229 vec <a class="code" href="classbdm_1_1egiwmix.html#96e1cfb7157b87f04e2957ca4d883425" title="return the expected variance">variance</a>() <span class="keyword">const</span>; 228 225 <a name="l00230"></a>00230 229 226 <a name="l00231"></a>00231 <span class="comment">// TODO!!! Defined to follow ANSI and/or for future development</span> 230 <a name="l00232"></a><a class="code" href="classbdm_1_1egiwmix.html# a99962cd566fc4e6d59099dae6b7ecb8c">00232</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egiwmix.html#a99962cd566fc4e6d59099dae6b7ecb8c" title="expected values of the linear coefficient and the covariance matrix are written to...">mean_mat</a> ( mat &M, mat&R )<span class="keyword"> const </span>{};231 <a name="l00233"></a><a class="code" href="classbdm_1_1egiwmix.html# a5713da45d66410382d6eca4e1b05a132">00233</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1egiwmix.html#a5713da45d66410382d6eca4e1b05a132" 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>{227 <a name="l00232"></a><a class="code" href="classbdm_1_1egiwmix.html#99962cd566fc4e6d59099dae6b7ecb8c">00232</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egiwmix.html#99962cd566fc4e6d59099dae6b7ecb8c" title="expected values of the linear coefficient and the covariance matrix are written to...">mean_mat</a> ( mat &M, mat&R )<span class="keyword"> const </span>{}; 228 <a name="l00233"></a><a class="code" href="classbdm_1_1egiwmix.html#5713da45d66410382d6eca4e1b05a132">00233</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1egiwmix.html#5713da45d66410382d6eca4e1b05a132" 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>{ 232 229 <a name="l00234"></a>00234 <span class="keywordflow">return</span> 0; 233 230 <a name="l00235"></a>00235 }; 234 <a name="l00236"></a><a class="code" href="classbdm_1_1egiwmix.html# a7c9bc72ecea861dd2416f852905bf023">00236</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1egiwmix.html#a7c9bc72ecea861dd2416f852905bf023" title="logarithm of the normalizing constant, ">lognc</a> ()<span class="keyword"> const </span>{231 <a name="l00236"></a><a class="code" href="classbdm_1_1egiwmix.html#7c9bc72ecea861dd2416f852905bf023">00236</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1egiwmix.html#7c9bc72ecea861dd2416f852905bf023" title="logarithm of the normalizing constant, ">lognc</a> ()<span class="keyword"> const </span>{ 235 232 <a name="l00237"></a>00237 <span class="keywordflow">return</span> 0; 236 233 <a name="l00238"></a>00238 } 237 234 <a name="l00239"></a>00239 238 <a name="l00240"></a>00240 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<epdf></a> <a class="code" href="classbdm_1_1egiwmix.html#a ab30611d0ca7cc718956548a42a1f67d" 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#a62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> ) <span class="keyword">const</span>;239 <a name="l00241"></a>00241 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egiwmix.html#a ab30611d0ca7cc718956548a42a1f67d" 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#a62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>, <a class="code" href="classbdm_1_1emix.html" title="Mixture of epdfs.">emix</a> &target ) <span class="keyword">const</span>;235 <a name="l00240"></a>00240 <a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<epdf></a> <a class="code" href="classbdm_1_1egiwmix.html#ab30611d0ca7cc718956548a42a1f67d" 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="Description of the random variable.">rv</a> ) <span class="keyword">const</span>; 236 <a name="l00241"></a>00241 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egiwmix.html#ab30611d0ca7cc718956548a42a1f67d" 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="Description of the random variable.">rv</a>, <a class="code" href="classbdm_1_1emix.html" title="Mixture of epdfs.">emix</a> &target ) <span class="keyword">const</span>; 240 237 <a name="l00242"></a>00242 241 238 <a name="l00243"></a>00243 <span class="comment">//Access methods</span> 242 <a name="l00245"></a><a class="code" href="classbdm_1_1egiwmix.html# a884d203ca3994b9fba4c8bd440f355ea">00245</a> <span class="comment"></span> vec& <a class="code" href="classbdm_1_1egiwmix.html#a884d203ca3994b9fba4c8bd440f355ea" title="returns a pointer to the internal mean value. Use with Care!">_w</a>() {243 <a name="l00246"></a>00246 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1egiwmix.html# a2deb6d7cd689949b92450227de98afa4" title="weights of the components">w</a>;239 <a name="l00245"></a><a class="code" href="classbdm_1_1egiwmix.html#884d203ca3994b9fba4c8bd440f355ea">00245</a> <span class="comment"></span> vec& <a class="code" href="classbdm_1_1egiwmix.html#884d203ca3994b9fba4c8bd440f355ea" title="returns a pointer to the internal mean value. Use with Care!">_w</a>() { 240 <a name="l00246"></a>00246 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1egiwmix.html#2deb6d7cd689949b92450227de98afa4" title="weights of the components">w</a>; 244 241 <a name="l00247"></a>00247 } 245 242 <a name="l00248"></a>00248 <span class="keyword">virtual</span> ~<a class="code" href="classbdm_1_1egiwmix.html" title="Mixture of egiws.">egiwmix</a>() { 246 <a name="l00249"></a>00249 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1egiwmix.html# a2a363169e5aa6c7cad1f4d7647fe9eec" title="Flag if owning Coms.">destroyComs</a> ) {247 <a name="l00250"></a>00250 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1egiwmix.html# a8d0a3acd6ced68349b8f9950f4658280" title="Component (epdfs).">Coms</a>.length(); i++ ) {248 <a name="l00251"></a>00251 <span class="keyword">delete</span> <a class="code" href="classbdm_1_1egiwmix.html# a8d0a3acd6ced68349b8f9950f4658280" title="Component (epdfs).">Coms</a> ( i );243 <a name="l00249"></a>00249 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1egiwmix.html#2a363169e5aa6c7cad1f4d7647fe9eec" title="Flag if owning Coms.">destroyComs</a> ) { 244 <a name="l00250"></a>00250 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1egiwmix.html#8d0a3acd6ced68349b8f9950f4658280" title="Component (epdfs).">Coms</a>.length(); i++ ) { 245 <a name="l00251"></a>00251 <span class="keyword">delete</span> <a class="code" href="classbdm_1_1egiwmix.html#8d0a3acd6ced68349b8f9950f4658280" title="Component (epdfs).">Coms</a> ( i ); 249 246 <a name="l00252"></a>00252 } 250 247 <a name="l00253"></a>00253 } 251 248 <a name="l00254"></a>00254 } 252 <a name="l00256"></a><a class="code" href="classbdm_1_1egiwmix.html#a adc550fe74df25524c20867e89b5b096">00256</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egiwmix.html#aadc550fe74df25524c20867e89b5b096" title="Auxiliary function for taking ownership of the Coms().">ownComs</a>() {253 <a name="l00257"></a>00257 <a class="code" href="classbdm_1_1egiwmix.html# a2a363169e5aa6c7cad1f4d7647fe9eec" title="Flag if owning Coms.">destroyComs</a> = <span class="keyword">true</span>;249 <a name="l00256"></a><a class="code" href="classbdm_1_1egiwmix.html#adc550fe74df25524c20867e89b5b096">00256</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egiwmix.html#adc550fe74df25524c20867e89b5b096" title="Auxiliary function for taking ownership of the Coms().">ownComs</a>() { 250 <a name="l00257"></a>00257 <a class="code" href="classbdm_1_1egiwmix.html#2a363169e5aa6c7cad1f4d7647fe9eec" title="Flag if owning Coms.">destroyComs</a> = <span class="keyword">true</span>; 254 251 <a name="l00258"></a>00258 } 255 252 <a name="l00259"></a>00259 256 <a name="l00261"></a><a class="code" href="classbdm_1_1egiwmix.html# ad20a56a7b129c1ea9f71725e15f8ad8c">00261</a> <a class="code" href="classbdm_1_1egiw.html" title="Gauss-inverse-Wishart density stored in LD form.">egiw</a>* <a class="code" href="classbdm_1_1egiwmix.html#ad20a56a7b129c1ea9f71725e15f8ad8c" title="access function">_Coms</a> ( <span class="keywordtype">int</span> i ) {257 <a name="l00262"></a>00262 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1egiwmix.html# a8d0a3acd6ced68349b8f9950f4658280" title="Component (epdfs).">Coms</a> ( i );253 <a name="l00261"></a><a class="code" href="classbdm_1_1egiwmix.html#d20a56a7b129c1ea9f71725e15f8ad8c">00261</a> <a class="code" href="classbdm_1_1egiw.html" title="Gauss-inverse-Wishart density stored in LD form.">egiw</a>* <a class="code" href="classbdm_1_1egiwmix.html#d20a56a7b129c1ea9f71725e15f8ad8c" title="access function">_Coms</a> ( <span class="keywordtype">int</span> i ) { 254 <a name="l00262"></a>00262 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1egiwmix.html#8d0a3acd6ced68349b8f9950f4658280" title="Component (epdfs).">Coms</a> ( i ); 258 255 <a name="l00263"></a>00263 } 259 256 <a name="l00264"></a>00264 260 <a name="l00265"></a><a class="code" href="classbdm_1_1egiwmix.html# adc999c5c1402c450200f22128db688b2">00265</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egiwmix.html#adc999c5c1402c450200f22128db688b2" title="Name its rv.">set_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_1epdf.html#a62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> ) {261 <a name="l00266"></a>00266 <a class="code" href="classbdm_1_1egiwmix.html# adc999c5c1402c450200f22128db688b2" title="Name its rv.">egiw::set_rv</a> ( rv );262 <a name="l00267"></a>00267 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1egiwmix.html# a8d0a3acd6ced68349b8f9950f4658280" title="Component (epdfs).">Coms</a>.length(); i++ ) {263 <a name="l00268"></a>00268 <a class="code" href="classbdm_1_1egiwmix.html# a8d0a3acd6ced68349b8f9950f4658280" title="Component (epdfs).">Coms</a> ( i )->set_rv ( rv );257 <a name="l00265"></a><a class="code" href="classbdm_1_1egiwmix.html#dc999c5c1402c450200f22128db688b2">00265</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1egiwmix.html#dc999c5c1402c450200f22128db688b2" title="Name its rv.">set_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_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> ) { 258 <a name="l00266"></a>00266 <a class="code" href="classbdm_1_1egiwmix.html#dc999c5c1402c450200f22128db688b2" title="Name its rv.">egiw::set_rv</a> ( rv ); 259 <a name="l00267"></a>00267 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1egiwmix.html#8d0a3acd6ced68349b8f9950f4658280" title="Component (epdfs).">Coms</a>.length(); i++ ) { 260 <a name="l00268"></a>00268 <a class="code" href="classbdm_1_1egiwmix.html#8d0a3acd6ced68349b8f9950f4658280" title="Component (epdfs).">Coms</a> ( i )->set_rv ( rv ); 264 261 <a name="l00269"></a>00269 } 265 262 <a name="l00270"></a>00270 } 266 263 <a name="l00271"></a>00271 267 <a name="l00273"></a>00273 <a class="code" href="classbdm_1_1egiw.html" title="Gauss-inverse-Wishart density stored in LD form.">egiw</a>* <a class="code" href="classbdm_1_1egiwmix.html# a10894d50e82130cc5b93d3cbc30b2e4d" title="Approximation of a GiW mix by a single GiW pdf.">approx</a>();264 <a name="l00273"></a>00273 <a class="code" href="classbdm_1_1egiw.html" title="Gauss-inverse-Wishart density stored in LD form.">egiw</a>* <a class="code" href="classbdm_1_1egiwmix.html#10894d50e82130cc5b93d3cbc30b2e4d" title="Approximation of a GiW mix by a single GiW pdf.">approx</a>(); 268 265 <a name="l00274"></a>00274 }; 269 266 <a name="l00275"></a>00275 … … 275 272 <a name="l00290"></a>00290 276 273 <a name="l00291"></a>00291 <span class="keyword">protected</span>: 277 <a name="l00293"></a><a class="code" href="classbdm_1_1mprod.html# a9dab8448f970e2e09f76d14af990990d">00293</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_1mprod.html#a9dab8448f970e2e09f76d14af990990d" title="dummy epdf used only as storage for RV and dim">iepdf</a>;274 <a name="l00293"></a><a class="code" href="classbdm_1_1mprod.html#9dab8448f970e2e09f76d14af990990d">00293</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_1mprod.html#9dab8448f970e2e09f76d14af990990d" title="dummy epdf used only as storage for RV and dim">iepdf</a>; 278 275 <a name="l00294"></a>00294 279 276 <a name="l00295"></a>00295 <span class="keyword">public</span>: 280 <a name="l00297"></a><a class="code" href="classbdm_1_1mprod.html# afed864cdd0e724d9133e6c6bfcacf94b">00297</a> <a class="code" href="classbdm_1_1mprod.html#afed864cdd0e724d9133e6c6bfcacf94b" title="Default constructor.">mprod</a>() { }277 <a name="l00297"></a><a class="code" href="classbdm_1_1mprod.html#fed864cdd0e724d9133e6c6bfcacf94b">00297</a> <a class="code" href="classbdm_1_1mprod.html#fed864cdd0e724d9133e6c6bfcacf94b" title="Default constructor.">mprod</a>() { } 281 278 <a name="l00298"></a>00298 282 <a name="l00301"></a><a class="code" href="classbdm_1_1mprod.html# ae0d61b25fa0955b2c5fab8c710c42200">00301</a> <a class="code" href="classbdm_1_1mprod.html#ae0d61b25fa0955b2c5fab8c710c42200" title="Constructor from list of mFacs.">mprod</a> ( <span class="keyword">const</span> Array<<a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<mpdf></a> > &mFacs ) {283 <a name="l00302"></a>00302 <a class="code" href="classbdm_1_1mprod.html#a acb4cd6d390ef73a4432d0c4993baffa" title="Set internal mpdfs from given values.">set_elements</a> ( mFacs );279 <a name="l00301"></a><a class="code" href="classbdm_1_1mprod.html#e0d61b25fa0955b2c5fab8c710c42200">00301</a> <a class="code" href="classbdm_1_1mprod.html#e0d61b25fa0955b2c5fab8c710c42200" title="Constructor from list of mFacs.">mprod</a> ( <span class="keyword">const</span> Array<<a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<mpdf></a> > &mFacs ) { 280 <a name="l00302"></a>00302 <a class="code" href="classbdm_1_1mprod.html#acb4cd6d390ef73a4432d0c4993baffa" title="Set internal mpdfs from given values.">set_elements</a> ( mFacs ); 284 281 <a name="l00303"></a>00303 } 285 <a name="l00305"></a>00305 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mprod.html#a acb4cd6d390ef73a4432d0c4993baffa" title="Set internal mpdfs from given values.">set_elements</a> (<span class="keyword">const</span> Array<<a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<mpdf></a> > &mFacs );282 <a name="l00305"></a>00305 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mprod.html#acb4cd6d390ef73a4432d0c4993baffa" title="Set internal mpdfs from given values.">set_elements</a> (<span class="keyword">const</span> Array<<a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<mpdf></a> > &mFacs ); 286 283 <a name="l00306"></a>00306 287 <a name="l00307"></a><a class="code" href="classbdm_1_1mprod.html# a800f21d94c919137608a2fd5c88719e2">00307</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mprod.html#a800f21d94c919137608a2fd5c88719e2" title="Shortcut for conditioning and evaluation of the internal epdf. In some cases, this...">evallogcond</a> ( <span class="keyword">const</span> vec &val, <span class="keyword">const</span> vec &cond ) {284 <a name="l00307"></a><a class="code" href="classbdm_1_1mprod.html#800f21d94c919137608a2fd5c88719e2">00307</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mprod.html#800f21d94c919137608a2fd5c88719e2" title="Shortcut for conditioning and evaluation of the internal epdf. In some cases, this...">evallogcond</a> ( <span class="keyword">const</span> vec &val, <span class="keyword">const</span> vec &cond ) { 288 285 <a name="l00308"></a>00308 <span class="keywordtype">int</span> i; 289 286 <a name="l00309"></a>00309 <span class="keywordtype">double</span> res = 0.0; … … 301 298 <a name="l00321"></a>00321 <span class="keywordflow">return</span> res; 302 299 <a name="l00322"></a>00322 } 303 <a name="l00323"></a><a class="code" href="classbdm_1_1mprod.html# ae27b359d2572abfa4cc7d8f947848dab">00323</a> vec <a class="code" href="classbdm_1_1mprod.html#ae27b359d2572abfa4cc7d8f947848dab" title="Matrix version of evallogcond.">evallogcond_m</a> ( <span class="keyword">const</span> mat &Dt, <span class="keyword">const</span> vec &cond ) {300 <a name="l00323"></a><a class="code" href="classbdm_1_1mprod.html#e27b359d2572abfa4cc7d8f947848dab">00323</a> vec <a class="code" href="classbdm_1_1mprod.html#e27b359d2572abfa4cc7d8f947848dab" title="Matrix version of evallogcond.">evallogcond_m</a> ( <span class="keyword">const</span> mat &Dt, <span class="keyword">const</span> vec &cond ) { 304 301 <a name="l00324"></a>00324 vec tmp ( Dt.cols() ); 305 302 <a name="l00325"></a>00325 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < Dt.cols(); i++ ) { 306 <a name="l00326"></a>00326 tmp ( i ) = <a class="code" href="classbdm_1_1mprod.html# a800f21d94c919137608a2fd5c88719e2" title="Shortcut for conditioning and evaluation of the internal epdf. In some cases, this...">evallogcond</a> ( Dt.get_col ( i ), cond );303 <a name="l00326"></a>00326 tmp ( i ) = <a class="code" href="classbdm_1_1mprod.html#800f21d94c919137608a2fd5c88719e2" title="Shortcut for conditioning and evaluation of the internal epdf. In some cases, this...">evallogcond</a> ( Dt.get_col ( i ), cond ); 307 304 <a name="l00327"></a>00327 } 308 305 <a name="l00328"></a>00328 <span class="keywordflow">return</span> tmp; 309 306 <a name="l00329"></a>00329 }; 310 <a name="l00330"></a><a class="code" href="classbdm_1_1mprod.html# ae8cdde6056fe20551be1fa460841f5e2">00330</a> vec <a class="code" href="classbdm_1_1mprod.html#ae8cdde6056fe20551be1fa460841f5e2" title="Array&lt;vec&gt; version of evallogcond.">evallogcond_m</a> ( <span class="keyword">const</span> Array<vec> &Dt, <span class="keyword">const</span> vec &cond ) {307 <a name="l00330"></a><a class="code" href="classbdm_1_1mprod.html#e8cdde6056fe20551be1fa460841f5e2">00330</a> vec <a class="code" href="classbdm_1_1mprod.html#e8cdde6056fe20551be1fa460841f5e2" title="Array&lt;vec&gt; version of evallogcond.">evallogcond_m</a> ( <span class="keyword">const</span> Array<vec> &Dt, <span class="keyword">const</span> vec &cond ) { 311 308 <a name="l00331"></a>00331 vec tmp ( Dt.length() ); 312 309 <a name="l00332"></a>00332 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < Dt.length(); i++ ) { 313 <a name="l00333"></a>00333 tmp ( i ) = <a class="code" href="classbdm_1_1mprod.html# a800f21d94c919137608a2fd5c88719e2" title="Shortcut for conditioning and evaluation of the internal epdf. In some cases, this...">evallogcond</a> ( Dt ( i ), cond );310 <a name="l00333"></a>00333 tmp ( i ) = <a class="code" href="classbdm_1_1mprod.html#800f21d94c919137608a2fd5c88719e2" title="Shortcut for conditioning and evaluation of the internal epdf. In some cases, this...">evallogcond</a> ( Dt ( i ), cond ); 314 311 <a name="l00334"></a>00334 } 315 312 <a name="l00335"></a>00335 <span class="keywordflow">return</span> tmp; … … 318 315 <a name="l00338"></a>00338 319 316 <a name="l00339"></a>00339 <span class="comment">//TODO smarter...</span> 320 <a name="l00340"></a><a class="code" href="classbdm_1_1mprod.html# aee715a8013acf9892f6cb489db595555">00340</a> vec <a class="code" href="classbdm_1_1mprod.html#aee715a8013acf9892f6cb489db595555" title="Returns a sample from the density conditioned on cond, .">samplecond</a> ( <span class="keyword">const</span> vec &cond ) {317 <a name="l00340"></a><a class="code" href="classbdm_1_1mprod.html#ee715a8013acf9892f6cb489db595555">00340</a> vec <a class="code" href="classbdm_1_1mprod.html#ee715a8013acf9892f6cb489db595555" title="Returns a sample from the density conditioned on cond, .">samplecond</a> ( <span class="keyword">const</span> vec &cond ) { 321 318 <a name="l00342"></a>00342 vec smp = std::numeric_limits<double>::infinity() * ones ( dimension() ); 322 319 <a name="l00343"></a>00343 vec smpi; … … 331 328 <a name="l00352"></a>00352 } 332 329 <a name="l00353"></a>00353 333 <a name="l00361"></a><a class="code" href="classbdm_1_1mprod.html# abfa7478f8df1de6d8cd4c349db512831">00361</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mprod.html#abfa7478f8df1de6d8cd4c349db512831">from_setting</a> ( <span class="keyword">const</span> Setting &<span class="keyword">set</span> ) {330 <a name="l00361"></a><a class="code" href="classbdm_1_1mprod.html#bfa7478f8df1de6d8cd4c349db512831">00361</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mprod.html#bfa7478f8df1de6d8cd4c349db512831">from_setting</a> ( <span class="keyword">const</span> Setting &<span class="keyword">set</span> ) { 334 331 <a name="l00362"></a>00362 Array<shared_ptr<mpdf> > atmp; <span class="comment">//temporary Array</span> 335 <a name="l00363"></a>00363 <a class="code" href="classbdm_1_1UI.html# acd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> ( atmp, <span class="keyword">set</span>, <span class="stringliteral">"mpdfs"</span>, UI::compulsory );336 <a name="l00364"></a>00364 <a class="code" href="classbdm_1_1mprod.html#a acb4cd6d390ef73a4432d0c4993baffa" title="Set internal mpdfs from given values.">set_elements</a> ( atmp );332 <a name="l00363"></a>00363 <a class="code" href="classbdm_1_1UI.html#cd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> ( atmp, <span class="keyword">set</span>, <span class="stringliteral">"mpdfs"</span>, UI::compulsory ); 333 <a name="l00364"></a>00364 <a class="code" href="classbdm_1_1mprod.html#acb4cd6d390ef73a4432d0c4993baffa" title="Set internal mpdfs from given values.">set_elements</a> ( atmp ); 337 334 <a name="l00365"></a>00365 } 338 335 <a name="l00366"></a>00366 }; 339 <a name="l00367"></a>00367 <a class="code" href="user__info_8h.html# a4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a> ( mprod );336 <a name="l00367"></a>00367 <a class="code" href="user__info_8h.html#4f9de2f17e844047726487b99def99c6" title="Macro for registration of class into map of user-infos, registered class is scriptable...">UIREGISTER</a> ( mprod ); 340 337 <a name="l00368"></a>00368 SHAREDPTR ( mprod ); 341 338 <a name="l00369"></a>00369 342 339 <a name="l00371"></a><a class="code" href="classbdm_1_1eprod.html">00371</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1eprod.html" title="Product of independent epdfs. For dependent pdfs, use mprod.">eprod</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> { 343 340 <a name="l00372"></a>00372 <span class="keyword">protected</span>: 344 <a name="l00374"></a><a class="code" href="classbdm_1_1eprod.html# afa0b0981730f0a8339b9ff3e29d78391">00374</a> Array<const epdf*> <a class="code" href="classbdm_1_1eprod.html#afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>;345 <a name="l00376"></a><a class="code" href="classbdm_1_1eprod.html# a6b5a9be71a644f6009e7beda6c762a43">00376</a> Array<datalink*> <a class="code" href="classbdm_1_1eprod.html#a6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a>;341 <a name="l00374"></a><a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391">00374</a> Array<const epdf*> <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>; 342 <a name="l00376"></a><a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43">00376</a> Array<datalink*> <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a>; 346 343 <a name="l00377"></a>00377 <span class="keyword">public</span>: 347 <a name="l00379"></a><a class="code" href="classbdm_1_1eprod.html# a9bd36af548d5c350ebe62599aacf91ba">00379</a> <a class="code" href="classbdm_1_1eprod.html#a9bd36af548d5c350ebe62599aacf91ba" title="Default constructor.">eprod</a> () : <a class="code" href="classbdm_1_1eprod.html#afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( 0 ), <a class="code" href="classbdm_1_1eprod.html#a6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( 0 ) {};348 <a name="l00381"></a><a class="code" href="classbdm_1_1eprod.html# a7f0f526ddcd028c5edaecf250ef780f6">00381</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eprod.html#a7f0f526ddcd028c5edaecf250ef780f6" title="Set internal.">set_parameters</a> ( <span class="keyword">const</span> Array<const epdf*> &epdfs0, <span class="keywordtype">bool</span> named = <span class="keyword">true</span> ) {349 <a name="l00382"></a>00382 <a class="code" href="classbdm_1_1eprod.html# afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> = epdfs0;<span class="comment">//.set_length ( epdfs0.length() );</span>350 <a name="l00383"></a>00383 <a class="code" href="classbdm_1_1eprod.html# a6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a>.set_length ( <a class="code" href="classbdm_1_1eprod.html#afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length() );344 <a name="l00379"></a><a class="code" href="classbdm_1_1eprod.html#9bd36af548d5c350ebe62599aacf91ba">00379</a> <a class="code" href="classbdm_1_1eprod.html#9bd36af548d5c350ebe62599aacf91ba" title="Default constructor.">eprod</a> () : <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( 0 ), <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( 0 ) {}; 345 <a name="l00381"></a><a class="code" href="classbdm_1_1eprod.html#7f0f526ddcd028c5edaecf250ef780f6">00381</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1eprod.html#7f0f526ddcd028c5edaecf250ef780f6" title="Set internal.">set_parameters</a> ( <span class="keyword">const</span> Array<const epdf*> &epdfs0, <span class="keywordtype">bool</span> named = <span class="keyword">true</span> ) { 346 <a name="l00382"></a>00382 <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> = epdfs0;<span class="comment">//.set_length ( epdfs0.length() );</span> 347 <a name="l00383"></a>00383 <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a>.set_length ( <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length() ); 351 348 <a name="l00384"></a>00384 352 349 <a name="l00385"></a>00385 <span class="keywordtype">bool</span> independent = <span class="keyword">true</span>; 353 350 <a name="l00386"></a>00386 <span class="keywordflow">if</span> ( named ) { 354 <a name="l00387"></a>00387 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1eprod.html# afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length(); i++ ) {355 <a name="l00388"></a>00388 independent = <a class="code" href="classbdm_1_1epdf.html# a62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#a87841b5ee43997b79789c0c22047e224" title="Add (concat) another variable to the current one,.">add</a> ( <a class="code" href="classbdm_1_1eprod.html#afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )-><a class="code" href="classbdm_1_1epdf.html#aa4ab378d5e004c3ff3e2d4e64f7bba21" title="Return name (fails when isnamed is false).">_rv</a>() );356 <a name="l00389"></a>00389 <a class="code" href="bdmerror_8h.html# a89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</a> ( independent, <span class="stringliteral">"eprod:: given components are not independent."</span> );351 <a name="l00387"></a>00387 <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++ ) { 352 <a name="l00388"></a>00388 independent = <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description 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="Return name (fails when isnamed is false).">_rv</a>() ); 353 <a name="l00389"></a>00389 <a class="code" href="bdmerror_8h.html#89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</a> ( independent, <span class="stringliteral">"eprod:: given components are not independent."</span> ); 357 354 <a name="l00390"></a>00390 } 358 <a name="l00391"></a>00391 <a class="code" href="classbdm_1_1epdf.html# a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = <a class="code" href="classbdm_1_1epdf.html#a62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>();355 <a name="l00391"></a>00391 <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>(); 359 356 <a name="l00392"></a>00392 } <span class="keywordflow">else</span> { 360 <a name="l00393"></a>00393 <a class="code" href="classbdm_1_1epdf.html# a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = 0;361 <a name="l00394"></a>00394 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1eprod.html# afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length(); i++ ) {362 <a name="l00395"></a>00395 <a class="code" href="classbdm_1_1epdf.html# a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> += <a class="code" href="classbdm_1_1eprod.html#afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->dimension();357 <a name="l00393"></a>00393 <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = 0; 358 <a name="l00394"></a>00394 <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++ ) { 359 <a name="l00395"></a>00395 <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> += <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->dimension(); 363 360 <a name="l00396"></a>00396 } 364 361 <a name="l00397"></a>00397 } … … 367 364 <a name="l00400"></a>00400 <span class="keywordtype">int</span> dimi = 0; 368 365 <a name="l00401"></a>00401 <span class="keywordtype">int</span> i; 369 <a name="l00402"></a>00402 <span class="keywordflow">for</span> ( i = 0; i < <a class="code" href="classbdm_1_1eprod.html# afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length(); i++ ) {370 <a name="l00403"></a>00403 <a class="code" href="classbdm_1_1eprod.html# a6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i ) = <span class="keyword">new</span> <a class="code" href="classbdm_1_1datalink.html" title="DataLink is a connection between two data vectors Up and Down.">datalink</a>;366 <a name="l00402"></a>00402 <span class="keywordflow">for</span> ( i = 0; i < <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length(); i++ ) { 367 <a name="l00403"></a>00403 <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i ) = <span class="keyword">new</span> <a class="code" href="classbdm_1_1datalink.html" title="DataLink is a connection between two data vectors Up and Down.">datalink</a>; 371 368 <a name="l00404"></a>00404 <span class="keywordflow">if</span> ( named ) { 372 <a name="l00405"></a>00405 <a class="code" href="classbdm_1_1eprod.html# a6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->set_connection ( <a class="code" href="classbdm_1_1eprod.html#afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )-><a class="code" href="classbdm_1_1epdf.html#aa4ab378d5e004c3ff3e2d4e64f7bba21" title="Return name (fails when isnamed is false).">_rv</a>() , <a class="code" href="classbdm_1_1epdf.html#a62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> );369 <a name="l00405"></a>00405 <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->set_connection ( <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="Return name (fails when isnamed is false).">_rv</a>() , <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> ); 373 370 <a name="l00406"></a>00406 } <span class="keywordflow">else</span> { 374 <a name="l00407"></a>00407 dimi = <a class="code" href="classbdm_1_1eprod.html# afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->dimension();375 <a name="l00408"></a>00408 <a class="code" href="classbdm_1_1eprod.html# a6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->set_connection ( dimi, <a class="code" href="classbdm_1_1epdf.html#a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>, linspace ( cumdim, cumdim + dimi - 1 ) );371 <a name="l00407"></a>00407 dimi = <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->dimension(); 372 <a name="l00408"></a>00408 <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->set_connection ( dimi, <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>, linspace ( cumdim, cumdim + dimi - 1 ) ); 376 373 <a name="l00409"></a>00409 cumdim += dimi; 377 374 <a name="l00410"></a>00410 } … … 379 376 <a name="l00412"></a>00412 } 380 377 <a name="l00413"></a>00413 381 <a name="l00414"></a><a class="code" href="classbdm_1_1eprod.html# a1d494351e7e385ad3382387c96915d24">00414</a> vec <a class="code" href="classbdm_1_1eprod.html#a1d494351e7e385ad3382387c96915d24" title="return expected value">mean</a>()<span class="keyword"> const </span>{382 <a name="l00415"></a>00415 vec tmp ( <a class="code" href="classbdm_1_1epdf.html# a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> );383 <a name="l00416"></a>00416 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1eprod.html# afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length(); i++ ) {384 <a name="l00417"></a>00417 vec pom = <a class="code" href="classbdm_1_1eprod.html# afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->mean();385 <a name="l00418"></a>00418 <a class="code" href="classbdm_1_1eprod.html# a6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->pushup ( tmp, pom );378 <a name="l00414"></a><a class="code" href="classbdm_1_1eprod.html#1d494351e7e385ad3382387c96915d24">00414</a> vec <a class="code" href="classbdm_1_1eprod.html#1d494351e7e385ad3382387c96915d24" title="return expected value">mean</a>()<span class="keyword"> const </span>{ 379 <a name="l00415"></a>00415 vec tmp ( <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> ); 380 <a name="l00416"></a>00416 <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++ ) { 381 <a name="l00417"></a>00417 vec pom = <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->mean(); 382 <a name="l00418"></a>00418 <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->pushup ( tmp, pom ); 386 383 <a name="l00419"></a>00419 } 387 384 <a name="l00420"></a>00420 <span class="keywordflow">return</span> tmp; 388 385 <a name="l00421"></a>00421 } 389 <a name="l00422"></a><a class="code" href="classbdm_1_1eprod.html# acc53a151f5ac5dfba68d425acc3a5615">00422</a> vec <a class="code" href="classbdm_1_1eprod.html#acc53a151f5ac5dfba68d425acc3a5615" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{390 <a name="l00423"></a>00423 vec tmp ( <a class="code" href="classbdm_1_1epdf.html# a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> ); <span class="comment">//second moment</span>391 <a name="l00424"></a>00424 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1eprod.html# afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length(); i++ ) {392 <a name="l00425"></a>00425 vec pom = <a class="code" href="classbdm_1_1eprod.html# afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->mean();393 <a name="l00426"></a>00426 <a class="code" href="classbdm_1_1eprod.html# a6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->pushup ( tmp, pow ( pom, 2 ) );386 <a name="l00422"></a><a class="code" href="classbdm_1_1eprod.html#cc53a151f5ac5dfba68d425acc3a5615">00422</a> vec <a class="code" href="classbdm_1_1eprod.html#cc53a151f5ac5dfba68d425acc3a5615" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{ 387 <a name="l00423"></a>00423 vec tmp ( <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> ); <span class="comment">//second moment</span> 388 <a name="l00424"></a>00424 <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++ ) { 389 <a name="l00425"></a>00425 vec pom = <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->mean(); 390 <a name="l00426"></a>00426 <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->pushup ( tmp, pow ( pom, 2 ) ); 394 391 <a name="l00427"></a>00427 } 395 <a name="l00428"></a>00428 <span class="keywordflow">return</span> tmp - pow ( <a class="code" href="classbdm_1_1eprod.html# a1d494351e7e385ad3382387c96915d24" title="return expected value">mean</a>(), 2 );392 <a name="l00428"></a>00428 <span class="keywordflow">return</span> tmp - pow ( <a class="code" href="classbdm_1_1eprod.html#1d494351e7e385ad3382387c96915d24" title="return expected value">mean</a>(), 2 ); 396 393 <a name="l00429"></a>00429 } 397 <a name="l00430"></a><a class="code" href="classbdm_1_1eprod.html#a af48debea25d3473bcb71b6a77fac741">00430</a> vec <a class="code" href="classbdm_1_1eprod.html#aaf48debea25d3473bcb71b6a77fac741" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{398 <a name="l00431"></a>00431 vec tmp ( <a class="code" href="classbdm_1_1epdf.html# a16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> );399 <a name="l00432"></a>00432 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1eprod.html# afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length(); i++ ) {400 <a name="l00433"></a>00433 vec pom = <a class="code" href="classbdm_1_1eprod.html# afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->sample();401 <a name="l00434"></a>00434 <a class="code" href="classbdm_1_1eprod.html# a6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->pushup ( tmp, pom );394 <a name="l00430"></a><a class="code" href="classbdm_1_1eprod.html#af48debea25d3473bcb71b6a77fac741">00430</a> vec <a class="code" href="classbdm_1_1eprod.html#af48debea25d3473bcb71b6a77fac741" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{ 395 <a name="l00431"></a>00431 vec tmp ( <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> ); 396 <a name="l00432"></a>00432 <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++ ) { 397 <a name="l00433"></a>00433 vec pom = <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->sample(); 398 <a name="l00434"></a>00434 <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->pushup ( tmp, pom ); 402 399 <a name="l00435"></a>00435 } 403 400 <a name="l00436"></a>00436 <span class="keywordflow">return</span> tmp; 404 401 <a name="l00437"></a>00437 } 405 <a name="l00438"></a><a class="code" href="classbdm_1_1eprod.html#a a5a91e67d2f74ff2b0b8eecde2fa42e2">00438</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eprod.html#aa5a91e67d2f74ff2b0b8eecde2fa42e2" title="Compute log-probability of argument val In case the argument is out of suport return...">evallog</a> ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{402 <a name="l00438"></a><a class="code" href="classbdm_1_1eprod.html#a5a91e67d2f74ff2b0b8eecde2fa42e2">00438</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eprod.html#a5a91e67d2f74ff2b0b8eecde2fa42e2" title="Compute log-probability of argument val In case the argument is out of suport return...">evallog</a> ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{ 406 403 <a name="l00439"></a>00439 <span class="keywordtype">double</span> tmp = 0; 407 <a name="l00440"></a>00440 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1eprod.html# afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length(); i++ ) {408 <a name="l00441"></a>00441 tmp += <a class="code" href="classbdm_1_1eprod.html# afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->evallog ( <a class="code" href="classbdm_1_1eprod.html#a6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->pushdown ( val ) );404 <a name="l00440"></a>00440 <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++ ) { 405 <a name="l00441"></a>00441 tmp += <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->evallog ( <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->pushdown ( val ) ); 409 406 <a name="l00442"></a>00442 } 410 <a name="l00443"></a>00443 <a class="code" href="bdmerror_8h.html# a89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</a> ( std::isfinite ( tmp ), <span class="stringliteral">"Infinite"</span> );407 <a name="l00443"></a>00443 <a class="code" href="bdmerror_8h.html#89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</a> ( std::isfinite ( tmp ), <span class="stringliteral">"Infinite"</span> ); 411 408 <a name="l00444"></a>00444 <span class="keywordflow">return</span> tmp; 412 409 <a name="l00445"></a>00445 } 413 <a name="l00447"></a><a class="code" href="classbdm_1_1eprod.html# a5194b47dd05a5886e0745250b6704953">00447</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_1eprod.html#a5194b47dd05a5886e0745250b6704953" title="access function">operator () </a>( <span class="keywordtype">int</span> i )<span class="keyword"> const </span>{414 <a name="l00448"></a>00448 <a class="code" href="bdmerror_8h.html# a89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</a> ( i < <a class="code" href="classbdm_1_1eprod.html#afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length(), <span class="stringliteral">"wrong index"</span> );415 <a name="l00449"></a>00449 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eprod.html# afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i );410 <a name="l00447"></a><a class="code" href="classbdm_1_1eprod.html#5194b47dd05a5886e0745250b6704953">00447</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_1eprod.html#5194b47dd05a5886e0745250b6704953" title="access function">operator () </a>( <span class="keywordtype">int</span> i )<span class="keyword"> const </span>{ 411 <a name="l00448"></a>00448 <a class="code" href="bdmerror_8h.html#89a0f906b242b79c5d3d342291b2cab4" title="Throw std::runtime_exception if t is not true and NDEBUG is not defined.">bdm_assert_debug</a> ( i < <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length(), <span class="stringliteral">"wrong index"</span> ); 412 <a name="l00449"></a>00449 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i ); 416 413 <a name="l00450"></a>00450 } 417 414 <a name="l00451"></a>00451 418 <a name="l00453"></a><a class="code" href="classbdm_1_1eprod.html# a708b37971aab3667f20e325c358632cf">00453</a> <a class="code" href="classbdm_1_1eprod.html#a708b37971aab3667f20e325c358632cf" title="Destructor.">~eprod</a>() {419 <a name="l00454"></a>00454 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1eprod.html# afa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length(); i++ ) {420 <a name="l00455"></a>00455 <span class="keyword">delete</span> <a class="code" href="classbdm_1_1eprod.html# a6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i );415 <a name="l00453"></a><a class="code" href="classbdm_1_1eprod.html#708b37971aab3667f20e325c358632cf">00453</a> <a class="code" href="classbdm_1_1eprod.html#708b37971aab3667f20e325c358632cf" title="Destructor.">~eprod</a>() { 416 <a name="l00454"></a>00454 <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++ ) { 417 <a name="l00455"></a>00455 <span class="keyword">delete</span> <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i ); 421 418 <a name="l00456"></a>00456 } 422 419 <a name="l00457"></a>00457 } … … 426 423 <a name="l00464"></a><a class="code" href="classbdm_1_1mmix.html">00464</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mmix.html" title="Mixture of mpdfs with constant weights, all mpdfs are of equal RV and RVC.">mmix</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling , where is random variable, rv, and...">mpdf</a> { 427 424 <a name="l00465"></a>00465 <span class="keyword">protected</span>: 428 <a name="l00467"></a><a class="code" href="classbdm_1_1mmix.html# a63013f8c57dfb51babc3be7fc5d05809">00467</a> Array<shared_ptr<mpdf> > <a class="code" href="classbdm_1_1mmix.html#a63013f8c57dfb51babc3be7fc5d05809" title="Component (mpdfs).">Coms</a>;429 <a name="l00469"></a><a class="code" href="classbdm_1_1mmix.html# af23a22414419b3a4a0a7d97157a03b17">00469</a> vec <a class="code" href="classbdm_1_1mmix.html#af23a22414419b3a4a0a7d97157a03b17" title="weights of the components">w</a>;430 <a name="l00471"></a><a class="code" href="classbdm_1_1mmix.html# a8c740fff8807cb7f1df6a7e510e10805">00471</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_1mmix.html#a8c740fff8807cb7f1df6a7e510e10805" title="dummy epdfs">dummy_epdf</a>;425 <a name="l00467"></a><a class="code" href="classbdm_1_1mmix.html#63013f8c57dfb51babc3be7fc5d05809">00467</a> Array<shared_ptr<mpdf> > <a class="code" href="classbdm_1_1mmix.html#63013f8c57dfb51babc3be7fc5d05809" title="Component (mpdfs).">Coms</a>; 426 <a name="l00469"></a><a class="code" href="classbdm_1_1mmix.html#f23a22414419b3a4a0a7d97157a03b17">00469</a> vec <a class="code" href="classbdm_1_1mmix.html#f23a22414419b3a4a0a7d97157a03b17" title="weights of the components">w</a>; 427 <a name="l00471"></a><a class="code" href="classbdm_1_1mmix.html#8c740fff8807cb7f1df6a7e510e10805">00471</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_1mmix.html#8c740fff8807cb7f1df6a7e510e10805" title="dummy epdfs">dummy_epdf</a>; 431 428 <a name="l00472"></a>00472 <span class="keyword">public</span>: 432 <a name="l00474"></a><a class="code" href="classbdm_1_1mmix.html#a a0cf51b7daeb6751103e94e6b96213fb">00474</a> <a class="code" href="classbdm_1_1mmix.html#aa0cf51b7daeb6751103e94e6b96213fb" title="Default constructor.">mmix</a>() : <a class="code" href="classbdm_1_1mmix.html#a63013f8c57dfb51babc3be7fc5d05809" title="Component (mpdfs).">Coms</a>(0), <a class="code" href="classbdm_1_1mmix.html#a8c740fff8807cb7f1df6a7e510e10805" title="dummy epdfs">dummy_epdf</a>() { <a class="code" href="classbdm_1_1mpdf.html#a147afacb393324bb3f9a7a89e33f835e" title="set internal pointer ep to point to given iepdf ">set_ep</a>(<a class="code" href="classbdm_1_1mmix.html#a8c740fff8807cb7f1df6a7e510e10805" title="dummy epdfs">dummy_epdf</a>); }429 <a name="l00474"></a><a class="code" href="classbdm_1_1mmix.html#a0cf51b7daeb6751103e94e6b96213fb">00474</a> <a class="code" href="classbdm_1_1mmix.html#a0cf51b7daeb6751103e94e6b96213fb" title="Default constructor.">mmix</a>() : <a class="code" href="classbdm_1_1mmix.html#63013f8c57dfb51babc3be7fc5d05809" title="Component (mpdfs).">Coms</a>(0), <a class="code" href="classbdm_1_1mmix.html#8c740fff8807cb7f1df6a7e510e10805" title="dummy epdfs">dummy_epdf</a>() { <a class="code" href="classbdm_1_1mpdf.html#147afacb393324bb3f9a7a89e33f835e" title="set internal pointer ep to point to given iepdf ">set_ep</a>(<a class="code" href="classbdm_1_1mmix.html#8c740fff8807cb7f1df6a7e510e10805" title="dummy epdfs">dummy_epdf</a>); } 433 430 <a name="l00475"></a>00475 434 <a name="l00477"></a><a class="code" href="classbdm_1_1mmix.html# a77f4e69ba18e685bdd1cb92e256a2ea2">00477</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mmix.html#a77f4e69ba18e685bdd1cb92e256a2ea2" title="Set weights w and components R.">set_parameters</a> ( <span class="keyword">const</span> vec &w0, <span class="keyword">const</span> Array<<a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<mpdf></a> > &Coms0 ) {435 <a name="l00479"></a>00479 <a class="code" href="classbdm_1_1mmix.html# a63013f8c57dfb51babc3be7fc5d05809" title="Component (mpdfs).">Coms</a> = Coms0;436 <a name="l00480"></a>00480 <a class="code" href="classbdm_1_1mmix.html# af23a22414419b3a4a0a7d97157a03b17" title="weights of the components">w</a>=w0;431 <a name="l00477"></a><a class="code" href="classbdm_1_1mmix.html#77f4e69ba18e685bdd1cb92e256a2ea2">00477</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mmix.html#77f4e69ba18e685bdd1cb92e256a2ea2" title="Set weights w and components R.">set_parameters</a> ( <span class="keyword">const</span> vec &w0, <span class="keyword">const</span> Array<<a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<mpdf></a> > &Coms0 ) { 432 <a name="l00479"></a>00479 <a class="code" href="classbdm_1_1mmix.html#63013f8c57dfb51babc3be7fc5d05809" title="Component (mpdfs).">Coms</a> = Coms0; 433 <a name="l00480"></a>00480 <a class="code" href="classbdm_1_1mmix.html#f23a22414419b3a4a0a7d97157a03b17" title="weights of the components">w</a>=w0; 437 434 <a name="l00481"></a>00481 438 435 <a name="l00482"></a>00482 <span class="keywordflow">if</span> (Coms0.length()>0){ 439 <a name="l00483"></a>00483 set_rv(<a class="code" href="classbdm_1_1mmix.html# a63013f8c57dfb51babc3be7fc5d05809" title="Component (mpdfs).">Coms</a>(0)->_rv());440 <a name="l00484"></a>00484 <a class="code" href="classbdm_1_1mmix.html# a8c740fff8807cb7f1df6a7e510e10805" title="dummy epdfs">dummy_epdf</a>.set_parameters(<a class="code" href="classbdm_1_1mmix.html#a63013f8c57dfb51babc3be7fc5d05809" title="Component (mpdfs).">Coms</a>(0)->_rv()._dsize());441 <a name="l00485"></a>00485 set_rvc(<a class="code" href="classbdm_1_1mmix.html# a63013f8c57dfb51babc3be7fc5d05809" title="Component (mpdfs).">Coms</a>(0)->_rvc());442 <a name="l00486"></a>00486 <a class="code" href="classbdm_1_1mpdf.html# a7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</a> = <a class="code" href="classbdm_1_1mpdf.html#a5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a>.<a class="code" href="classbdm_1_1RV.html#ade30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>();436 <a name="l00483"></a>00483 set_rv(<a class="code" href="classbdm_1_1mmix.html#63013f8c57dfb51babc3be7fc5d05809" title="Component (mpdfs).">Coms</a>(0)->_rv()); 437 <a name="l00484"></a>00484 <a class="code" href="classbdm_1_1mmix.html#8c740fff8807cb7f1df6a7e510e10805" title="dummy epdfs">dummy_epdf</a>.set_parameters(<a class="code" href="classbdm_1_1mmix.html#63013f8c57dfb51babc3be7fc5d05809" title="Component (mpdfs).">Coms</a>(0)->_rv()._dsize()); 438 <a name="l00485"></a>00485 set_rvc(<a class="code" href="classbdm_1_1mmix.html#63013f8c57dfb51babc3be7fc5d05809" title="Component (mpdfs).">Coms</a>(0)->_rvc()); 439 <a name="l00486"></a>00486 <a class="code" href="classbdm_1_1mpdf.html#7c1900976ff13dbc09c9729b3bbff9e6" title="dimension of the condition">dimc</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#de30156104f61d86c94f758861418089" title="total size of a random variable">_dsize</a>(); 443 440 <a name="l00487"></a>00487 } 444 441 <a name="l00488"></a>00488 } 445 <a name="l00489"></a><a class="code" href="classbdm_1_1mmix.html# a33372bfd0ddbcb9f78b4d4b563a24624">00489</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mmix.html#a33372bfd0ddbcb9f78b4d4b563a24624" title="Shortcut for conditioning and evaluation of the internal epdf. In some cases, this...">evallogcond</a> (<span class="keyword">const</span> vec &dt, <span class="keyword">const</span> vec &cond) {442 <a name="l00489"></a><a class="code" href="classbdm_1_1mmix.html#33372bfd0ddbcb9f78b4d4b563a24624">00489</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mmix.html#33372bfd0ddbcb9f78b4d4b563a24624" title="Shortcut for conditioning and evaluation of the internal epdf. In some cases, this...">evallogcond</a> (<span class="keyword">const</span> vec &dt, <span class="keyword">const</span> vec &cond) { 446 443 <a name="l00490"></a>00490 <span class="keywordtype">double</span> ll=0.0; 447 <a name="l00491"></a>00491 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1mmix.html# a63013f8c57dfb51babc3be7fc5d05809" title="Component (mpdfs).">Coms</a>.length();i++){448 <a name="l00492"></a>00492 ll+=<a class="code" href="classbdm_1_1mmix.html# a63013f8c57dfb51babc3be7fc5d05809" title="Component (mpdfs).">Coms</a>(i)->evallogcond(dt,cond);444 <a name="l00491"></a>00491 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1mmix.html#63013f8c57dfb51babc3be7fc5d05809" title="Component (mpdfs).">Coms</a>.length();i++){ 445 <a name="l00492"></a>00492 ll+=<a class="code" href="classbdm_1_1mmix.html#63013f8c57dfb51babc3be7fc5d05809" title="Component (mpdfs).">Coms</a>(i)->evallogcond(dt,cond); 449 446 <a name="l00493"></a>00493 } 450 447 <a name="l00494"></a>00494 <span class="keywordflow">return</span> ll; 451 448 <a name="l00495"></a>00495 } 452 449 <a name="l00496"></a>00496 453 <a name="l00497"></a>00497 vec <a class="code" href="classbdm_1_1mmix.html# ac97f01cd62bf63e67ddd5b1b8a56cf59" title="Returns a sample from the density conditioned on cond, .">samplecond</a> (<span class="keyword">const</span> vec &cond);450 <a name="l00497"></a>00497 vec <a class="code" href="classbdm_1_1mmix.html#c97f01cd62bf63e67ddd5b1b8a56cf59" title="Returns a sample from the density conditioned on cond, .">samplecond</a> (<span class="keyword">const</span> vec &cond); 454 451 <a name="l00498"></a>00498 455 452 <a name="l00499"></a>00499 }; … … 458 455 <a name="l00502"></a>00502 <span class="preprocessor">#endif //MX_H</span> 459 456 </pre></div></div> 460 <hr size="1" /><address style="text-align: right;"><small>Generated on Sun Sep 27 00:49:042009 for mixpp by 457 <hr size="1"><address style="text-align: right;"><small>Generated on Wed Oct 7 17:34:43 2009 for mixpp by 461 458 <a href="http://www.doxygen.org/index.html"> 462 <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1</small></address>459 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address> 463 460 </body> 464 461 </html>