[171] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
---|
| 2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
---|
[261] | 3 | <title>mixpp: mixef.h Source File</title> |
---|
[171] | 4 | <link href="doxygen.css" rel="stylesheet" type="text/css"> |
---|
| 5 | <link href="tabs.css" rel="stylesheet" type="text/css"> |
---|
| 6 | </head><body> |
---|
| 7 | <!-- Generated by Doxygen 1.5.6 --> |
---|
| 8 | <div class="navigation" id="top"> |
---|
| 9 | <div class="tabs"> |
---|
| 10 | <ul> |
---|
| 11 | <li><a href="index.html"><span>Main Page</span></a></li> |
---|
| 12 | <li><a href="pages.html"><span>Related Pages</span></a></li> |
---|
[219] | 13 | <li><a href="modules.html"><span>Modules</span></a></li> |
---|
[261] | 14 | <li><a href="namespaces.html"><span>Namespaces</span></a></li> |
---|
| 15 | <li><a href="classes.html"><span>Classes</span></a></li> |
---|
[171] | 16 | <li class="current"><a href="files.html"><span>Files</span></a></li> |
---|
| 17 | </ul> |
---|
| 18 | </div> |
---|
[261] | 19 | <h1>mixef.h</h1><a href="mixef_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 |
---|
[171] | 20 | <a name="l00013"></a>00013 <span class="preprocessor">#ifndef MEF_H</span> |
---|
| 21 | <a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define MEF_H</span> |
---|
| 22 | <a name="l00015"></a>00015 <span class="preprocessor"></span> |
---|
[261] | 23 | <a name="l00016"></a>00016 |
---|
[171] | 24 | <a name="l00017"></a>00017 <span class="preprocessor">#include "../stat/libFN.h"</span> |
---|
| 25 | <a name="l00018"></a>00018 <span class="preprocessor">#include "../stat/libEF.h"</span> |
---|
| 26 | <a name="l00019"></a>00019 <span class="preprocessor">#include "../stat/emix.h"</span> |
---|
| 27 | <a name="l00020"></a>00020 |
---|
[255] | 28 | <a name="l00021"></a>00021 <span class="keyword">namespace </span>bdm{ |
---|
[171] | 29 | <a name="l00022"></a>00022 |
---|
[210] | 30 | <a name="l00023"></a>00023 <span class="keyword">enum</span> MixEF_METHOD { EM = 0, QB = 1}; |
---|
| 31 | <a name="l00024"></a>00024 |
---|
[255] | 32 | <a name="l00041"></a><a class="code" href="classbdm_1_1MixEF.html">00041</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1MixEF.html" title="Mixture of Exponential Family Densities.">MixEF</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a> { |
---|
[210] | 33 | <a name="l00042"></a>00042 <span class="keyword">protected</span>: |
---|
[255] | 34 | <a name="l00044"></a><a class="code" href="classbdm_1_1MixEF.html#38ca1d86e977d1c38810a3c95bf074a5">00044</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1MixEF.html#38ca1d86e977d1c38810a3c95bf074a5" title="Number of components.">n</a>; |
---|
| 35 | <a name="l00046"></a><a class="code" href="classbdm_1_1MixEF.html#90c21ab5a2af56d4b49e2eaef6eccc08">00046</a> Array<BMEF*> <a class="code" href="classbdm_1_1MixEF.html#90c21ab5a2af56d4b49e2eaef6eccc08" title="Models for Components of .">Coms</a>; |
---|
| 36 | <a name="l00048"></a><a class="code" href="classbdm_1_1MixEF.html#e39faa70cebadc3296bd249040105e86">00048</a> <a class="code" href="classbdm_1_1multiBM.html" title="Estimator for Multinomial density.">multiBM</a> <a class="code" href="classbdm_1_1MixEF.html#e39faa70cebadc3296bd249040105e86" title="Statistics for weights.">weights</a>; |
---|
| 37 | <a name="l00050"></a><a class="code" href="classbdm_1_1MixEF.html#9413fb7f1836237aac807fb9f245e4f6">00050</a> <a class="code" href="classbdm_1_1eprod.html" title="Product of independent epdfs. For dependent pdfs, use mprod.">eprod</a>* <a class="code" href="classbdm_1_1MixEF.html#9413fb7f1836237aac807fb9f245e4f6" title="Posterior on component parameters.">est</a>; |
---|
[210] | 38 | <a name="l00052"></a>00052 |
---|
[255] | 39 | <a name="l00054"></a><a class="code" href="classbdm_1_1MixEF.html#a2376ddadb7573532404452d0c2dd28a">00054</a> MixEF_METHOD <a class="code" href="classbdm_1_1MixEF.html#a2376ddadb7573532404452d0c2dd28a" title="Flag for a method that is used in the inference.">method</a>; |
---|
[210] | 40 | <a name="l00055"></a>00055 |
---|
[255] | 41 | <a name="l00057"></a><a class="code" href="classbdm_1_1MixEF.html#d74a8d1370c63c93ec554908ae3e6006">00057</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1MixEF.html#d74a8d1370c63c93ec554908ae3e6006" title="Auxiliary function for use in constructors.">build_est</a>() { |
---|
| 42 | <a name="l00058"></a>00058 Array<const epdf*> epdfs ( <a class="code" href="classbdm_1_1MixEF.html#38ca1d86e977d1c38810a3c95bf074a5" title="Number of components.">n</a>+1 ); |
---|
| 43 | <a name="l00059"></a>00059 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1MixEF.html#90c21ab5a2af56d4b49e2eaef6eccc08" title="Models for Components of .">Coms</a>.length();i++ ) { |
---|
[210] | 44 | <a name="l00060"></a>00060 <span class="comment">// it_assert_debug(!x,"MixEF::MixEF : Incompatible components");</span> |
---|
[255] | 45 | <a name="l00061"></a>00061 epdfs ( i ) =& ( <a class="code" href="classbdm_1_1MixEF.html#90c21ab5a2af56d4b49e2eaef6eccc08" title="Models for Components of .">Coms</a> ( i )->_epdf() ); |
---|
[210] | 46 | <a name="l00062"></a>00062 } |
---|
| 47 | <a name="l00063"></a>00063 <span class="comment">// last in the product is the weight</span> |
---|
[255] | 48 | <a name="l00064"></a>00064 epdfs ( <a class="code" href="classbdm_1_1MixEF.html#38ca1d86e977d1c38810a3c95bf074a5" title="Number of components.">n</a> ) =& ( <a class="code" href="classbdm_1_1MixEF.html#e39faa70cebadc3296bd249040105e86" title="Statistics for weights.">weights</a>.<a class="code" href="classbdm_1_1multiBM.html#98c22316ecfef589989baca261713c8d" title="Returns a reference to the epdf representing posterior density on parameters.">_epdf</a>() ); |
---|
| 49 | <a name="l00065"></a>00065 <a class="code" href="classbdm_1_1MixEF.html#9413fb7f1836237aac807fb9f245e4f6" title="Posterior on component parameters.">est</a> = <span class="keyword">new</span> <a class="code" href="classbdm_1_1eprod.html" title="Product of independent epdfs. For dependent pdfs, use mprod.">eprod</a> ( epdfs ); |
---|
[210] | 50 | <a name="l00066"></a>00066 } |
---|
| 51 | <a name="l00067"></a>00067 |
---|
| 52 | <a name="l00068"></a>00068 <span class="keyword">public</span>: |
---|
[255] | 53 | <a name="l00070"></a><a class="code" href="classbdm_1_1MixEF.html#4efe67d414ff34a1e7534004fd061241">00070</a> <a class="code" href="classbdm_1_1MixEF.html#0266854387338ba757e6192d62907984" title="Constructor of empty mixture.">MixEF</a> ( <span class="keyword">const</span> Array<BMEF*> &Coms0, <span class="keyword">const</span> vec &alpha0 ) : |
---|
| 54 | <a name="l00071"></a>00071 <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a> ( <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a>() ), <a class="code" href="classbdm_1_1MixEF.html#38ca1d86e977d1c38810a3c95bf074a5" title="Number of components.">n</a> ( Coms0.length() ), <a class="code" href="classbdm_1_1MixEF.html#90c21ab5a2af56d4b49e2eaef6eccc08" title="Models for Components of .">Coms</a> ( <a class="code" href="classbdm_1_1MixEF.html#38ca1d86e977d1c38810a3c95bf074a5" title="Number of components.">n</a> ), |
---|
| 55 | <a name="l00072"></a>00072 <a class="code" href="classbdm_1_1MixEF.html#e39faa70cebadc3296bd249040105e86" title="Statistics for weights.">weights</a> ( <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> ( <span class="stringliteral">"{w }"</span>, vec_1 ( <a class="code" href="classbdm_1_1MixEF.html#38ca1d86e977d1c38810a3c95bf074a5" title="Number of components.">n</a> ) ),alpha0 ), <a class="code" href="classbdm_1_1MixEF.html#a2376ddadb7573532404452d0c2dd28a" title="Flag for a method that is used in the inference.">method</a>(QB) { |
---|
[210] | 56 | <a name="l00073"></a>00073 <span class="comment">// it_assert_debug ( n>0,"MixEF::MixEF : Empty Component list" );</span> |
---|
| 57 | <a name="l00074"></a>00074 |
---|
[255] | 58 | <a name="l00075"></a>00075 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1MixEF.html#38ca1d86e977d1c38810a3c95bf074a5" title="Number of components.">n</a>;i++ ) {<a class="code" href="classbdm_1_1MixEF.html#90c21ab5a2af56d4b49e2eaef6eccc08" title="Models for Components of .">Coms</a> ( i ) = ( <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a>* ) Coms0 ( i )->_copy_();} |
---|
| 59 | <a name="l00076"></a>00076 <a class="code" href="classbdm_1_1MixEF.html#d74a8d1370c63c93ec554908ae3e6006" title="Auxiliary function for use in constructors.">build_est</a>(); |
---|
[210] | 60 | <a name="l00077"></a>00077 }; |
---|
[255] | 61 | <a name="l00079"></a><a class="code" href="classbdm_1_1MixEF.html#0266854387338ba757e6192d62907984">00079</a> <a class="code" href="classbdm_1_1MixEF.html#0266854387338ba757e6192d62907984" title="Constructor of empty mixture.">MixEF</a> () : |
---|
| 62 | <a name="l00080"></a>00080 <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a> ( <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a>() ), <a class="code" href="classbdm_1_1MixEF.html#38ca1d86e977d1c38810a3c95bf074a5" title="Number of components.">n</a> ( 0 ), <a class="code" href="classbdm_1_1MixEF.html#90c21ab5a2af56d4b49e2eaef6eccc08" title="Models for Components of .">Coms</a> ( 0 ), |
---|
| 63 | <a name="l00081"></a>00081 <a class="code" href="classbdm_1_1MixEF.html#e39faa70cebadc3296bd249040105e86" title="Statistics for weights.">weights</a> ( <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> ( <span class="stringliteral">"{w }"</span>, vec_1 ( 0 ) ),vec ( 0 ) ),<a class="code" href="classbdm_1_1MixEF.html#a2376ddadb7573532404452d0c2dd28a" title="Flag for a method that is used in the inference.">method</a>(QB) {<a class="code" href="classbdm_1_1MixEF.html#d74a8d1370c63c93ec554908ae3e6006" title="Auxiliary function for use in constructors.">build_est</a>();} |
---|
| 64 | <a name="l00083"></a><a class="code" href="classbdm_1_1MixEF.html#9577de85c3e3481f7c0e23cf8f87c482">00083</a> <a class="code" href="classbdm_1_1MixEF.html#0266854387338ba757e6192d62907984" title="Constructor of empty mixture.">MixEF</a>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1MixEF.html" title="Mixture of Exponential Family Densities.">MixEF</a> &M2): <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a> ( <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a>() ), <a class="code" href="classbdm_1_1MixEF.html#38ca1d86e977d1c38810a3c95bf074a5" title="Number of components.">n</a> ( M2.<a class="code" href="classbdm_1_1MixEF.html#38ca1d86e977d1c38810a3c95bf074a5" title="Number of components.">n</a> ), <a class="code" href="classbdm_1_1MixEF.html#90c21ab5a2af56d4b49e2eaef6eccc08" title="Models for Components of .">Coms</a> ( <a class="code" href="classbdm_1_1MixEF.html#38ca1d86e977d1c38810a3c95bf074a5" title="Number of components.">n</a> ), |
---|
| 65 | <a name="l00084"></a>00084 <a class="code" href="classbdm_1_1MixEF.html#e39faa70cebadc3296bd249040105e86" title="Statistics for weights.">weights</a> ( M2.<a class="code" href="classbdm_1_1MixEF.html#e39faa70cebadc3296bd249040105e86" title="Statistics for weights.">weights</a> ), <a class="code" href="classbdm_1_1MixEF.html#a2376ddadb7573532404452d0c2dd28a" title="Flag for a method that is used in the inference.">method</a>(M2.<a class="code" href="classbdm_1_1MixEF.html#a2376ddadb7573532404452d0c2dd28a" title="Flag for a method that is used in the inference.">method</a>) { |
---|
[210] | 66 | <a name="l00085"></a>00085 <span class="comment">// it_assert_debug ( n>0,"MixEF::MixEF : Empty Component list" );</span> |
---|
| 67 | <a name="l00086"></a>00086 |
---|
[255] | 68 | <a name="l00087"></a>00087 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1MixEF.html#38ca1d86e977d1c38810a3c95bf074a5" title="Number of components.">n</a>;i++ ) {<a class="code" href="classbdm_1_1MixEF.html#90c21ab5a2af56d4b49e2eaef6eccc08" title="Models for Components of .">Coms</a> ( i ) = M2.<a class="code" href="classbdm_1_1MixEF.html#90c21ab5a2af56d4b49e2eaef6eccc08" title="Models for Components of .">Coms</a> ( i )->_copy_();} |
---|
| 69 | <a name="l00088"></a>00088 <a class="code" href="classbdm_1_1MixEF.html#d74a8d1370c63c93ec554908ae3e6006" title="Auxiliary function for use in constructors.">build_est</a>(); |
---|
[210] | 70 | <a name="l00089"></a>00089 } |
---|
[255] | 71 | <a name="l00094"></a>00094 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1MixEF.html#0c2a50789b30769964a909d217125ed2">init</a> ( <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a>* Com0, <span class="keyword">const</span> mat &Data, <span class="keywordtype">int</span> c=5 ); |
---|
[210] | 72 | <a name="l00095"></a>00095 <span class="comment">//Destructor</span> |
---|
[255] | 73 | <a name="l00096"></a>00096 ~<a class="code" href="classbdm_1_1MixEF.html" title="Mixture of Exponential Family Densities.">MixEF</a>() { |
---|
| 74 | <a name="l00097"></a>00097 <span class="keyword">delete</span> <a class="code" href="classbdm_1_1MixEF.html#9413fb7f1836237aac807fb9f245e4f6" title="Posterior on component parameters.">est</a>; |
---|
| 75 | <a name="l00098"></a>00098 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1MixEF.html#38ca1d86e977d1c38810a3c95bf074a5" title="Number of components.">n</a>;i++ ) {<span class="keyword">delete</span> <a class="code" href="classbdm_1_1MixEF.html#90c21ab5a2af56d4b49e2eaef6eccc08" title="Models for Components of .">Coms</a> ( i );} |
---|
[210] | 76 | <a name="l00099"></a>00099 } |
---|
[255] | 77 | <a name="l00101"></a>00101 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1MixEF.html#5bd7da667da183eed1577f11dff0c1f1" title="Recursive EM-like algorithm (QB-variant), see Karny et. al, 2006.">bayes</a> ( <span class="keyword">const</span> vec &dt ); |
---|
| 78 | <a name="l00103"></a>00103 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1MixEF.html#5bd7da667da183eed1577f11dff0c1f1" title="Recursive EM-like algorithm (QB-variant), see Karny et. al, 2006.">bayes</a> ( <span class="keyword">const</span> mat &dt ); |
---|
[210] | 79 | <a name="l00104"></a>00104 <span class="keywordtype">void</span> bayesB ( <span class="keyword">const</span> mat &dt, <span class="keyword">const</span> vec &wData ); |
---|
[255] | 80 | <a name="l00105"></a>00105 <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1MixEF.html#da724da464a75e07521941e430929efa">logpred</a> ( <span class="keyword">const</span> vec &dt ) <span class="keyword">const</span>; |
---|
| 81 | <a name="l00106"></a><a class="code" href="classbdm_1_1MixEF.html#33d0b3da1d10bf149d41ee74f6284a19">00106</a> <span class="keyword">const</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>& <a class="code" href="classbdm_1_1MixEF.html#33d0b3da1d10bf149d41ee74f6284a19" title="Returns a reference to the epdf representing posterior density on parameters.">_epdf</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> *<a class="code" href="classbdm_1_1MixEF.html#9413fb7f1836237aac807fb9f245e4f6" title="Posterior on component parameters.">est</a>;} |
---|
| 82 | <a name="l00107"></a><a class="code" href="classbdm_1_1MixEF.html#ea8be6f0703d87b7c4c3e77fd07e28c8">00107</a> <span class="keyword">const</span> <a class="code" href="classbdm_1_1eprod.html" title="Product of independent epdfs. For dependent pdfs, use mprod.">eprod</a>* <a class="code" href="classbdm_1_1MixEF.html#ea8be6f0703d87b7c4c3e77fd07e28c8" title="Returns a pointer to the epdf representing posterior density on parameters. Use with...">_e</a>()<span class="keyword"> const </span>{<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1MixEF.html#9413fb7f1836237aac807fb9f245e4f6" title="Posterior on component parameters.">est</a>;} |
---|
| 83 | <a name="l00108"></a>00108 <a class="code" href="classbdm_1_1emix.html" title="Mixture of epdfs.">emix</a>* <a class="code" href="classbdm_1_1MixEF.html#5105973c0f790f08d1dfb79c2a3f6e1c" title="Constructs a predictive density (marginal density on data).">predictor</a>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> &<a class="code" href="classbdm_1_1BM.html#18d6db4af8ee42077741d9e3618153ca" title="Random variable of the posterior.">rv</a>) <span class="keyword">const</span>; |
---|
| 84 | <a name="l00110"></a>00110 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1MixEF.html#f0dfb4375fef4e61c4cb062e5bac7c8c" title="Flatten the density as if it was not estimated from the data.">flatten</a>(<span class="keyword">const</span> <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a>* M2); |
---|
| 85 | <a name="l00112"></a><a class="code" href="classbdm_1_1MixEF.html#251ef6fc51757712693da5faae5317c9">00112</a> <a class="code" href="classbdm_1_1BMEF.html" title="Estimator for Exponential family.">BMEF</a>* <a class="code" href="classbdm_1_1MixEF.html#251ef6fc51757712693da5faae5317c9" title="Access function.">_Coms</a>(<span class="keywordtype">int</span> i){<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1MixEF.html#90c21ab5a2af56d4b49e2eaef6eccc08" title="Models for Components of .">Coms</a>(i);} |
---|
[210] | 86 | <a name="l00113"></a>00113 |
---|
[255] | 87 | <a name="l00115"></a><a class="code" href="classbdm_1_1MixEF.html#664529d52cc667383b39eeb440ccd577">00115</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1MixEF.html#664529d52cc667383b39eeb440ccd577" title="Set which method is to be used.">set_method</a>(MixEF_METHOD M){<a class="code" href="classbdm_1_1MixEF.html#a2376ddadb7573532404452d0c2dd28a" title="Flag for a method that is used in the inference.">method</a>=M;} |
---|
[210] | 88 | <a name="l00116"></a>00116 }; |
---|
| 89 | <a name="l00117"></a>00117 |
---|
[255] | 90 | <a name="l00118"></a>00118 } |
---|
[210] | 91 | <a name="l00119"></a>00119 <span class="preprocessor">#endif // MEF_H</span> |
---|
| 92 | <a name="l00120"></a>00120 <span class="preprocessor"></span> |
---|
| 93 | <a name="l00121"></a>00121 |
---|
[171] | 94 | </pre></div></div> |
---|
[269] | 95 | <hr size="1"><address style="text-align: right;"><small>Generated on Wed Feb 11 10:20:05 2009 for mixpp by |
---|
[171] | 96 | <a href="http://www.doxygen.org/index.html"> |
---|
| 97 | <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address> |
---|
| 98 | </body> |
---|
| 99 | </html> |
---|