root/doc/html/emix_8h-source.html @ 129

Revision 106, 7.0 kB (checked in by smidl, 16 years ago)

doc

Line 
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">
3<title>mixpp: work/mixpp/bdm/stat/emix.h Source File</title>
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.5 -->
8<div class="navigation" id="top">
9  <div class="tabs">
10    <ul>
11      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
12      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
13      <li><a href="annotated.html"><span>Classes</span></a></li>
14      <li class="current"><a href="files.html"><span>Files</span></a></li>
15    </ul>
16  </div>
17<h1>work/mixpp/bdm/stat/emix.h</h1><a href="emix_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
18<a name="l00013"></a>00013 <span class="preprocessor">#ifndef MX_H</span>
19<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define MX_H</span>
20<a name="l00015"></a>00015 <span class="preprocessor"></span>
21<a name="l00016"></a>00016 <span class="preprocessor">#include "<a class="code" href="libBM_8h.html" title="Bayesian Models (bm) that use Bayes rule to learn from observations.">libBM.h</a>"</span>
22<a name="l00017"></a>00017 <span class="preprocessor">#include "<a class="code" href="libEF_8h.html" title="Probability distributions for Exponential Family models.">libEF.h</a>"</span>
23<a name="l00018"></a>00018 <span class="comment">//#include &lt;std&gt;</span>
24<a name="l00019"></a>00019
25<a name="l00020"></a>00020 <span class="keyword">using namespace </span>itpp;
26<a name="l00021"></a>00021
27<a name="l00032"></a><a class="code" href="classemix.html">00032</a> <span class="keyword">class </span><a class="code" href="classemix.html" title="Mixture of epdfs.">emix</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> {
28<a name="l00033"></a>00033 <span class="keyword">protected</span>:
29<a name="l00035"></a><a class="code" href="classemix.html#cdc8f4e2a5e43595ac5450d8a7f9d1ab">00035</a>         vec <a class="code" href="classemix.html#cdc8f4e2a5e43595ac5450d8a7f9d1ab" title="weights of the components">w</a>;
30<a name="l00037"></a><a class="code" href="classemix.html#7155d827417b53fb6aa5cff1459e6eb4">00037</a>         Array&lt;epdf*&gt; <a class="code" href="classemix.html#7155d827417b53fb6aa5cff1459e6eb4" title="Component (epdfs).">Coms</a>;
31<a name="l00038"></a>00038 <span class="keyword">public</span>:
32<a name="l00040"></a><a class="code" href="classemix.html#3a10c8481115a5460877272ddb6532a6">00040</a>         <a class="code" href="classemix.html#3a10c8481115a5460877272ddb6532a6" title="Default constructor.">emix</a> ( <a class="code" href="classRV.html" title="Class representing variables, most often random variables.">RV</a> &amp;<a class="code" href="classepdf.html#74da992e3f5d598da8850b646b79b9d9" title="Identified of the random variable.">rv</a> ): <a class="code" href="classepdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a>(rv){};
33<a name="l00042"></a>00042         <span class="keywordtype">void</span> <a class="code" href="classemix.html#6ce82b24d7fe540ddbf44b472a005555" title="Set weights w and components R.">set_parameters</a> ( <span class="keyword">const</span> vec &amp;<a class="code" href="classemix.html#cdc8f4e2a5e43595ac5450d8a7f9d1ab" title="weights of the components">w</a>, <span class="keyword">const</span> Array&lt;epdf*&gt; &amp;<a class="code" href="classemix.html#7155d827417b53fb6aa5cff1459e6eb4" title="Component (epdfs).">Coms</a> );
34<a name="l00043"></a>00043
35<a name="l00044"></a>00044         vec <a class="code" href="classemix.html#0650601f24e633e0ab09aa1e46c14483" title="Returns the required moment of the epdf.">sample</a>() <span class="keyword">const</span>;
36<a name="l00045"></a><a class="code" href="classemix.html#b662a51d042b062020460e64bff4e9e8">00045</a>         vec <a class="code" href="classemix.html#b662a51d042b062020460e64bff4e9e8" title="return expected value">mean</a>()<span class="keyword"> const </span>{
37<a name="l00046"></a>00046                 <span class="keywordtype">int</span> i; vec mu=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>() );
38<a name="l00047"></a>00047                 <span class="keywordflow">for</span> ( i=0;i&lt;<a class="code" href="classemix.html#cdc8f4e2a5e43595ac5450d8a7f9d1ab" title="weights of the components">w</a>.length();i++ ) {mu+=<a class="code" href="classemix.html#cdc8f4e2a5e43595ac5450d8a7f9d1ab" title="weights of the components">w</a> ( i ) *<a class="code" href="classemix.html#7155d827417b53fb6aa5cff1459e6eb4" title="Component (epdfs).">Coms</a> ( i )-&gt;mean(); }
39<a name="l00048"></a>00048                 <span class="keywordflow">return</span> mu;
40<a name="l00049"></a>00049         }
41<a name="l00050"></a><a class="code" href="classemix.html#469e910479b3402589104ef3bb1b5741">00050</a>         <span class="keywordtype">double</span> <a class="code" href="classemix.html#469e910479b3402589104ef3bb1b5741" title="Compute log-probability of argument val.">evalpdflog</a> ( <span class="keyword">const</span> vec &amp;val )<span class="keyword"> const </span>{<span class="keywordtype">int</span> i; <span class="keywordtype">double</span> sum=0.0; <span class="keywordflow">for</span> ( i=0;i&lt;<a class="code" href="classemix.html#cdc8f4e2a5e43595ac5450d8a7f9d1ab" title="weights of the components">w</a>.length();i++ ) {sum+=<a class="code" href="classemix.html#cdc8f4e2a5e43595ac5450d8a7f9d1ab" title="weights of the components">w</a> ( i ) *<a class="code" href="classemix.html#7155d827417b53fb6aa5cff1459e6eb4" title="Component (epdfs).">Coms</a> ( i )-&gt;evalpdflog ( val );} <span class="keywordflow">return</span> log ( sum );};
42<a name="l00051"></a>00051
43<a name="l00052"></a>00052 <span class="comment">//Access methods</span>
44<a name="l00054"></a><a class="code" href="classemix.html#35baf0f62307455cebfbf462144b4dd8">00054</a> <span class="comment"></span>        vec&amp; <a class="code" href="classemix.html#35baf0f62307455cebfbf462144b4dd8" title="returns a pointer to the internal mean value. Use with Care!">_w</a>() {<span class="keywordflow">return</span> <a class="code" href="classemix.html#cdc8f4e2a5e43595ac5450d8a7f9d1ab" title="weights of the components">w</a>;}
45<a name="l00055"></a>00055 };
46<a name="l00056"></a>00056
47<a name="l00057"></a>00057
48<a name="l00058"></a>00058 <span class="preprocessor">#endif //MX_H</span>
49</pre></div></div>
50<hr size="1"><address style="text-align: right;"><small>Generated on Fri May 9 23:06:27 2008 for mixpp by&nbsp;
51<a href="http://www.doxygen.org/index.html">
52<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.5 </small></address>
53</body>
54</html>
Note: See TracBrowser for help on using the browser.