Show
Ignore:
Timestamp:
02/16/09 10:02:08 (16 years ago)
Author:
smidl
Message:

Changes in the very root classes!
* rv and rvc are no longer compulsory,
* samplecond does not return ll
* BM has drv

Files:
1 modified

Legend:

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

    r269 r270  
    4141<a name="l00048"></a>00048 <span class="keyword">public</span>: 
    4242<a name="l00050"></a><a class="code" href="classbdm_1_1merger.html#30ae0fa8a88737185f598bf63fec0569">00050</a>         <a class="code" href="classbdm_1_1merger.html#30ae0fa8a88737185f598bf63fec0569" title="Default constructor.">merger</a> ( <span class="keyword">const</span> Array&lt;mpdf*&gt; &amp;S ) : 
    43 <a name="l00051"></a>00051                         <a class="code" href="classbdm_1_1compositepdf.html" title="Abstract composition of pdfs, will be used for specific classes this abstract class...">compositepdf</a> ( S ), <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_1compositepdf.html#c73d39acc4378eee6a63155c3517d3c9" title="find common rv, flag">getrv</a> ( false ) ), 
    44 <a name="l00052"></a>00052                         <a class="code" href="classbdm_1_1merger.html#67ae71cbf0686d7c7bf116fa5db86d81" title="Internal mixture of EF models.">Mix</a> ( Array&lt;<a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a>*&gt; ( 0 ),vec ( 0 ) ), <a class="code" href="classbdm_1_1merger.html#ea3c9f4739f857877fd5285b3973289c" title="Data link for each mpdf in mpdfs.">dls</a> ( <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a> ), <a class="code" href="classbdm_1_1merger.html#135b938f841cb88ad00a8bbded818703" title="Array of rvs that are not modelled by mpdfs at all (aux).">rvzs</a> ( <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a> ), <a class="code" href="classbdm_1_1merger.html#6c48bf36ec1f3f7b52e3159cf428a193" title="Data Links of rv0 mpdfs - these will be conditioned the (rv,rvc) of mpdfs.">zdls</a> ( <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a> ), <a class="code" href="classbdm_1_1merger.html#522d43f7aa13fe6701e93fba174dec94" title="Projection to empirical density.">eSmp</a>(<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a>,0) { 
     43<a name="l00051"></a>00051                         <a class="code" href="classbdm_1_1compositepdf.html" title="Abstract composition of pdfs, will be used for specific classes this abstract class...">compositepdf</a> ( S ), <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( ), 
     44<a name="l00052"></a>00052                         <a class="code" href="classbdm_1_1merger.html#67ae71cbf0686d7c7bf116fa5db86d81" title="Internal mixture of EF models.">Mix</a> ( Array&lt;<a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a>*&gt; ( 0 ),vec ( 0 ) ), <a class="code" href="classbdm_1_1merger.html#ea3c9f4739f857877fd5285b3973289c" title="Data link for each mpdf in mpdfs.">dls</a> ( <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a> ), <a class="code" href="classbdm_1_1merger.html#135b938f841cb88ad00a8bbded818703" title="Array of rvs that are not modelled by mpdfs at all (aux).">rvzs</a> ( <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a> ), <a class="code" href="classbdm_1_1merger.html#6c48bf36ec1f3f7b52e3159cf428a193" title="Data Links of rv0 mpdfs - these will be conditioned the (rv,rvc) of mpdfs.">zdls</a> ( <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a> ), <a class="code" href="classbdm_1_1merger.html#522d43f7aa13fe6701e93fba174dec94" title="Projection to empirical density.">eSmp</a>(0) { 
    4545<a name="l00053"></a>00053                 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> ztmp; 
    4646<a name="l00054"></a>00054                 <span class="comment">// Extend rv by rvc!</span> 
    47 <a name="l00055"></a>00055                 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> rvc; <a class="code" href="classbdm_1_1compositepdf.html#c71fc2c51f49d797e61f479f543c75ce" title="common rvc of all mpdfs is written to rvc">setrvc</a> ( <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a>,rvc ); 
    48 <a name="l00056"></a>00056                 <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#87841b5ee43997b79789c0c22047e224" title="Add (concat) another variable to the current one,.">add</a> ( rvc ); 
     47<a name="l00055"></a>00055                 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> rvc; <a class="code" href="classbdm_1_1compositepdf.html#c71fc2c51f49d797e61f479f543c75ce" title="common rvc of all mpdfs is written to rvc">setrvc</a> ( <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>,rvc ); 
     48<a name="l00056"></a>00056                 <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> ( rvc ); 
    4949<a name="l00057"></a>00057                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i&lt;<a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a>;i++ ) { 
    5050<a name="l00058"></a>00058                         <span class="comment">//Establich connection between mpdfs and merger</span> 
    51 <a name="l00059"></a>00059                         <a class="code" href="classbdm_1_1merger.html#ea3c9f4739f857877fd5285b3973289c" title="Data link for each mpdf in mpdfs.">dls</a> ( i ) = <span class="keyword">new</span> <a class="code" href="classbdm_1_1datalink__m2e.html" title="data link between">datalink_m2e</a> ( <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )-&gt;<a class="code" href="classbdm_1_1epdf.html#a4ab378d5e004c3ff3e2d4e64f7bba21" title="access function, possibly dangerous!">_rv</a>(), <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )-&gt;_rvc(), <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a> ); 
     51<a name="l00059"></a>00059                         <a class="code" href="classbdm_1_1merger.html#ea3c9f4739f857877fd5285b3973289c" title="Data link for each mpdf in mpdfs.">dls</a> ( i ) = <span class="keyword">new</span> <a class="code" href="classbdm_1_1datalink__m2e.html" title="data link between">datalink_m2e</a> ( <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )-&gt;<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_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )-&gt;_rvc(), <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> ); 
    5252<a name="l00060"></a>00060                         <span class="comment">// find out what is missing in each mpdf</span> 
    5353<a name="l00061"></a>00061                         ztmp= <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )-&gt;_rv(); 
    5454<a name="l00062"></a>00062                         ztmp.<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_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )-&gt;_rvc() ); 
    55 <a name="l00063"></a>00063                         <a class="code" href="classbdm_1_1merger.html#135b938f841cb88ad00a8bbded818703" title="Array of rvs that are not modelled by mpdfs at all (aux).">rvzs</a> ( i ) =<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#aec44dabdf0a6d90fbae95e1356eda39" title="Subtract another variable from the current one.">subt</a> ( ztmp ); 
    56 <a name="l00064"></a>00064                         <a class="code" href="classbdm_1_1merger.html#6c48bf36ec1f3f7b52e3159cf428a193" title="Data Links of rv0 mpdfs - these will be conditioned the (rv,rvc) of mpdfs.">zdls</a> ( i ) = <span class="keyword">new</span> <a class="code" href="classbdm_1_1datalink__m2e.html" title="data link between">datalink_m2e</a> ( <a class="code" href="classbdm_1_1merger.html#135b938f841cb88ad00a8bbded818703" title="Array of rvs that are not modelled by mpdfs at all (aux).">rvzs</a> ( i ), ztmp, <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a> ) ; 
     55<a name="l00063"></a>00063                         <a class="code" href="classbdm_1_1merger.html#135b938f841cb88ad00a8bbded818703" title="Array of rvs that are not modelled by mpdfs at all (aux).">rvzs</a> ( i ) =<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#aec44dabdf0a6d90fbae95e1356eda39" title="Subtract another variable from the current one.">subt</a> ( ztmp ); 
     56<a name="l00064"></a>00064                         <a class="code" href="classbdm_1_1merger.html#6c48bf36ec1f3f7b52e3159cf428a193" title="Data Links of rv0 mpdfs - these will be conditioned the (rv,rvc) of mpdfs.">zdls</a> ( i ) = <span class="keyword">new</span> <a class="code" href="classbdm_1_1datalink__m2e.html" title="data link between">datalink_m2e</a> ( <a class="code" href="classbdm_1_1merger.html#135b938f841cb88ad00a8bbded818703" title="Array of rvs that are not modelled by mpdfs at all (aux).">rvzs</a> ( i ), ztmp, <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> ) ; 
    5757<a name="l00065"></a>00065                 }; 
    5858<a name="l00066"></a>00066                 <span class="comment">//Set Default values of parameters</span> 
     
    6969<a name="l00079"></a>00079         } 
    7070<a name="l00081"></a>00081         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger.html#b72f4662c9ac760a8b17ebe5d697f3c2" title="Create a mixture density, make sure to call init() before the first call.">merge</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>* g0 ); 
    71 <a name="l00083"></a><a class="code" href="classbdm_1_1merger.html#b72f4662c9ac760a8b17ebe5d697f3c2">00083</a>         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger.html#b72f4662c9ac760a8b17ebe5d697f3c2" title="Create a mixture density, make sure to call init() before the first call.">merge</a> () {<a class="code" href="classbdm_1_1merger.html#b72f4662c9ac760a8b17ebe5d697f3c2" title="Create a mixture density, make sure to call init() before the first call.">merge</a> ( &amp; ( <a class="code" href="classbdm_1_1merger.html#67ae71cbf0686d7c7bf116fa5db86d81" title="Internal mixture of EF models.">Mix</a>.<a class="code" href="classbdm_1_1MixEF.html#33d0b3da1d10bf149d41ee74f6284a19" title="Returns a reference to the epdf representing posterior density on parameters.">_epdf</a>() ) );}; 
     71<a name="l00083"></a><a class="code" href="classbdm_1_1merger.html#b72f4662c9ac760a8b17ebe5d697f3c2">00083</a>         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger.html#b72f4662c9ac760a8b17ebe5d697f3c2" title="Create a mixture density, make sure to call init() before the first call.">merge</a> () {<a class="code" href="classbdm_1_1merger.html#b72f4662c9ac760a8b17ebe5d697f3c2" title="Create a mixture density, make sure to call init() before the first call.">merge</a> ( &amp; ( <a class="code" href="classbdm_1_1merger.html#67ae71cbf0686d7c7bf116fa5db86d81" title="Internal mixture of EF models.">Mix</a>.<a class="code" href="classbdm_1_1MixEF.html#33d0b3da1d10bf149d41ee74f6284a19">_epdf</a>() ) );}; 
    7272<a name="l00084"></a>00084  
    7373<a name="l00086"></a>00086         vec <a class="code" href="classbdm_1_1merger.html#b90f1b8a21a693176dd953a3b983aa0b" title="Merge log-likelihood values.">lognorm_merge</a> ( mat &amp;lW ); 
    74 <a name="l00089"></a><a class="code" href="classbdm_1_1merger.html#0ef73e76eeee44c8e3896e3a271ad974">00089</a>         vec <a class="code" href="classbdm_1_1merger.html#0ef73e76eeee44c8e3896e3a271ad974">sample</a> ( )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1merger.html#67ae71cbf0686d7c7bf116fa5db86d81" title="Internal mixture of EF models.">Mix</a>.<a class="code" href="classbdm_1_1MixEF.html#33d0b3da1d10bf149d41ee74f6284a19" title="Returns a reference to the epdf representing posterior density on parameters.">_epdf</a>().<a class="code" href="classbdm_1_1epdf.html#09721eb148bc49d6ec2f1956039f3a10" title="Returns a sample,  from density .">sample</a>();} 
     74<a name="l00089"></a><a class="code" href="classbdm_1_1merger.html#0ef73e76eeee44c8e3896e3a271ad974">00089</a>         vec <a class="code" href="classbdm_1_1merger.html#0ef73e76eeee44c8e3896e3a271ad974">sample</a> ( )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1merger.html#67ae71cbf0686d7c7bf116fa5db86d81" title="Internal mixture of EF models.">Mix</a>.<a class="code" href="classbdm_1_1MixEF.html#33d0b3da1d10bf149d41ee74f6284a19">_epdf</a>().<a class="code" href="classbdm_1_1epdf.html#09721eb148bc49d6ec2f1956039f3a10" title="Returns a sample,  from density .">sample</a>();} 
    7575<a name="l00090"></a><a class="code" href="classbdm_1_1merger.html#c47543661897638cab9f506c76a1f92f">00090</a>         <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1merger.html#c47543661897638cab9f506c76a1f92f" title="Compute log-probability of argument val.">evallog</a> ( <span class="keyword">const</span> vec &amp;dt )<span class="keyword"> const </span>{ 
    7676<a name="l00091"></a>00091                 vec dtf=ones ( dt.length() +1 ); 
     
    8181<a name="l00096"></a>00096                 <span class="keyword">const</span> Vec&lt;double&gt; &amp;w = <a class="code" href="classbdm_1_1merger.html#522d43f7aa13fe6701e93fba174dec94" title="Projection to empirical density.">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#d7f83cc0415cd44ae7cc8b4bdad93aef" title="Potentially dangerous, use with care.">_w</a>(); 
    8282<a name="l00097"></a>00097                 <span class="keyword">const</span> Array&lt;vec&gt; &amp;S = <a class="code" href="classbdm_1_1merger.html#522d43f7aa13fe6701e93fba174dec94" title="Projection to empirical density.">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#c24966b0aaeb767bc8a6b4fd60931be2" title="access function">_samples</a>(); 
    83 <a name="l00098"></a>00098                 vec tmp=zeros ( <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>() );  
     83<a name="l00098"></a>00098                 vec tmp=zeros ( <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>);  
    8484<a name="l00099"></a>00099                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i&lt;<a class="code" href="classbdm_1_1merger.html#e91b83e6d9076848c71ae27664072109" title="Number of samples used in approximation.">Ns</a>; i++ ) { 
    8585<a name="l00100"></a>00100                         tmp+=w ( i ) *S ( i ); 
     
    9595<a name="l00110"></a>00110                 cout &lt;&lt; sum(w) &lt;&lt; <span class="stringliteral">","</span> &lt;&lt; w*w &lt;&lt;endl; 
    9696<a name="l00111"></a>00111                  
    97 <a name="l00112"></a>00112                 mat Tmp=zeros(<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>(), <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>()); 
     97<a name="l00112"></a>00112                 mat Tmp=zeros(<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#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>); 
    9898<a name="l00113"></a>00113                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i&lt;<a class="code" href="classbdm_1_1merger.html#e91b83e6d9076848c71ae27664072109" title="Number of samples used in approximation.">Ns</a>; i++ ) { 
    9999<a name="l00114"></a>00114                         Tmp+=w ( i ) *outer_product(S ( i ), S(i)); 
     
    105105<a name="l00120"></a>00120                 <span class="keyword">const</span> Array&lt;vec&gt; &amp;S = <a class="code" href="classbdm_1_1merger.html#522d43f7aa13fe6701e93fba174dec94" title="Projection to empirical density.">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#c24966b0aaeb767bc8a6b4fd60931be2" title="access function">_samples</a>(); 
    106106<a name="l00121"></a>00121                  
    107 <a name="l00122"></a>00122                 vec tmp=zeros(<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Identified of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#2174751a00ce19f941edd2c1a861be67" title="Return number of scalars in the RV.">count</a>()); 
     107<a name="l00122"></a>00122                 vec tmp=zeros(<a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>); 
    108108<a name="l00123"></a>00123                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i&lt;Ns; i++ ) { 
    109109<a name="l00124"></a>00124                         tmp+=w ( i ) *pow(S ( i ),2); 
     
    126126<a name="l00144"></a>00144 <span class="preprocessor">#endif // MER_H</span> 
    127127</pre></div></div> 
    128 <hr size="1"><address style="text-align: right;"><small>Generated on Wed Feb 11 10:20:05 2009 for mixpp by&nbsp; 
     128<hr size="1"><address style="text-align: right;"><small>Generated on Wed Feb 11 23:33:55 2009 for mixpp by&nbsp; 
    129129<a href="http://www.doxygen.org/index.html"> 
    130130<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>