Show
Ignore:
Timestamp:
11/13/08 19:59:21 (16 years ago)
Author:
smidl
Message:

dokumentace

Files:
1 modified

Legend:

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

    r181 r210  
    2525<a name="l00020"></a>00020 <span class="keyword">using</span> std::string; 
    2626<a name="l00021"></a>00021  
    27 <a name="l00028"></a><a class="code" href="classmerger.html">00028</a> <span class="keyword">class </span><a class="code" href="classmerger.html" title="Function for general combination of pdfs.">merger</a> : <span class="keyword">public</span> <a class="code" href="classcompositepdf.html" title="Abstract composition of pdfs, a base for specific classes.">compositepdf</a>, <span class="keyword">public</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> { 
     27<a name="l00028"></a><a class="code" href="classmerger.html">00028</a> <span class="keyword">class </span><a class="code" href="classmerger.html" title="Function for general combination of pdfs.">merger</a> : <span class="keyword">public</span> <a class="code" href="classcompositepdf.html" title="Abstract composition of pdfs, a base for specific classes this abstract class is...">compositepdf</a>, <span class="keyword">public</span> <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> { 
    2828<a name="l00029"></a>00029 <span class="keyword">protected</span>: 
    2929<a name="l00031"></a><a class="code" href="classmerger.html#021d1522cea70db8545d708afd32ec2f">00031</a>         <a class="code" href="classMixEF.html" title="Mixture of Exponential Family Densities.">MixEF</a> <a class="code" href="classmerger.html#021d1522cea70db8545d708afd32ec2f" title="Internal mixture of EF models.">Mix</a>; 
    30 <a name="l00033"></a><a class="code" href="classmerger.html#ce84de1824875b4262eefb640e8c6d69">00033</a>         <span class="keywordtype">int</span> <a class="code" href="classmerger.html#ce84de1824875b4262eefb640e8c6d69" title="Number of samples used in approximation.">Ns</a>; 
    31 <a name="l00035"></a><a class="code" href="classmerger.html#6acf33e1c64aaaee20689725e8110f65">00035</a>         <span class="keywordtype">int</span> <a class="code" href="classmerger.html#6acf33e1c64aaaee20689725e8110f65" title="Number of components in a mixture.">Nc</a>; 
    32 <a name="l00037"></a><a class="code" href="classmerger.html#e68a72e2740007ae68545e378c7701ad">00037</a>         <span class="keywordtype">double</span> <a class="code" href="classmerger.html#e68a72e2740007ae68545e378c7701ad" title="Prior on the log-normal merging model.">beta</a>; 
    33 <a name="l00038"></a>00038 <span class="keyword">public</span>: 
    34 <a name="l00040"></a><a class="code" href="classmerger.html#3f9a955329eab65026e8322e9027d469">00040</a>         <a class="code" href="classmerger.html#3f9a955329eab65026e8322e9027d469" title="Default constructor.">merger</a> ( <span class="keyword">const</span> Array&lt;mpdf*&gt; &amp;S ) : 
    35 <a name="l00041"></a>00041                         <a class="code" href="classcompositepdf.html" title="Abstract composition of pdfs, a base for specific classes.">compositepdf</a> ( S ), <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( <a class="code" href="classcompositepdf.html#635d219fb3e32852400d6f98aa4bdc93" title="find common rv, flag">getrv</a> ( false ) ), 
    36 <a name="l00042"></a>00042                         <a class="code" href="classmerger.html#021d1522cea70db8545d708afd32ec2f" title="Internal mixture of EF models.">Mix</a> ( Array&lt;<a class="code" href="classBMEF.html" title="Estimator for Exponential family.">BMEF</a>*&gt; ( 0 ),vec ( 0 ) ) 
    37 <a name="l00043"></a>00043         {<a class="code" href="classcompositepdf.html#08958c8f76d65de94ecc37b8d90bc77a" title="fill all rv*inrv* according to">setindices</a>(<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>); <a class="code" href="classmerger.html#e68a72e2740007ae68545e378c7701ad" title="Prior on the log-normal merging model.">beta</a>=2.0; <a class="code" href="classmerger.html#ce84de1824875b4262eefb640e8c6d69" title="Number of samples used in approximation.">Ns</a>=100; <a class="code" href="classmerger.html#6acf33e1c64aaaee20689725e8110f65" title="Number of components in a mixture.">Nc</a>=10;} 
    38 <a name="l00045"></a><a class="code" href="classmerger.html#79420e251308df4502c834171d518ad9">00045</a>         <span class="keywordtype">void</span> <a class="code" href="classmerger.html#79420e251308df4502c834171d518ad9" 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="classmerger.html#e68a72e2740007ae68545e378c7701ad" title="Prior on the log-normal merging model.">beta</a>=beta0;<a class="code" href="classmerger.html#ce84de1824875b4262eefb640e8c6d69" title="Number of samples used in approximation.">Ns</a>=Ns0;<a class="code" href="classmerger.html#6acf33e1c64aaaee20689725e8110f65" title="Number of components in a mixture.">Nc</a>=Nc0;} 
    39 <a name="l00047"></a><a class="code" href="classmerger.html#02d2a445e44a87f37ee3a2b9b40cffd1">00047</a>         <span class="keywordtype">void</span> <a class="code" href="classmerger.html#02d2a445e44a87f37ee3a2b9b40cffd1" title="Initialize the proposal density. This function must be called before merge()!">init</a>() { 
    40 <a name="l00048"></a>00048                 Array&lt;vec&gt; Smps ( <a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a> ); 
    41 <a name="l00049"></a>00049                 <span class="comment">//Gibbs sampling</span> 
    42 <a name="l00050"></a>00050                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i&lt;<a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a>;i++ ) {Smps ( i ) =zeros ( 0 );} 
    43 <a name="l00051"></a>00051         } 
    44 <a name="l00053"></a>00053         <span class="keywordtype">void</span> <a class="code" href="classmerger.html#bc23accc77ec766bce7202934e2c180c" 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="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* g0 ); 
    45 <a name="l00055"></a><a class="code" href="classmerger.html#bc23accc77ec766bce7202934e2c180c">00055</a>         <span class="keywordtype">void</span> <a class="code" href="classmerger.html#bc23accc77ec766bce7202934e2c180c" title="Create a mixture density, make sure to call init() before the first call.">merge</a> () {<a class="code" href="classmerger.html#bc23accc77ec766bce7202934e2c180c" title="Create a mixture density, make sure to call init() before the first call.">merge</a> ( &amp; ( <a class="code" href="classmerger.html#021d1522cea70db8545d708afd32ec2f" title="Internal mixture of EF models.">Mix</a>.<a class="code" href="classMixEF.html#efb3e20c2151d91c4fc080b7722a2069" title="Returns a pointer to the epdf representing posterior density on parameters. Use with...">_epdf</a>() ) );}; 
    46 <a name="l00056"></a>00056  
    47 <a name="l00058"></a>00058         vec <a class="code" href="classmerger.html#217c65f335c603033fa09a2ecc64bc05" title="Merge log-likelihood values.">lognorm_merge</a> ( mat &amp;lW ); 
    48 <a name="l00061"></a><a class="code" href="classmerger.html#379198c3d2063bfa63f5d1245a2511ba">00061</a>         vec <a class="code" href="classmerger.html#379198c3d2063bfa63f5d1245a2511ba">sample</a> ( )<span class="keyword">const </span>{ <span class="keywordflow">return</span> <a class="code" href="classmerger.html#021d1522cea70db8545d708afd32ec2f" title="Internal mixture of EF models.">Mix</a>.<a class="code" href="classMixEF.html#efb3e20c2151d91c4fc080b7722a2069" title="Returns a pointer to the epdf representing posterior density on parameters. Use with...">_epdf</a>().<a class="code" href="classepdf.html#8019654e494bf5e458f6fb947e11b262" title="Returns a sample,  from density .">sample</a>();} 
    49 <a name="l00062"></a><a class="code" href="classmerger.html#8c37688902b1a1e9fa32edc5709e5a00">00062</a>         <span class="keywordtype">double</span> <a class="code" href="classmerger.html#8c37688902b1a1e9fa32edc5709e5a00" title="Compute log-probability of argument val.">evalpdflog</a> ( <span class="keyword">const</span> vec &amp;dt )<span class="keyword"> const</span>{ vec dtf=zeros(dt.length()+1); dtf.set_subvector(0,dt); <span class="keywordflow">return</span> <a class="code" href="classmerger.html#021d1522cea70db8545d708afd32ec2f" title="Internal mixture of EF models.">Mix</a>.<a class="code" href="classMixEF.html#424ca64f36d4e41de7a7e7ae921d35ea">logpred</a> ( dtf );} 
    50 <a name="l00063"></a><a class="code" href="classmerger.html#3a46999cd77047d5d4ac6c1cb735a83e">00063</a>         vec <a class="code" href="classmerger.html#3a46999cd77047d5d4ac6c1cb735a83e" title="return expected value">mean</a>()<span class="keyword">const </span>{<span class="keywordflow">return</span> <a class="code" href="classmerger.html#021d1522cea70db8545d708afd32ec2f" title="Internal mixture of EF models.">Mix</a>.<a class="code" href="classMixEF.html#efb3e20c2151d91c4fc080b7722a2069" title="Returns a pointer to the epdf representing posterior density on parameters. Use with...">_epdf</a>().<a class="code" href="classepdf.html#bf0a070a8f3e67a93604ca724638b870" title="return expected value">mean</a>();} 
    51 <a name="l00065"></a><a class="code" href="classmerger.html#51e425ee1dd46d73353526e6a1c24ca3">00065</a>         <span class="keyword">virtual</span> <a class="code" href="classmerger.html#51e425ee1dd46d73353526e6a1c24ca3" title="for future use">~merger</a>() {}; 
    52 <a name="l00066"></a>00066 }; 
    53 <a name="l00067"></a>00067  
    54 <a name="l00068"></a>00068  
    55 <a name="l00069"></a>00069  
    56 <a name="l00070"></a>00070 <span class="preprocessor">#endif // MER_H</span> 
     30<a name="l00033"></a><a class="code" href="classmerger.html#01e222f5df660e1b25c712e82da8df8f">00033</a>         Array&lt;datalink_m2e*&gt; <a class="code" href="classmerger.html#01e222f5df660e1b25c712e82da8df8f" title="Data link for each mpdf in mpdfs.">dls</a>; 
     31<a name="l00035"></a><a class="code" href="classmerger.html#e741e6096a7acec3dfa477efa1d8160e">00035</a>         Array&lt;RV&gt; <a class="code" href="classmerger.html#e741e6096a7acec3dfa477efa1d8160e" title="Array of rvs that are not modelled by mpdfs at all (aux).">rvzs</a>; 
     32<a name="l00037"></a><a class="code" href="classmerger.html#d0ff2953f904f12a355f72f51813ca7a">00037</a>         Array&lt;datalink_m2e*&gt; <a class="code" href="classmerger.html#d0ff2953f904f12a355f72f51813ca7a" title="Data Links of rv0 mpdfs - these will be conditioned the (rv,rvc) of mpdfs.">zdls</a>; 
     33<a name="l00038"></a>00038  
     34<a name="l00040"></a><a class="code" href="classmerger.html#ce84de1824875b4262eefb640e8c6d69">00040</a>         <span class="keywordtype">int</span> <a class="code" href="classmerger.html#ce84de1824875b4262eefb640e8c6d69" title="Number of samples used in approximation.">Ns</a>; 
     35<a name="l00042"></a><a class="code" href="classmerger.html#6acf33e1c64aaaee20689725e8110f65">00042</a>         <span class="keywordtype">int</span> <a class="code" href="classmerger.html#6acf33e1c64aaaee20689725e8110f65" title="Number of components in a mixture.">Nc</a>; 
     36<a name="l00044"></a><a class="code" href="classmerger.html#e68a72e2740007ae68545e378c7701ad">00044</a>         <span class="keywordtype">double</span> <a class="code" href="classmerger.html#e68a72e2740007ae68545e378c7701ad" title="Prior on the log-normal merging model.">beta</a>; 
     37<a name="l00046"></a><a class="code" href="classmerger.html#b13c9e8921e6bc6b8dd7bbafb54fa801">00046</a>         <a class="code" href="classeEmp.html" title="Weighted empirical density.">eEmp</a> <a class="code" href="classmerger.html#b13c9e8921e6bc6b8dd7bbafb54fa801" title="Projection to empirical density.">eSmp</a>; 
     38<a name="l00047"></a>00047  
     39<a name="l00048"></a>00048 <span class="keyword">public</span>: 
     40<a name="l00050"></a><a class="code" href="classmerger.html#3f9a955329eab65026e8322e9027d469">00050</a>         <a class="code" href="classmerger.html#3f9a955329eab65026e8322e9027d469" title="Default constructor.">merger</a> ( <span class="keyword">const</span> Array&lt;mpdf*&gt; &amp;S ) : 
     41<a name="l00051"></a>00051                         <a class="code" href="classcompositepdf.html" title="Abstract composition of pdfs, a base for specific classes this abstract class is...">compositepdf</a> ( S ), <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> ( <a class="code" href="classcompositepdf.html#635d219fb3e32852400d6f98aa4bdc93" title="find common rv, flag">getrv</a> ( false ) ), 
     42<a name="l00052"></a>00052                         <a class="code" href="classmerger.html#021d1522cea70db8545d708afd32ec2f" title="Internal mixture of EF models.">Mix</a> ( Array&lt;<a class="code" href="classBMEF.html" title="Estimator for Exponential family.">BMEF</a>*&gt; ( 0 ),vec ( 0 ) ), <a class="code" href="classmerger.html#01e222f5df660e1b25c712e82da8df8f" title="Data link for each mpdf in mpdfs.">dls</a> ( <a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a> ), <a class="code" href="classmerger.html#e741e6096a7acec3dfa477efa1d8160e" title="Array of rvs that are not modelled by mpdfs at all (aux).">rvzs</a> ( <a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a> ), <a class="code" href="classmerger.html#d0ff2953f904f12a355f72f51813ca7a" title="Data Links of rv0 mpdfs - these will be conditioned the (rv,rvc) of mpdfs.">zdls</a> ( <a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a> ), <a class="code" href="classmerger.html#b13c9e8921e6bc6b8dd7bbafb54fa801" title="Projection to empirical density.">eSmp</a>(<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>,0) { 
     43<a name="l00053"></a>00053                 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> ztmp; 
     44<a name="l00054"></a>00054                 <span class="comment">// Extend rv by rvc!</span> 
     45<a name="l00055"></a>00055                 <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> rvc; <a class="code" href="classcompositepdf.html#5a4479785c1fdb2cc351fbea07b899ac" title="common rvc of all mpdfs is written to rvc">setrvc</a> ( <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>,rvc ); 
     46<a name="l00056"></a>00056                 <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>.<a class="code" href="classRV.html#935790526b630dec4ffefa9ec0c2b6fb" title="Add (concat) another variable to the current one,.">add</a> ( rvc ); 
     47<a name="l00057"></a>00057                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i&lt;<a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a>;i++ ) { 
     48<a name="l00058"></a>00058                         <span class="comment">//Establich connection between mpdfs and merger</span> 
     49<a name="l00059"></a>00059                         <a class="code" href="classmerger.html#01e222f5df660e1b25c712e82da8df8f" title="Data link for each mpdf in mpdfs.">dls</a> ( i ) = <span class="keyword">new</span> <a class="code" href="classdatalink__m2e.html" title="data link between">datalink_m2e</a> ( <a class="code" href="classcompositepdf.html#637877061b917a16a0421bb5c4cd480d" title="Elements of composition.">mpdfs</a> ( i )-&gt;<a class="code" href="classepdf.html#ca0d32aabb4cbba347e0c37fe8607562" title="access function, possibly dangerous!">_rv</a>(), <a class="code" href="classcompositepdf.html#637877061b917a16a0421bb5c4cd480d" title="Elements of composition.">mpdfs</a> ( i )-&gt;_rvc(), <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ); 
     50<a name="l00060"></a>00060                         <span class="comment">// find out what is missing in each mpdf</span> 
     51<a name="l00061"></a>00061                         ztmp= <a class="code" href="classcompositepdf.html#637877061b917a16a0421bb5c4cd480d" title="Elements of composition.">mpdfs</a> ( i )-&gt;_rv(); 
     52<a name="l00062"></a>00062                         ztmp.<a class="code" href="classRV.html#935790526b630dec4ffefa9ec0c2b6fb" title="Add (concat) another variable to the current one,.">add</a> ( <a class="code" href="classcompositepdf.html#637877061b917a16a0421bb5c4cd480d" title="Elements of composition.">mpdfs</a> ( i )-&gt;_rvc() ); 
     53<a name="l00063"></a>00063                         <a class="code" href="classmerger.html#e741e6096a7acec3dfa477efa1d8160e" title="Array of rvs that are not modelled by mpdfs at all (aux).">rvzs</a> ( i ) =<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>.<a class="code" href="classRV.html#b9d175c327c21488b1e2fb756a84e149" title="Subtract another variable from the current one.">subt</a> ( ztmp ); 
     54<a name="l00064"></a>00064                         <a class="code" href="classmerger.html#d0ff2953f904f12a355f72f51813ca7a" 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="classdatalink__m2e.html" title="data link between">datalink_m2e</a> ( <a class="code" href="classmerger.html#e741e6096a7acec3dfa477efa1d8160e" title="Array of rvs that are not modelled by mpdfs at all (aux).">rvzs</a> ( i ), ztmp, <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ) ; 
     55<a name="l00065"></a>00065                 }; 
     56<a name="l00066"></a>00066                 <span class="comment">//Set Default values of parameters</span> 
     57<a name="l00067"></a>00067                 <a class="code" href="classmerger.html#e68a72e2740007ae68545e378c7701ad" title="Prior on the log-normal merging model.">beta</a>=2.0; 
     58<a name="l00068"></a>00068                 <a class="code" href="classmerger.html#ce84de1824875b4262eefb640e8c6d69" title="Number of samples used in approximation.">Ns</a>=100; 
     59<a name="l00069"></a>00069                 <a class="code" href="classmerger.html#6acf33e1c64aaaee20689725e8110f65" title="Number of components in a mixture.">Nc</a>=10; 
     60<a name="l00070"></a>00070                 <a class="code" href="classmerger.html#021d1522cea70db8545d708afd32ec2f" title="Internal mixture of EF models.">Mix</a>.<a class="code" href="classMixEF.html#6576024e16523da5cbaaf233512c53dc" title="Set which method is to be used.">set_method</a> ( EM ); 
     61<a name="l00071"></a>00071         } 
     62<a name="l00073"></a><a class="code" href="classmerger.html#79420e251308df4502c834171d518ad9">00073</a>         <span class="keywordtype">void</span> <a class="code" href="classmerger.html#79420e251308df4502c834171d518ad9" 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="classmerger.html#e68a72e2740007ae68545e378c7701ad" title="Prior on the log-normal merging model.">beta</a>=beta0;<a class="code" href="classmerger.html#ce84de1824875b4262eefb640e8c6d69" title="Number of samples used in approximation.">Ns</a>=Ns0;<a class="code" href="classmerger.html#6acf33e1c64aaaee20689725e8110f65" title="Number of components in a mixture.">Nc</a>=Nc0;<a class="code" href="classmerger.html#b13c9e8921e6bc6b8dd7bbafb54fa801" title="Projection to empirical density.">eSmp</a>.<a class="code" href="classeEmp.html#a4215f6a5a04d07b43f7ebaa942e15f1" title="Set sample.">set_n</a>(Ns0,<span class="keyword">false</span>);} 
     63<a name="l00075"></a><a class="code" href="classmerger.html#02d2a445e44a87f37ee3a2b9b40cffd1">00075</a>         <span class="keywordtype">void</span> <a class="code" href="classmerger.html#02d2a445e44a87f37ee3a2b9b40cffd1" title="Initialize the proposal density. This function must be called before merge()!">init</a>() {  
     64<a name="l00076"></a>00076                 Array&lt;vec&gt; Smps ( <a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a> ); 
     65<a name="l00077"></a>00077                 <span class="comment">//Gibbs sampling</span> 
     66<a name="l00078"></a>00078                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i&lt;<a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a>;i++ ) {Smps ( i ) =zeros ( 0 );} 
     67<a name="l00079"></a>00079         } 
     68<a name="l00081"></a>00081         <span class="keywordtype">void</span> <a class="code" href="classmerger.html#bc23accc77ec766bce7202934e2c180c" 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="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>* g0 ); 
     69<a name="l00083"></a><a class="code" href="classmerger.html#bc23accc77ec766bce7202934e2c180c">00083</a>         <span class="keywordtype">void</span> <a class="code" href="classmerger.html#bc23accc77ec766bce7202934e2c180c" title="Create a mixture density, make sure to call init() before the first call.">merge</a> () {<a class="code" href="classmerger.html#bc23accc77ec766bce7202934e2c180c" title="Create a mixture density, make sure to call init() before the first call.">merge</a> ( &amp; ( <a class="code" href="classmerger.html#021d1522cea70db8545d708afd32ec2f" title="Internal mixture of EF models.">Mix</a>.<a class="code" href="classMixEF.html#efb3e20c2151d91c4fc080b7722a2069" title="Returns a reference to the epdf representing posterior density on parameters.">_epdf</a>() ) );}; 
     70<a name="l00084"></a>00084  
     71<a name="l00086"></a>00086         vec <a class="code" href="classmerger.html#217c65f335c603033fa09a2ecc64bc05" title="Merge log-likelihood values.">lognorm_merge</a> ( mat &amp;lW ); 
     72<a name="l00089"></a><a class="code" href="classmerger.html#379198c3d2063bfa63f5d1245a2511ba">00089</a>         vec <a class="code" href="classmerger.html#379198c3d2063bfa63f5d1245a2511ba">sample</a> ( )<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classmerger.html#021d1522cea70db8545d708afd32ec2f" title="Internal mixture of EF models.">Mix</a>.<a class="code" href="classMixEF.html#efb3e20c2151d91c4fc080b7722a2069" title="Returns a reference to the epdf representing posterior density on parameters.">_epdf</a>().<a class="code" href="classepdf.html#8019654e494bf5e458f6fb947e11b262" title="Returns a sample,  from density .">sample</a>();} 
     73<a name="l00090"></a><a class="code" href="classmerger.html#8c37688902b1a1e9fa32edc5709e5a00">00090</a>         <span class="keywordtype">double</span> <a class="code" href="classmerger.html#8c37688902b1a1e9fa32edc5709e5a00" title="Compute log-probability of argument val.">evalpdflog</a> ( <span class="keyword">const</span> vec &amp;dt )<span class="keyword"> const </span>{ 
     74<a name="l00091"></a>00091                 vec dtf=ones ( dt.length() +1 ); 
     75<a name="l00092"></a>00092                 dtf.set_subvector ( 0,dt ); 
     76<a name="l00093"></a>00093                 <span class="keywordflow">return</span> <a class="code" href="classmerger.html#021d1522cea70db8545d708afd32ec2f" title="Internal mixture of EF models.">Mix</a>.<a class="code" href="classMixEF.html#424ca64f36d4e41de7a7e7ae921d35ea">logpred</a> ( dtf ); 
     77<a name="l00094"></a>00094         } 
     78<a name="l00095"></a><a class="code" href="classmerger.html#3a46999cd77047d5d4ac6c1cb735a83e">00095</a>         vec <a class="code" href="classmerger.html#3a46999cd77047d5d4ac6c1cb735a83e" title="return expected value">mean</a>()<span class="keyword"> const </span>{ 
     79<a name="l00096"></a>00096                 <span class="keyword">const</span> Vec&lt;double&gt; &amp;w = <a class="code" href="classmerger.html#b13c9e8921e6bc6b8dd7bbafb54fa801" title="Projection to empirical density.">eSmp</a>.<a class="code" href="classeEmp.html#31b2bfb73b72486a5c89f2ab850c7a9b" title="Potentially dangerous, use with care.">_w</a>(); 
     80<a name="l00097"></a>00097                 <span class="keyword">const</span> Array&lt;vec&gt; &amp;S = <a class="code" href="classmerger.html#b13c9e8921e6bc6b8dd7bbafb54fa801" title="Projection to empirical density.">eSmp</a>.<a class="code" href="classeEmp.html#31b747eca73b16f30370827ba4cc3575" title="access function">_samples</a>(); 
     81<a name="l00098"></a>00098                 vec tmp=zeros ( <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>() );  
     82<a name="l00099"></a>00099                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i&lt;<a class="code" href="classmerger.html#ce84de1824875b4262eefb640e8c6d69" title="Number of samples used in approximation.">Ns</a>; i++ ) { 
     83<a name="l00100"></a>00100                         tmp+=w ( i ) *S ( i ); 
     84<a name="l00101"></a>00101                 } 
     85<a name="l00102"></a>00102                 <span class="keywordflow">return</span> tmp; 
     86<a name="l00103"></a>00103         } 
     87<a name="l00104"></a>00104         mat variance()<span class="keyword"> const </span>{ 
     88<a name="l00105"></a>00105                 <span class="keyword">const</span> vec &amp;w = <a class="code" href="classmerger.html#b13c9e8921e6bc6b8dd7bbafb54fa801" title="Projection to empirical density.">eSmp</a>.<a class="code" href="classeEmp.html#31b2bfb73b72486a5c89f2ab850c7a9b" title="Potentially dangerous, use with care.">_w</a>(); 
     89<a name="l00106"></a>00106                 <span class="keyword">const</span> Array&lt;vec&gt; &amp;S = <a class="code" href="classmerger.html#b13c9e8921e6bc6b8dd7bbafb54fa801" title="Projection to empirical density.">eSmp</a>.<a class="code" href="classeEmp.html#31b747eca73b16f30370827ba4cc3575" title="access function">_samples</a>(); 
     90<a name="l00107"></a>00107                  
     91<a name="l00108"></a>00108                 vec mea = <a class="code" href="classmerger.html#3a46999cd77047d5d4ac6c1cb735a83e" title="return expected value">mean</a>();  
     92<a name="l00109"></a>00109                  
     93<a name="l00110"></a>00110                 cout &lt;&lt; sum(w) &lt;&lt; <span class="stringliteral">","</span> &lt;&lt; w*w &lt;&lt;endl; 
     94<a name="l00111"></a>00111                  
     95<a name="l00112"></a>00112                 mat Tmp=zeros(<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>(), <a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a>.<a class="code" href="classRV.html#f5c7b8bd589eef09ccdf3329a0addea0" title="Return number of scalars in the RV.">count</a>()); 
     96<a name="l00113"></a>00113                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i&lt;<a class="code" href="classmerger.html#ce84de1824875b4262eefb640e8c6d69" title="Number of samples used in approximation.">Ns</a>; i++ ) { 
     97<a name="l00114"></a>00114                         Tmp+=w ( i ) *outer_product(S ( i ), S(i)); 
     98<a name="l00115"></a>00115                 } 
     99<a name="l00116"></a>00116                 <span class="keywordflow">return</span> Tmp-outer_product(mea,mea); 
     100<a name="l00117"></a>00117         } 
     101<a name="l00119"></a><a class="code" href="classmerger.html#51e425ee1dd46d73353526e6a1c24ca3">00119</a>         <span class="keyword">virtual</span> <a class="code" href="classmerger.html#51e425ee1dd46d73353526e6a1c24ca3" title="for future use">~merger</a>() { 
     102<a name="l00120"></a>00120                 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i&lt;<a class="code" href="classcompositepdf.html#c1646fe41ff5934d010e54ccaa46133f" title="Number of mpdfs in the composite.">n</a>; i++ ) { 
     103<a name="l00121"></a>00121                         <span class="keyword">delete</span> <a class="code" href="classmerger.html#01e222f5df660e1b25c712e82da8df8f" title="Data link for each mpdf in mpdfs.">dls</a> ( i ); 
     104<a name="l00122"></a>00122                         <span class="keyword">delete</span> <a class="code" href="classmerger.html#d0ff2953f904f12a355f72f51813ca7a" title="Data Links of rv0 mpdfs - these will be conditioned the (rv,rvc) of mpdfs.">zdls</a> ( i ); 
     105<a name="l00123"></a>00123                 } 
     106<a name="l00124"></a>00124         }; 
     107<a name="l00125"></a>00125  
     108<a name="l00127"></a><a class="code" href="classmerger.html#6e430acd4eb7eea6078df0eb0a429821">00127</a>         <a class="code" href="classMixEF.html" title="Mixture of Exponential Family Densities.">MixEF</a>&amp; <a class="code" href="classmerger.html#6e430acd4eb7eea6078df0eb0a429821" title="Access function.">_Mix</a>() {<span class="keywordflow">return</span> <a class="code" href="classmerger.html#021d1522cea70db8545d708afd32ec2f" title="Internal mixture of EF models.">Mix</a>;} 
     109<a name="l00129"></a><a class="code" href="classmerger.html#f79677063ec72cdc175280a3fae8ebc2">00129</a>         <a class="code" href="classeEmp.html" title="Weighted empirical density.">eEmp</a>&amp; <a class="code" href="classmerger.html#f79677063ec72cdc175280a3fae8ebc2" title="Access function.">_Smp</a>() {<span class="keywordflow">return</span> <a class="code" href="classmerger.html#b13c9e8921e6bc6b8dd7bbafb54fa801" title="Projection to empirical density.">eSmp</a>;} 
     110<a name="l00130"></a>00130 }; 
     111<a name="l00131"></a>00131  
     112<a name="l00132"></a>00132  
     113<a name="l00133"></a>00133  
     114<a name="l00134"></a>00134 <span class="preprocessor">#endif // MER_H</span> 
    57115</pre></div></div> 
    58 <hr size="1"><address style="text-align: right;"><small>Generated on Wed Oct 15 15:57:09 2008 for mixpp by&nbsp; 
     116<hr size="1"><address style="text-align: right;"><small>Generated on Wed Nov 12 20:46:05 2008 for mixpp by&nbsp; 
    59117<a href="http://www.doxygen.org/index.html"> 
    60118<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>