Show
Ignore:
Timestamp:
04/09/09 16:11:47 (16 years ago)
Author:
smidl
Message:

doc

Files:
1 modified

Legend:

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

    r305 r312  
    8686<a name="l00046"></a><a class="code" href="classbdm_1_1merger.html#1a85d299f202a70afe0cdc1045c26a5d">00046</a>                         <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1merger.html#1a85d299f202a70afe0cdc1045c26a5d" title="Prior on the log-normal merging model.">beta</a>; 
    8787<a name="l00048"></a><a class="code" href="classbdm_1_1merger.html#522d43f7aa13fe6701e93fba174dec94">00048</a>                         <a class="code" href="classbdm_1_1eEmp.html" title="Weighted empirical density.">eEmp</a> <a class="code" href="classbdm_1_1merger.html#522d43f7aa13fe6701e93fba174dec94" title="Projection to empirical density.">eSmp</a>; 
    88 <a name="l00049"></a>00049  
    89 <a name="l00051"></a><a class="code" href="classbdm_1_1merger.html#14081d8c5cffdcc6c2f81cb61da41dbe">00051</a>                         <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1merger.html#14081d8c5cffdcc6c2f81cb61da41dbe" title="debug or not debug">DBG</a>; 
    90 <a name="l00053"></a><a class="code" href="classbdm_1_1merger.html#2b99a4a9384dc088dc164372d206138f">00053</a>                         it_file* <a class="code" href="classbdm_1_1merger.html#2b99a4a9384dc088dc164372d206138f" title="debugging file">dbg</a>; 
    91 <a name="l00055"></a><a class="code" href="classbdm_1_1merger.html#05dc6d9876677fcf84806d39f24e5509">00055</a>                         <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1merger.html#05dc6d9876677fcf84806d39f24e5509" title="Flag if the samples are fixed or not.">fix_smp</a>; 
    92 <a name="l00056"></a>00056                 <span class="keyword">public</span>: 
    93 <a name="l00058"></a><a class="code" href="classbdm_1_1merger.html#30ae0fa8a88737185f598bf63fec0569">00058</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 ) : 
    94 <a name="l00059"></a>00059                                         <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> ( ), 
    95 <a name="l00060"></a>00060                                         <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>() 
    96 <a name="l00061"></a>00061                         { 
    97 <a name="l00062"></a>00062                                 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> ztmp; 
    98 <a name="l00063"></a>00063                                 <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> = <a class="code" href="classbdm_1_1compositepdf.html#c73d39acc4378eee6a63155c3517d3c9" title="find common rv, flag">getrv</a> ( <span class="keyword">false</span> ); 
    99 <a name="l00064"></a>00064                                 <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 ); <span class="comment">// Extend rv by rvc!</span> 
    100 <a name="l00065"></a>00065                                 <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 ); 
    101 <a name="l00066"></a>00066                                 <span class="comment">// get dimension</span> 
    102 <a name="l00067"></a>00067                                 <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">_dsize</a>(); 
    103 <a name="l00068"></a>00068  
    104 <a name="l00069"></a>00069                                 <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++ ) 
    105 <a name="l00070"></a>00070                                 { 
    106 <a name="l00071"></a>00071                                         <span class="comment">//Establich connection between mpdfs and merger</span> 
    107 <a name="l00072"></a>00072                                         <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_1merger.html#ea3c9f4739f857877fd5285b3973289c" title="Data link for each mpdf in mpdfs.">dls</a> ( i )-&gt;set_connection ( <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> ); 
    108 <a name="l00073"></a>00073                                         <span class="comment">// find out what is missing in each mpdf</span> 
    109 <a name="l00074"></a>00074                                         ztmp= <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )-&gt;_rv(); 
    110 <a name="l00075"></a>00075                                         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() ); 
    111 <a name="l00076"></a>00076                                         <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 ); 
    112 <a name="l00077"></a>00077                                         <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#6c48bf36ec1f3f7b52e3159cf428a193" title="Data Links of rv0 mpdfs - these will be conditioned the (rv,rvc) of mpdfs.">zdls</a> ( i )-&gt;set_connection ( <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> ) ; 
    113 <a name="l00078"></a>00078                                 }; 
    114 <a name="l00079"></a>00079                                 <span class="comment">//Set Default values of parameters</span> 
    115 <a name="l00080"></a>00080                                 <a class="code" href="classbdm_1_1merger.html#1a85d299f202a70afe0cdc1045c26a5d" title="Prior on the log-normal merging model.">beta</a>=2.0; 
    116 <a name="l00081"></a>00081                                 <a class="code" href="classbdm_1_1merger.html#e91b83e6d9076848c71ae27664072109" title="Number of samples used in approximation.">Ns</a>=100; 
    117 <a name="l00082"></a>00082                                 <a class="code" href="classbdm_1_1merger.html#214ca7c566e8f75d45bb243d7c74580d" title="Number of components in a mixture.">Nc</a>=10; 
    118 <a name="l00083"></a>00083                                 <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#664529d52cc667383b39eeb440ccd577" title="Set which method is to be used.">set_method</a> ( EM ); 
    119 <a name="l00084"></a>00084                                 <a class="code" href="classbdm_1_1merger.html#14081d8c5cffdcc6c2f81cb61da41dbe" title="debug or not debug">DBG</a> = <span class="keyword">false</span>; 
    120 <a name="l00085"></a>00085                                 <a class="code" href="classbdm_1_1merger.html#05dc6d9876677fcf84806d39f24e5509" title="Flag if the samples are fixed or not.">fix_smp</a> = <span class="keyword">false</span>; 
    121 <a name="l00086"></a>00086                         } 
    122 <a name="l00088"></a><a class="code" href="classbdm_1_1merger.html#94b5358c9558a8389ac78a65b83244f6">00088</a>                         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger.html#94b5358c9558a8389ac78a65b83244f6" title="set debug file">debug_file</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> fname ) { <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1merger.html#14081d8c5cffdcc6c2f81cb61da41dbe" title="debug or not debug">DBG</a> ) <span class="keyword">delete</span> <a class="code" href="classbdm_1_1merger.html#2b99a4a9384dc088dc164372d206138f" title="debugging file">dbg</a>; <a class="code" href="classbdm_1_1merger.html#2b99a4a9384dc088dc164372d206138f" title="debugging file">dbg</a> = <span class="keyword">new</span> it_file ( fname ); <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1merger.html#2b99a4a9384dc088dc164372d206138f" title="debugging file">dbg</a> ) <a class="code" href="classbdm_1_1merger.html#14081d8c5cffdcc6c2f81cb61da41dbe" title="debug or not debug">DBG</a>=<span class="keyword">true</span>;} 
    123 <a name="l00090"></a><a class="code" href="classbdm_1_1merger.html#bc867c8e2b4709041bf8802ae9c78e37">00090</a>                         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger.html#bc867c8e2b4709041bf8802ae9c78e37" title="Set internal parameters used in approximation.">set_parameters</a> ( <span class="keywordtype">double</span> beta0, <span class="keywordtype">int</span> Ns0, <span class="keywordtype">int</span> Nc0 ) {<a class="code" href="classbdm_1_1merger.html#1a85d299f202a70afe0cdc1045c26a5d" title="Prior on the log-normal merging model.">beta</a>=beta0;<a class="code" href="classbdm_1_1merger.html#e91b83e6d9076848c71ae27664072109" title="Number of samples used in approximation.">Ns</a>=Ns0;<a class="code" href="classbdm_1_1merger.html#214ca7c566e8f75d45bb243d7c74580d" title="Number of components in a mixture.">Nc</a>=Nc0;<a class="code" href="classbdm_1_1merger.html#522d43f7aa13fe6701e93fba174dec94" title="Projection to empirical density.">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#c74c281d652356c19b6b079e42ca7ef1" title="Set sample.">set_parameters</a> ( Ns0,<span class="keyword">false</span> );} 
    124 <a name="l00091"></a>00091                         <span class="keywordtype">void</span> set_grid ( Array&lt;vec&gt; &amp;XYZ ) 
    125 <a name="l00092"></a>00092                         { 
    126 <a name="l00093"></a>00093                                 <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>=XYZ.length(); ivec szs ( dim ); 
    127 <a name="l00094"></a>00094                                 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0; i&lt;dim;i++){szs=XYZ(i).length();} 
    128 <a name="l00095"></a>00095                                 <a class="code" href="classbdm_1_1merger.html#e91b83e6d9076848c71ae27664072109" title="Number of samples used in approximation.">Ns</a>=prod(szs); 
    129 <a name="l00096"></a>00096                                 <a class="code" href="classbdm_1_1merger.html#522d43f7aa13fe6701e93fba174dec94" title="Projection to empirical density.">eSmp</a>.set_parameters(<a class="code" href="classbdm_1_1merger.html#e91b83e6d9076848c71ae27664072109" title="Number of samples used in approximation.">Ns</a>,<span class="keyword">false</span>); 
    130 <a name="l00097"></a>00097                                 Array&lt;vec&gt; &amp;samples=<a class="code" href="classbdm_1_1merger.html#522d43f7aa13fe6701e93fba174dec94" title="Projection to empirical density.">eSmp</a>._samples(); 
    131 <a name="l00098"></a>00098                                 <a class="code" href="classbdm_1_1merger.html#522d43f7aa13fe6701e93fba174dec94" title="Projection to empirical density.">eSmp</a>._w()=ones(<a class="code" href="classbdm_1_1merger.html#e91b83e6d9076848c71ae27664072109" title="Number of samples used in approximation.">Ns</a>)/<a class="code" href="classbdm_1_1merger.html#e91b83e6d9076848c71ae27664072109" title="Number of samples used in approximation.">Ns</a>; 
    132 <a name="l00099"></a>00099                                                  
    133 <a name="l00100"></a>00100                                 <span class="comment">//set samples</span> 
    134 <a name="l00101"></a>00101                                 ivec is=zeros_i(dim);<span class="comment">//indeces of dimensions in for cycle;</span> 
    135 <a name="l00102"></a>00102                                 vec smpi(dim); 
    136 <a name="l00103"></a>00103                                 <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++){ 
    137 <a name="l00104"></a>00104                                         <span class="keywordflow">for</span>(<span class="keywordtype">int</span> j=0; j&lt;dim; j++){smpi(j)=XYZ(j)(is(j)); <span class="comment">/* jty vector*/</span> } 
    138 <a name="l00105"></a>00105                                         samples(i)=smpi; 
    139 <a name="l00106"></a>00106                                         <span class="comment">// shift indeces</span> 
    140 <a name="l00107"></a>00107                                         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j=0;j&lt;dim;j++){ 
    141 <a name="l00108"></a>00108                                                 <span class="keywordflow">if</span> (is(j)==szs(j)-1) { <span class="comment">//j-th index is full</span> 
    142 <a name="l00109"></a>00109                                                         is(j)=0; <span class="comment">//shift back</span> 
    143 <a name="l00110"></a>00110                                                         is(j+1)++; <span class="comment">//increase th next dimension;</span> 
    144 <a name="l00111"></a>00111                                                         <span class="keywordflow">if</span> (is(j+1)&lt;szs(j+1)-1) <span class="keywordflow">break</span>; 
    145 <a name="l00112"></a>00112                                                 } <span class="keywordflow">else</span> { 
    146 <a name="l00113"></a>00113                                                         is(j)++; <span class="keywordflow">break</span>; 
    147 <a name="l00114"></a>00114                                                 } 
    148 <a name="l00115"></a>00115                                         } 
    149 <a name="l00116"></a>00116                                 } 
    150 <a name="l00117"></a>00117                                  
    151 <a name="l00118"></a>00118                                 <a class="code" href="classbdm_1_1merger.html#05dc6d9876677fcf84806d39f24e5509" title="Flag if the samples are fixed or not.">fix_smp</a> = <span class="keyword">true</span>; 
    152 <a name="l00119"></a>00119                         } 
    153 <a name="l00121"></a><a class="code" href="classbdm_1_1merger.html#8ae79a651e93d6e2d611556001af8aa8">00121</a>                         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger.html#8ae79a651e93d6e2d611556001af8aa8" title="Initialize the proposal density. This function must be called before merge()!">init</a>()    
    154 <a name="l00122"></a>00122                         { 
    155 <a name="l00123"></a>00123                                 Array&lt;vec&gt; Smps ( <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a> ); 
    156 <a name="l00124"></a>00124                                 <span class="comment">//Gibbs sampling</span> 
    157 <a name="l00125"></a>00125                                 <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++ ) {Smps ( i ) =zeros ( 0 );} 
     88<a name="l00050"></a><a class="code" href="classbdm_1_1merger.html#045974350a3612ef4080eab6360b3d70">00050</a>                         <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1merger.html#045974350a3612ef4080eab6360b3d70" title="coefficient of resampling">effss_coef</a>; 
     89<a name="l00051"></a>00051  
     90<a name="l00053"></a><a class="code" href="classbdm_1_1merger.html#14081d8c5cffdcc6c2f81cb61da41dbe">00053</a>                         <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1merger.html#14081d8c5cffdcc6c2f81cb61da41dbe" title="debug or not debug">DBG</a>; 
     91<a name="l00055"></a><a class="code" href="classbdm_1_1merger.html#2b99a4a9384dc088dc164372d206138f">00055</a>                         it_file* <a class="code" href="classbdm_1_1merger.html#2b99a4a9384dc088dc164372d206138f" title="debugging file">dbg</a>; 
     92<a name="l00057"></a><a class="code" href="classbdm_1_1merger.html#05dc6d9876677fcf84806d39f24e5509">00057</a>                         <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1merger.html#05dc6d9876677fcf84806d39f24e5509" title="Flag if the samples are fixed or not.">fix_smp</a>; 
     93<a name="l00058"></a>00058                 <span class="keyword">public</span>: 
     94<a name="l00060"></a><a class="code" href="classbdm_1_1merger.html#30ae0fa8a88737185f598bf63fec0569">00060</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 ) : 
     95<a name="l00061"></a>00061                                         <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> ( ), 
     96<a name="l00062"></a>00062                                         <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>() 
     97<a name="l00063"></a>00063                         { 
     98<a name="l00064"></a>00064                                 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> ztmp; 
     99<a name="l00065"></a>00065                                 <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> = <a class="code" href="classbdm_1_1compositepdf.html#c73d39acc4378eee6a63155c3517d3c9" title="find common rv, flag">getrv</a> ( <span class="keyword">false</span> ); 
     100<a name="l00066"></a>00066                                 <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 ); <span class="comment">// Extend rv by rvc!</span> 
     101<a name="l00067"></a>00067                                 <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 ); 
     102<a name="l00068"></a>00068                                 <span class="comment">// get dimension</span> 
     103<a name="l00069"></a>00069                                 <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">_dsize</a>(); 
     104<a name="l00070"></a>00070  
     105<a name="l00071"></a>00071                                 <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++ ) 
     106<a name="l00072"></a>00072                                 { 
     107<a name="l00073"></a>00073                                         <span class="comment">//Establich connection between mpdfs and merger</span> 
     108<a name="l00074"></a>00074                                         <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_1merger.html#ea3c9f4739f857877fd5285b3973289c" title="Data link for each mpdf in mpdfs.">dls</a> ( i )-&gt;set_connection ( <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> ); 
     109<a name="l00075"></a>00075                                         <span class="comment">// find out what is missing in each mpdf</span> 
     110<a name="l00076"></a>00076                                         ztmp= <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )-&gt;_rv(); 
     111<a name="l00077"></a>00077                                         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() ); 
     112<a name="l00078"></a>00078                                         <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 ); 
     113<a name="l00079"></a>00079                                         <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#6c48bf36ec1f3f7b52e3159cf428a193" title="Data Links of rv0 mpdfs - these will be conditioned the (rv,rvc) of mpdfs.">zdls</a> ( i )-&gt;set_connection ( <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> ) ; 
     114<a name="l00080"></a>00080                                 }; 
     115<a name="l00081"></a>00081                                 <span class="comment">//Set Default values of parameters</span> 
     116<a name="l00082"></a>00082                                 <a class="code" href="classbdm_1_1merger.html#1a85d299f202a70afe0cdc1045c26a5d" title="Prior on the log-normal merging model.">beta</a>=2.0; 
     117<a name="l00083"></a>00083                                 <a class="code" href="classbdm_1_1merger.html#e91b83e6d9076848c71ae27664072109" title="Number of samples used in approximation.">Ns</a>=100; 
     118<a name="l00084"></a>00084                                 <a class="code" href="classbdm_1_1merger.html#214ca7c566e8f75d45bb243d7c74580d" title="Number of components in a mixture.">Nc</a>=10; 
     119<a name="l00085"></a>00085                                 <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#664529d52cc667383b39eeb440ccd577" title="Set which method is to be used.">set_method</a> ( EM ); 
     120<a name="l00086"></a>00086                                 <a class="code" href="classbdm_1_1merger.html#14081d8c5cffdcc6c2f81cb61da41dbe" title="debug or not debug">DBG</a> = <span class="keyword">false</span>; 
     121<a name="l00087"></a>00087                                 <a class="code" href="classbdm_1_1merger.html#05dc6d9876677fcf84806d39f24e5509" title="Flag if the samples are fixed or not.">fix_smp</a> = <span class="keyword">false</span>; 
     122<a name="l00088"></a>00088                         } 
     123<a name="l00090"></a><a class="code" href="classbdm_1_1merger.html#94b5358c9558a8389ac78a65b83244f6">00090</a>                         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger.html#94b5358c9558a8389ac78a65b83244f6" title="set debug file">debug_file</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> fname ) { <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1merger.html#14081d8c5cffdcc6c2f81cb61da41dbe" title="debug or not debug">DBG</a> ) <span class="keyword">delete</span> <a class="code" href="classbdm_1_1merger.html#2b99a4a9384dc088dc164372d206138f" title="debugging file">dbg</a>; <a class="code" href="classbdm_1_1merger.html#2b99a4a9384dc088dc164372d206138f" title="debugging file">dbg</a> = <span class="keyword">new</span> it_file ( fname ); <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1merger.html#2b99a4a9384dc088dc164372d206138f" title="debugging file">dbg</a> ) <a class="code" href="classbdm_1_1merger.html#14081d8c5cffdcc6c2f81cb61da41dbe" title="debug or not debug">DBG</a>=<span class="keyword">true</span>;} 
     124<a name="l00092"></a><a class="code" href="classbdm_1_1merger.html#22216ad175880cf2345871f9313a3f19">00092</a>                         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger.html#22216ad175880cf2345871f9313a3f19" title="Set internal parameters used in approximation.">set_parameters</a> ( <span class="keywordtype">double</span> beta0, <span class="keywordtype">int</span> Ns0, <span class="keywordtype">int</span> Nc0, <span class="keywordtype">double</span> effss_coef0=0.5 ) {<a class="code" href="classbdm_1_1merger.html#1a85d299f202a70afe0cdc1045c26a5d" title="Prior on the log-normal merging model.">beta</a>=beta0; 
     125<a name="l00093"></a>00093                                 <a class="code" href="classbdm_1_1merger.html#e91b83e6d9076848c71ae27664072109" title="Number of samples used in approximation.">Ns</a>=Ns0; 
     126<a name="l00094"></a>00094                                 <a class="code" href="classbdm_1_1merger.html#214ca7c566e8f75d45bb243d7c74580d" title="Number of components in a mixture.">Nc</a>=Nc0; 
     127<a name="l00095"></a>00095                                 <a class="code" href="classbdm_1_1merger.html#045974350a3612ef4080eab6360b3d70" title="coefficient of resampling">effss_coef</a>=effss_coef0; 
     128<a name="l00096"></a>00096                                 <a class="code" href="classbdm_1_1merger.html#522d43f7aa13fe6701e93fba174dec94" title="Projection to empirical density.">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#c74c281d652356c19b6b079e42ca7ef1" title="Set sample.">set_parameters</a> ( Ns0,<span class="keyword">false</span> ); 
     129<a name="l00097"></a>00097                         } 
     130<a name="l00098"></a>00098                         <span class="keywordtype">void</span> set_grid ( Array&lt;vec&gt; &amp;XYZ ) 
     131<a name="l00099"></a>00099                         { 
     132<a name="l00100"></a>00100                                 <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>=XYZ.length(); ivec szs ( dim ); 
     133<a name="l00101"></a>00101                                 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0; i&lt;dim;i++){szs=XYZ(i).length();} 
     134<a name="l00102"></a>00102                                 <a class="code" href="classbdm_1_1merger.html#e91b83e6d9076848c71ae27664072109" title="Number of samples used in approximation.">Ns</a>=prod(szs); 
     135<a name="l00103"></a>00103                                 <a class="code" href="classbdm_1_1merger.html#522d43f7aa13fe6701e93fba174dec94" title="Projection to empirical density.">eSmp</a>.set_parameters(<a class="code" href="classbdm_1_1merger.html#e91b83e6d9076848c71ae27664072109" title="Number of samples used in approximation.">Ns</a>,<span class="keyword">false</span>); 
     136<a name="l00104"></a>00104                                 Array&lt;vec&gt; &amp;samples=<a class="code" href="classbdm_1_1merger.html#522d43f7aa13fe6701e93fba174dec94" title="Projection to empirical density.">eSmp</a>._samples(); 
     137<a name="l00105"></a>00105                                 <a class="code" href="classbdm_1_1merger.html#522d43f7aa13fe6701e93fba174dec94" title="Projection to empirical density.">eSmp</a>._w()=ones(<a class="code" href="classbdm_1_1merger.html#e91b83e6d9076848c71ae27664072109" title="Number of samples used in approximation.">Ns</a>)/<a class="code" href="classbdm_1_1merger.html#e91b83e6d9076848c71ae27664072109" title="Number of samples used in approximation.">Ns</a>; 
     138<a name="l00106"></a>00106                                                  
     139<a name="l00107"></a>00107                                 <span class="comment">//set samples</span> 
     140<a name="l00108"></a>00108                                 ivec is=zeros_i(dim);<span class="comment">//indeces of dimensions in for cycle;</span> 
     141<a name="l00109"></a>00109                                 vec smpi(dim); 
     142<a name="l00110"></a>00110                                 <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++){ 
     143<a name="l00111"></a>00111                                         <span class="keywordflow">for</span>(<span class="keywordtype">int</span> j=0; j&lt;dim; j++){smpi(j)=XYZ(j)(is(j)); <span class="comment">/* jty vector*/</span> } 
     144<a name="l00112"></a>00112                                         samples(i)=smpi; 
     145<a name="l00113"></a>00113                                         <span class="comment">// shift indeces</span> 
     146<a name="l00114"></a>00114                                         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j=0;j&lt;dim;j++){ 
     147<a name="l00115"></a>00115                                                 <span class="keywordflow">if</span> (is(j)==szs(j)-1) { <span class="comment">//j-th index is full</span> 
     148<a name="l00116"></a>00116                                                         is(j)=0; <span class="comment">//shift back</span> 
     149<a name="l00117"></a>00117                                                         is(j+1)++; <span class="comment">//increase th next dimension;</span> 
     150<a name="l00118"></a>00118                                                         <span class="keywordflow">if</span> (is(j+1)&lt;szs(j+1)-1) <span class="keywordflow">break</span>; 
     151<a name="l00119"></a>00119                                                 } <span class="keywordflow">else</span> { 
     152<a name="l00120"></a>00120                                                         is(j)++; <span class="keywordflow">break</span>; 
     153<a name="l00121"></a>00121                                                 } 
     154<a name="l00122"></a>00122                                         } 
     155<a name="l00123"></a>00123                                 } 
     156<a name="l00124"></a>00124                                  
     157<a name="l00125"></a>00125                                 <a class="code" href="classbdm_1_1merger.html#05dc6d9876677fcf84806d39f24e5509" title="Flag if the samples are fixed or not.">fix_smp</a> = <span class="keyword">true</span>; 
    158158<a name="l00126"></a>00126                         } 
    159 <a name="l00128"></a>00128                         <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 ); 
    160 <a name="l00130"></a><a class="code" href="classbdm_1_1merger.html#b72f4662c9ac760a8b17ebe5d697f3c2">00130</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#4830916adef7891a207e42f39aaf787b">posterior</a>() ) );}; 
    161 <a name="l00131"></a>00131  
    162 <a name="l00133"></a>00133                         vec <a class="code" href="classbdm_1_1merger.html#b90f1b8a21a693176dd953a3b983aa0b" title="Merge log-likelihood values.">lognorm_merge</a> ( mat &amp;lW ); 
    163 <a name="l00136"></a><a class="code" href="classbdm_1_1merger.html#0ef73e76eeee44c8e3896e3a271ad974">00136</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#4830916adef7891a207e42f39aaf787b">posterior</a>().<a class="code" href="classbdm_1_1epdf.html#75ba57a89681a8efec488f5796c7cc1b" title="Returns a sample,  from density .">sample</a>();} 
    164 <a name="l00137"></a><a class="code" href="classbdm_1_1merger.html#c47543661897638cab9f506c76a1f92f">00137</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> 
    165 <a name="l00138"></a>00138 <span class="keyword">                        </span>{ 
    166 <a name="l00139"></a>00139                                 vec dtf=ones ( dt.length() +1 ); 
    167 <a name="l00140"></a>00140                                 dtf.set_subvector ( 0,dt ); 
    168 <a name="l00141"></a>00141                                 <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#da724da464a75e07521941e430929efa">logpred</a> ( dtf ); 
    169 <a name="l00142"></a>00142                         } 
    170 <a name="l00143"></a><a class="code" href="classbdm_1_1merger.html#82c5ad7677315fde8e9fc9381c17ece5">00143</a>                         vec <a class="code" href="classbdm_1_1merger.html#82c5ad7677315fde8e9fc9381c17ece5" title="return expected value">mean</a>()<span class="keyword"> const</span> 
    171 <a name="l00144"></a>00144 <span class="keyword">                        </span>{ 
    172 <a name="l00145"></a>00145                                 <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>(); 
    173 <a name="l00146"></a>00146                                 <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>(); 
    174 <a name="l00147"></a>00147                                 vec tmp=zeros ( dim ); 
    175 <a name="l00148"></a>00148                                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i&lt;Ns; i++ ) 
    176 <a name="l00149"></a>00149                                 { 
    177 <a name="l00150"></a>00150                                         tmp+=w ( i ) *S ( i ); 
    178 <a name="l00151"></a>00151                                 } 
    179 <a name="l00152"></a>00152                                 <span class="keywordflow">return</span> tmp; 
    180 <a name="l00153"></a>00153                         } 
    181 <a name="l00154"></a>00154                         mat covariance()<span class="keyword"> const</span> 
    182 <a name="l00155"></a>00155 <span class="keyword">                        </span>{ 
    183 <a name="l00156"></a>00156                                 <span class="keyword">const</span> vec &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>(); 
    184 <a name="l00157"></a>00157                                 <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>(); 
    185 <a name="l00158"></a>00158  
    186 <a name="l00159"></a>00159                                 vec mea = <a class="code" href="classbdm_1_1merger.html#82c5ad7677315fde8e9fc9381c17ece5" title="return expected value">mean</a>(); 
    187 <a name="l00160"></a>00160  
    188 <a name="l00161"></a>00161                                 cout &lt;&lt; sum ( w ) &lt;&lt; <span class="stringliteral">","</span> &lt;&lt; w*w &lt;&lt;endl; 
    189 <a name="l00162"></a>00162  
    190 <a name="l00163"></a>00163                                 mat Tmp=zeros ( dim, dim ); 
    191 <a name="l00164"></a>00164                                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i&lt;Ns; i++ ) 
    192 <a name="l00165"></a>00165                                 { 
    193 <a name="l00166"></a>00166                                         Tmp+=w ( i ) *outer_product ( S ( i ), S ( i ) ); 
    194 <a name="l00167"></a>00167                                 } 
    195 <a name="l00168"></a>00168                                 <span class="keywordflow">return</span> Tmp-outer_product ( mea,mea ); 
    196 <a name="l00169"></a>00169                         } 
    197 <a name="l00170"></a><a class="code" href="classbdm_1_1merger.html#bcef70ece256b1ab1fa7a3a354eb1cc4">00170</a>                         vec <a class="code" href="classbdm_1_1merger.html#bcef70ece256b1ab1fa7a3a354eb1cc4" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const</span> 
    198 <a name="l00171"></a>00171 <span class="keyword">                        </span>{ 
    199 <a name="l00172"></a>00172                                 <span class="keyword">const</span> vec &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>(); 
    200 <a name="l00173"></a>00173                                 <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>(); 
    201 <a name="l00174"></a>00174  
    202 <a name="l00175"></a>00175                                 vec tmp=zeros ( dim ); 
    203 <a name="l00176"></a>00176                                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i&lt;Ns; i++ ) 
    204 <a name="l00177"></a>00177                                 { 
    205 <a name="l00178"></a>00178                                         tmp+=w ( i ) *pow ( S ( i ),2 ); 
    206 <a name="l00179"></a>00179                                 } 
    207 <a name="l00180"></a>00180                                 <span class="keywordflow">return</span> tmp-pow ( <a class="code" href="classbdm_1_1merger.html#82c5ad7677315fde8e9fc9381c17ece5" title="return expected value">mean</a>(),2 ); 
    208 <a name="l00181"></a>00181                         } 
    209 <a name="l00183"></a><a class="code" href="classbdm_1_1merger.html#febef179bb5e074ae6e34d15b4596273">00183</a>                         <span class="keyword">virtual</span> <a class="code" href="classbdm_1_1merger.html#febef179bb5e074ae6e34d15b4596273" title="for future use">~merger</a>() 
    210 <a name="l00184"></a>00184                         { 
    211 <a name="l00185"></a>00185                                 <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++ ) 
    212 <a name="l00186"></a>00186                                 { 
    213 <a name="l00187"></a>00187                                         <span class="keyword">delete</span> <a class="code" href="classbdm_1_1merger.html#ea3c9f4739f857877fd5285b3973289c" title="Data link for each mpdf in mpdfs.">dls</a> ( i ); 
    214 <a name="l00188"></a>00188                                         <span class="keyword">delete</span> <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 ); 
    215 <a name="l00189"></a>00189                                 } 
    216 <a name="l00190"></a>00190                                 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1merger.html#14081d8c5cffdcc6c2f81cb61da41dbe" title="debug or not debug">DBG</a> ) <span class="keyword">delete</span> <a class="code" href="classbdm_1_1merger.html#2b99a4a9384dc088dc164372d206138f" title="debugging file">dbg</a>; 
    217 <a name="l00191"></a>00191                         }; 
    218 <a name="l00192"></a>00192  
    219 <a name="l00194"></a><a class="code" href="classbdm_1_1merger.html#13f8534f626a37bed91a6d9db54d6d2f">00194</a>                         <a class="code" href="classbdm_1_1MixEF.html" title="Mixture of Exponential Family Densities.">MixEF</a>&amp; <a class="code" href="classbdm_1_1merger.html#13f8534f626a37bed91a6d9db54d6d2f" title="Access function.">_Mix</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1merger.html#67ae71cbf0686d7c7bf116fa5db86d81" title="Internal mixture of EF models.">Mix</a>;} 
    220 <a name="l00196"></a><a class="code" href="classbdm_1_1merger.html#23f5f8b80df579b05681006fbcfe3699">00196</a>                         <a class="code" href="classbdm_1_1eEmp.html" title="Weighted empirical density.">eEmp</a>&amp; <a class="code" href="classbdm_1_1merger.html#23f5f8b80df579b05681006fbcfe3699" title="Access function.">_Smp</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1merger.html#522d43f7aa13fe6701e93fba174dec94" title="Projection to empirical density.">eSmp</a>;} 
    221 <a name="l00197"></a>00197         }; 
    222 <a name="l00198"></a>00198  
    223 <a name="l00199"></a>00199 } 
    224 <a name="l00200"></a>00200  
    225 <a name="l00201"></a>00201 <span class="preprocessor">#endif // MER_H</span> 
     159<a name="l00128"></a><a class="code" href="classbdm_1_1merger.html#8ae79a651e93d6e2d611556001af8aa8">00128</a>                         <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger.html#8ae79a651e93d6e2d611556001af8aa8" title="Initialize the proposal density. This function must be called before merge()!">init</a>()    
     160<a name="l00129"></a>00129                         { 
     161<a name="l00130"></a>00130                                 Array&lt;vec&gt; Smps ( <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a> ); 
     162<a name="l00131"></a>00131                                 <span class="comment">//Gibbs sampling</span> 
     163<a name="l00132"></a>00132                                 <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++ ) {Smps ( i ) =zeros ( 0 );} 
     164<a name="l00133"></a>00133                         } 
     165<a name="l00135"></a>00135                         <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 ); 
     166<a name="l00137"></a><a class="code" href="classbdm_1_1merger.html#b72f4662c9ac760a8b17ebe5d697f3c2">00137</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#4830916adef7891a207e42f39aaf787b">posterior</a>() ) );}; 
     167<a name="l00138"></a>00138  
     168<a name="l00140"></a>00140                         vec <a class="code" href="classbdm_1_1merger.html#b90f1b8a21a693176dd953a3b983aa0b" title="Merge log-likelihood values.">lognorm_merge</a> ( mat &amp;lW ); 
     169<a name="l00143"></a><a class="code" href="classbdm_1_1merger.html#0ef73e76eeee44c8e3896e3a271ad974">00143</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#4830916adef7891a207e42f39aaf787b">posterior</a>().<a class="code" href="classbdm_1_1epdf.html#75ba57a89681a8efec488f5796c7cc1b" title="Returns a sample,  from density .">sample</a>();} 
     170<a name="l00144"></a><a class="code" href="classbdm_1_1merger.html#c47543661897638cab9f506c76a1f92f">00144</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> 
     171<a name="l00145"></a>00145 <span class="keyword">                        </span>{ 
     172<a name="l00146"></a>00146                                 vec dtf=ones ( dt.length() +1 ); 
     173<a name="l00147"></a>00147                                 dtf.set_subvector ( 0,dt ); 
     174<a name="l00148"></a>00148                                 <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#da724da464a75e07521941e430929efa">logpred</a> ( dtf ); 
     175<a name="l00149"></a>00149                         } 
     176<a name="l00150"></a><a class="code" href="classbdm_1_1merger.html#82c5ad7677315fde8e9fc9381c17ece5">00150</a>                         vec <a class="code" href="classbdm_1_1merger.html#82c5ad7677315fde8e9fc9381c17ece5" title="return expected value">mean</a>()<span class="keyword"> const</span> 
     177<a name="l00151"></a>00151 <span class="keyword">                        </span>{ 
     178<a name="l00152"></a>00152                                 <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>(); 
     179<a name="l00153"></a>00153                                 <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>(); 
     180<a name="l00154"></a>00154                                 vec tmp=zeros ( dim ); 
     181<a name="l00155"></a>00155                                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i&lt;Ns; i++ ) 
     182<a name="l00156"></a>00156                                 { 
     183<a name="l00157"></a>00157                                         tmp+=w ( i ) *S ( i ); 
     184<a name="l00158"></a>00158                                 } 
     185<a name="l00159"></a>00159                                 <span class="keywordflow">return</span> tmp; 
     186<a name="l00160"></a>00160                         } 
     187<a name="l00161"></a>00161                         mat covariance()<span class="keyword"> const</span> 
     188<a name="l00162"></a>00162 <span class="keyword">                        </span>{ 
     189<a name="l00163"></a>00163                                 <span class="keyword">const</span> vec &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>(); 
     190<a name="l00164"></a>00164                                 <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>(); 
     191<a name="l00165"></a>00165  
     192<a name="l00166"></a>00166                                 vec mea = <a class="code" href="classbdm_1_1merger.html#82c5ad7677315fde8e9fc9381c17ece5" title="return expected value">mean</a>(); 
     193<a name="l00167"></a>00167  
     194<a name="l00168"></a>00168                                 cout &lt;&lt; sum ( w ) &lt;&lt; <span class="stringliteral">","</span> &lt;&lt; w*w &lt;&lt;endl; 
     195<a name="l00169"></a>00169  
     196<a name="l00170"></a>00170                                 mat Tmp=zeros ( dim, dim ); 
     197<a name="l00171"></a>00171                                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i&lt;Ns; i++ ) 
     198<a name="l00172"></a>00172                                 { 
     199<a name="l00173"></a>00173                                         Tmp+=w ( i ) *outer_product ( S ( i ), S ( i ) ); 
     200<a name="l00174"></a>00174                                 } 
     201<a name="l00175"></a>00175                                 <span class="keywordflow">return</span> Tmp-outer_product ( mea,mea ); 
     202<a name="l00176"></a>00176                         } 
     203<a name="l00177"></a><a class="code" href="classbdm_1_1merger.html#bcef70ece256b1ab1fa7a3a354eb1cc4">00177</a>                         vec <a class="code" href="classbdm_1_1merger.html#bcef70ece256b1ab1fa7a3a354eb1cc4" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const</span> 
     204<a name="l00178"></a>00178 <span class="keyword">                        </span>{ 
     205<a name="l00179"></a>00179                                 <span class="keyword">const</span> vec &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>(); 
     206<a name="l00180"></a>00180                                 <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>(); 
     207<a name="l00181"></a>00181  
     208<a name="l00182"></a>00182                                 vec tmp=zeros ( dim ); 
     209<a name="l00183"></a>00183                                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i&lt;Ns; i++ ) 
     210<a name="l00184"></a>00184                                 { 
     211<a name="l00185"></a>00185                                         tmp+=w ( i ) *pow ( S ( i ),2 ); 
     212<a name="l00186"></a>00186                                 } 
     213<a name="l00187"></a>00187                                 <span class="keywordflow">return</span> tmp-pow ( <a class="code" href="classbdm_1_1merger.html#82c5ad7677315fde8e9fc9381c17ece5" title="return expected value">mean</a>(),2 ); 
     214<a name="l00188"></a>00188                         } 
     215<a name="l00190"></a><a class="code" href="classbdm_1_1merger.html#febef179bb5e074ae6e34d15b4596273">00190</a>                         <span class="keyword">virtual</span> <a class="code" href="classbdm_1_1merger.html#febef179bb5e074ae6e34d15b4596273" title="for future use">~merger</a>() 
     216<a name="l00191"></a>00191                         { 
     217<a name="l00192"></a>00192                                 <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++ ) 
     218<a name="l00193"></a>00193                                 { 
     219<a name="l00194"></a>00194                                         <span class="keyword">delete</span> <a class="code" href="classbdm_1_1merger.html#ea3c9f4739f857877fd5285b3973289c" title="Data link for each mpdf in mpdfs.">dls</a> ( i ); 
     220<a name="l00195"></a>00195                                         <span class="keyword">delete</span> <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 ); 
     221<a name="l00196"></a>00196                                 } 
     222<a name="l00197"></a>00197                                 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1merger.html#14081d8c5cffdcc6c2f81cb61da41dbe" title="debug or not debug">DBG</a> ) <span class="keyword">delete</span> <a class="code" href="classbdm_1_1merger.html#2b99a4a9384dc088dc164372d206138f" title="debugging file">dbg</a>; 
     223<a name="l00198"></a>00198                         }; 
     224<a name="l00199"></a>00199  
     225<a name="l00201"></a><a class="code" href="classbdm_1_1merger.html#13f8534f626a37bed91a6d9db54d6d2f">00201</a>                         <a class="code" href="classbdm_1_1MixEF.html" title="Mixture of Exponential Family Densities.">MixEF</a>&amp; <a class="code" href="classbdm_1_1merger.html#13f8534f626a37bed91a6d9db54d6d2f" title="Access function.">_Mix</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1merger.html#67ae71cbf0686d7c7bf116fa5db86d81" title="Internal mixture of EF models.">Mix</a>;} 
     226<a name="l00203"></a><a class="code" href="classbdm_1_1merger.html#59314cda058b05ede7831f36b9f759cf">00203</a>                         <a class="code" href="classbdm_1_1emix.html" title="Mixture of epdfs.">emix</a>* <a class="code" href="classbdm_1_1merger.html#59314cda058b05ede7831f36b9f759cf" title="Access function.">proposal</a>() {<a class="code" href="classbdm_1_1emix.html" title="Mixture of epdfs.">emix</a>* tmp=<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#edc50e9640f049b846084748b18469a2" title="Constructs a predictive density .">epredictor</a>(); tmp-&gt;<a class="code" href="classbdm_1_1emix.html#04a8632cfa9299ae937228eb732fd61e" title="Name its rv.">set_rv</a>(<a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>); <span class="keywordflow">return</span> tmp;} 
     227<a name="l00205"></a><a class="code" href="classbdm_1_1merger.html#23f5f8b80df579b05681006fbcfe3699">00205</a>                         <a class="code" href="classbdm_1_1eEmp.html" title="Weighted empirical density.">eEmp</a>&amp; <a class="code" href="classbdm_1_1merger.html#23f5f8b80df579b05681006fbcfe3699" title="Access function.">_Smp</a>() {<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1merger.html#522d43f7aa13fe6701e93fba174dec94" title="Projection to empirical density.">eSmp</a>;} 
     228<a name="l00206"></a>00206         }; 
     229<a name="l00207"></a>00207  
     230<a name="l00208"></a>00208 } 
     231<a name="l00209"></a>00209  
     232<a name="l00210"></a>00210 <span class="preprocessor">#endif // MER_H</span> 
    226233</pre></div></div> 
    227 <hr size="1"><address style="text-align: right;"><small>Generated on Wed Apr 8 16:12:31 2009 for mixpp by&nbsp; 
     234<hr size="1"><address style="text-align: right;"><small>Generated on Thu Apr 9 14:33:20 2009 for mixpp by&nbsp; 
    228235<a href="http://www.doxygen.org/index.html"> 
    229236<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>