126 | | <a name="l00169"></a>00169 <span class="keyword">public</span>: |
127 | | <a name="l00172"></a><a class="code" href="classbdm_1_1mprod.html#680c3e2d95b116c7cfb227c7f2984525">00172</a> <a class="code" href="classbdm_1_1mprod.html#680c3e2d95b116c7cfb227c7f2984525" title="Constructor from list of mFacs,.">mprod</a> ( Array<mpdf*> mFacs ) : <a class="code" href="classbdm_1_1compositepdf.html" title="Abstract composition of pdfs, will be used for specific classes this abstract class...">compositepdf</a> ( mFacs ), <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> (), <a class="code" href="classbdm_1_1mprod.html#eca722ed1b219727c6c0f8cbc6bf1e51" title="pointers to epdfs - shortcut to mpdfs()._epdf()">epdfs</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_1mprod.html#acf679b3b1d48629c5a042d9ac0d973f" title="Data link for each mpdfs.">dls</a> ( <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a> ) { |
128 | | <a name="l00173"></a>00173 <span class="comment">// setrvc ( ep->_rv(),_rvc() );</span> |
129 | | <a name="l00174"></a>00174 <span class="comment">// rv and rvc established = > we can link them with mpdfs</span> |
130 | | <a name="l00175"></a>00175 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0;i < <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a>;i++ ) { |
131 | | <a name="l00176"></a>00176 <a class="code" href="classbdm_1_1mprod.html#acf679b3b1d48629c5a042d9ac0d973f" title="Data link for each mpdfs.">dls</a> ( i ) = <span class="keyword">new</span> <a class="code" href="classbdm_1_1datalink__m2m.html">datalink_m2m</a> ( <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )->_rv(), <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )->_rvc(), _rv(), _rvc() ); |
132 | | <a name="l00177"></a>00177 } |
133 | | <a name="l00178"></a>00178 |
134 | | <a name="l00179"></a>00179 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<n;i++ ) { |
135 | | <a name="l00180"></a>00180 <a class="code" href="classbdm_1_1mprod.html#eca722ed1b219727c6c0f8cbc6bf1e51" title="pointers to epdfs - shortcut to mpdfs()._epdf()">epdfs</a> ( i ) =& ( <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )->_epdf() ); |
136 | | <a name="l00181"></a>00181 } |
137 | | <a name="l00182"></a>00182 }; |
| 166 | <a name="l00170"></a><a class="code" href="classbdm_1_1mprod.html#e3fe66c257e5eca9de1031ef44907677">00170</a> <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_1mprod.html#e3fe66c257e5eca9de1031ef44907677" title="dummy ep">dummy</a>; |
| 167 | <a name="l00171"></a>00171 <span class="keyword">public</span>: |
| 168 | <a name="l00174"></a><a class="code" href="classbdm_1_1mprod.html#680c3e2d95b116c7cfb227c7f2984525">00174</a> <a class="code" href="classbdm_1_1mprod.html#680c3e2d95b116c7cfb227c7f2984525" title="Constructor from list of mFacs,.">mprod</a> ( Array<mpdf*> mFacs ) : <a class="code" href="classbdm_1_1compositepdf.html" title="Abstract composition of pdfs, will be used for specific classes this abstract class...">compositepdf</a> ( mFacs ), <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> (), <a class="code" href="classbdm_1_1mprod.html#eca722ed1b219727c6c0f8cbc6bf1e51" title="pointers to epdfs - shortcut to mpdfs().posterior()">epdfs</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_1mprod.html#acf679b3b1d48629c5a042d9ac0d973f" title="Data link for each mpdfs.">dls</a> ( <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a> ) { |
| 169 | <a name="l00175"></a>00175 <a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>=&<a class="code" href="classbdm_1_1mprod.html#e3fe66c257e5eca9de1031ef44907677" title="dummy ep">dummy</a>; |
| 170 | <a name="l00176"></a>00176 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> rv=<a class="code" href="classbdm_1_1compositepdf.html#c73d39acc4378eee6a63155c3517d3c9" title="find common rv, flag">getrv</a>(<span class="keyword">true</span>); |
| 171 | <a name="l00177"></a>00177 set_rv(rv);<a class="code" href="classbdm_1_1mprod.html#e3fe66c257e5eca9de1031ef44907677" title="dummy ep">dummy</a>.<a class="code" href="classbdm_1_1epdf.html#840de94aa33cf4f2ebd2427f45a165d8">set_parameters</a>(rv.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>()); |
| 172 | <a name="l00178"></a>00178 <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_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>-><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_1mpdf.html#5a5f08950daa08b85b01ddf4e1c36288" title="random variable in condition">rvc</a> ); |
| 173 | <a name="l00179"></a>00179 <span class="comment">// rv and rvc established = > we can link them with mpdfs</span> |
| 174 | <a name="l00180"></a>00180 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0;i < <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a>;i++ ) { |
| 175 | <a name="l00181"></a>00181 <a class="code" href="classbdm_1_1mprod.html#acf679b3b1d48629c5a042d9ac0d973f" title="Data link for each mpdfs.">dls</a> ( i ) = <span class="keyword">new</span> <a class="code" href="classbdm_1_1datalink__m2m.html">datalink_m2m</a> ( <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )->_rv(), <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )->_rvc(), _rv(), _rvc() ); |
| 176 | <a name="l00182"></a>00182 } |
139 | | <a name="l00184"></a><a class="code" href="classbdm_1_1mprod.html#800f21d94c919137608a2fd5c88719e2">00184</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mprod.html#800f21d94c919137608a2fd5c88719e2" title="Shortcut for conditioning and evaluation of the internal epdf. In some cases, this...">evallogcond</a> ( <span class="keyword">const</span> vec &val, <span class="keyword">const</span> vec &cond ) { |
140 | | <a name="l00185"></a>00185 <span class="keywordtype">int</span> i; |
141 | | <a name="l00186"></a>00186 <span class="keywordtype">double</span> res = 1.0; |
142 | | <a name="l00187"></a>00187 <span class="keywordflow">for</span> ( i = <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a> - 1;i >= 0;i-- ) { |
143 | | <a name="l00188"></a>00188 <span class="comment">/* if ( mpdfs(i)->_rvc().count() >0) {</span> |
144 | | <a name="l00189"></a>00189 <span class="comment"> mpdfs ( i )->condition ( dls ( i )->get_cond ( val,cond ) );</span> |
145 | | <a name="l00190"></a>00190 <span class="comment"> }</span> |
146 | | <a name="l00191"></a>00191 <span class="comment"> // add logarithms</span> |
147 | | <a name="l00192"></a>00192 <span class="comment"> res += epdfs ( i )->evallog ( dls ( i )->pushdown ( val ) );*/</span> |
148 | | <a name="l00193"></a>00193 res *= <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )->evallogcond ( |
149 | | <a name="l00194"></a>00194 <a class="code" href="classbdm_1_1mprod.html#acf679b3b1d48629c5a042d9ac0d973f" title="Data link for each mpdfs.">dls</a> ( i )->pushdown ( val ), |
150 | | <a name="l00195"></a>00195 <a class="code" href="classbdm_1_1mprod.html#acf679b3b1d48629c5a042d9ac0d973f" title="Data link for each mpdfs.">dls</a> ( i )->get_cond ( val, cond ) |
151 | | <a name="l00196"></a>00196 ); |
152 | | <a name="l00197"></a>00197 } |
153 | | <a name="l00198"></a>00198 <span class="keywordflow">return</span> res; |
154 | | <a name="l00199"></a>00199 } |
155 | | <a name="l00200"></a><a class="code" href="classbdm_1_1mprod.html#1a37c2aaba8bde7fce5351c39b6e1168">00200</a> vec <a class="code" href="classbdm_1_1mprod.html#1a37c2aaba8bde7fce5351c39b6e1168">samplecond</a> ( <span class="keyword">const</span> vec &cond, <span class="keywordtype">double</span> &ll ) { |
156 | | <a name="l00202"></a>00202 vec smp= std::numeric_limits<double>::infinity() * ones ( <a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>-><a class="code" href="classbdm_1_1epdf.html#46dfe100cd621716ee5c7ee25a20f24b" title="Size of the random variable.">dimension</a>() ); |
157 | | <a name="l00203"></a>00203 vec smpi; |
158 | | <a name="l00204"></a>00204 ll = 0; |
159 | | <a name="l00205"></a>00205 <span class="comment">// Hard assumption here!!! We are going backwards, to assure that samples that are needed from smp are already generated!</span> |
160 | | <a name="l00206"></a>00206 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = ( <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a> - 1 );i >= 0;i-- ) { |
161 | | <a name="l00207"></a>00207 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )->dimensionc() ) { |
162 | | <a name="l00208"></a>00208 <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )->condition ( <a class="code" href="classbdm_1_1mprod.html#acf679b3b1d48629c5a042d9ac0d973f" title="Data link for each mpdfs.">dls</a> ( i )->get_cond ( smp ,cond ) ); <span class="comment">// smp is val here!!</span> |
163 | | <a name="l00209"></a>00209 } |
164 | | <a name="l00210"></a>00210 smpi = <a class="code" href="classbdm_1_1mprod.html#eca722ed1b219727c6c0f8cbc6bf1e51" title="pointers to epdfs - shortcut to mpdfs()._epdf()">epdfs</a> ( i )->sample(); |
165 | | <a name="l00211"></a>00211 <span class="comment">// copy contribution of this pdf into smp</span> |
166 | | <a name="l00212"></a>00212 <a class="code" href="classbdm_1_1mprod.html#acf679b3b1d48629c5a042d9ac0d973f" title="Data link for each mpdfs.">dls</a> ( i )->pushup ( smp, smpi ); |
167 | | <a name="l00213"></a>00213 <span class="comment">// add ith likelihood contribution</span> |
168 | | <a name="l00214"></a>00214 ll+=<a class="code" href="classbdm_1_1mprod.html#eca722ed1b219727c6c0f8cbc6bf1e51" title="pointers to epdfs - shortcut to mpdfs()._epdf()">epdfs</a> ( i )->evallog ( smpi ); |
169 | | <a name="l00215"></a>00215 } |
170 | | <a name="l00216"></a>00216 <span class="keywordflow">return</span> smp; |
171 | | <a name="l00217"></a>00217 } |
172 | | <a name="l00218"></a>00218 mat <a class="code" href="classbdm_1_1mprod.html#1a37c2aaba8bde7fce5351c39b6e1168">samplecond</a> ( <span class="keyword">const</span> vec &cond, vec &ll, <span class="keywordtype">int</span> N ) { |
173 | | <a name="l00219"></a>00219 mat Smp ( dimension(),N ); |
174 | | <a name="l00220"></a>00220 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<N;i++ ) {Smp.set_col ( i,<a class="code" href="classbdm_1_1mprod.html#1a37c2aaba8bde7fce5351c39b6e1168">samplecond</a> ( cond,ll ( i ) ) );} |
175 | | <a name="l00221"></a>00221 <span class="keywordflow">return</span> Smp; |
176 | | <a name="l00222"></a>00222 } |
177 | | <a name="l00223"></a>00223 |
178 | | <a name="l00224"></a>00224 ~<a class="code" href="classbdm_1_1mprod.html#680c3e2d95b116c7cfb227c7f2984525" title="Constructor from list of mFacs,.">mprod</a>() {}; |
179 | | <a name="l00225"></a>00225 }; |
180 | | <a name="l00226"></a>00226 |
181 | | <a name="l00228"></a><a class="code" href="classbdm_1_1eprod.html">00228</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1eprod.html" title="Product of independent epdfs. For dependent pdfs, use mprod.">eprod</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> { |
182 | | <a name="l00229"></a>00229 <span class="keyword">protected</span>: |
183 | | <a name="l00231"></a><a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391">00231</a> Array<const epdf*> <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>; |
184 | | <a name="l00233"></a><a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43">00233</a> Array<datalink*> <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a>; |
185 | | <a name="l00234"></a>00234 <span class="keyword">public</span>: |
186 | | <a name="l00235"></a>00235 <a class="code" href="classbdm_1_1eprod.html" title="Product of independent epdfs. For dependent pdfs, use mprod.">eprod</a> ( <span class="keyword">const</span> Array<const epdf*> epdfs0 ) : <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_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( epdfs0 ),<a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length() ) { |
187 | | <a name="l00236"></a>00236 <span class="keywordtype">bool</span> independent=<span class="keyword">true</span>; |
188 | | <a name="l00237"></a>00237 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
189 | | <a name="l00238"></a>00238 independent=<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> ( <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )-><a class="code" href="classbdm_1_1epdf.html#a4ab378d5e004c3ff3e2d4e64f7bba21" title="Return name (fails when isnamed is false).">_rv</a>() ); |
190 | | <a name="l00239"></a>00239 it_assert_debug ( independent==<span class="keyword">true</span>, <span class="stringliteral">"eprod:: given components are not independent ."</span> ); |
191 | | <a name="l00240"></a>00240 } |
| 178 | <a name="l00184"></a>00184 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<n;i++ ) { |
| 179 | <a name="l00185"></a>00185 <a class="code" href="classbdm_1_1mprod.html#eca722ed1b219727c6c0f8cbc6bf1e51" title="pointers to epdfs - shortcut to mpdfs().posterior()">epdfs</a> ( i ) =& ( <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )->_epdf() ); |
| 180 | <a name="l00186"></a>00186 } |
| 181 | <a name="l00187"></a>00187 }; |
| 182 | <a name="l00188"></a>00188 |
| 183 | <a name="l00189"></a><a class="code" href="classbdm_1_1mprod.html#800f21d94c919137608a2fd5c88719e2">00189</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1mprod.html#800f21d94c919137608a2fd5c88719e2" title="Shortcut for conditioning and evaluation of the internal epdf. In some cases, this...">evallogcond</a> ( <span class="keyword">const</span> vec &val, <span class="keyword">const</span> vec &cond ) { |
| 184 | <a name="l00190"></a>00190 <span class="keywordtype">int</span> i; |
| 185 | <a name="l00191"></a>00191 <span class="keywordtype">double</span> res = 0.0; |
| 186 | <a name="l00192"></a>00192 <span class="keywordflow">for</span> ( i = <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a> - 1;i >= 0;i-- ) { |
| 187 | <a name="l00193"></a>00193 <span class="comment">/* if ( mpdfs(i)->_rvc().count() >0) {</span> |
| 188 | <a name="l00194"></a>00194 <span class="comment"> mpdfs ( i )->condition ( dls ( i )->get_cond ( val,cond ) );</span> |
| 189 | <a name="l00195"></a>00195 <span class="comment"> }</span> |
| 190 | <a name="l00196"></a>00196 <span class="comment"> // add logarithms</span> |
| 191 | <a name="l00197"></a>00197 <span class="comment"> res += epdfs ( i )->evallog ( dls ( i )->pushdown ( val ) );*/</span> |
| 192 | <a name="l00198"></a>00198 res += <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )->evallogcond ( |
| 193 | <a name="l00199"></a>00199 <a class="code" href="classbdm_1_1mprod.html#acf679b3b1d48629c5a042d9ac0d973f" title="Data link for each mpdfs.">dls</a> ( i )->pushdown ( val ), |
| 194 | <a name="l00200"></a>00200 <a class="code" href="classbdm_1_1mprod.html#acf679b3b1d48629c5a042d9ac0d973f" title="Data link for each mpdfs.">dls</a> ( i )->get_cond ( val, cond ) |
| 195 | <a name="l00201"></a>00201 ); |
| 196 | <a name="l00202"></a>00202 } |
| 197 | <a name="l00203"></a>00203 <span class="keywordflow">return</span> res; |
| 198 | <a name="l00204"></a>00204 } |
| 199 | <a name="l00205"></a>00205 <span class="comment">//TODO smarter...</span> |
| 200 | <a name="l00206"></a><a class="code" href="classbdm_1_1mprod.html#ee715a8013acf9892f6cb489db595555">00206</a> vec <a class="code" href="classbdm_1_1mprod.html#ee715a8013acf9892f6cb489db595555" title="Returns a sample from the density conditioned on cond, .">samplecond</a> ( <span class="keyword">const</span> vec &cond ) { |
| 201 | <a name="l00208"></a>00208 vec smp= std::numeric_limits<double>::infinity() * ones ( <a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a>-><a class="code" href="classbdm_1_1epdf.html#7083a65f7b7a0d0d13b2c516bd2ec29c" title="Size of the random variable.">dimension</a>() ); |
| 202 | <a name="l00209"></a>00209 vec smpi; |
| 203 | <a name="l00210"></a>00210 <span class="comment">// Hard assumption here!!! We are going backwards, to assure that samples that are needed from smp are already generated!</span> |
| 204 | <a name="l00211"></a>00211 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = ( <a class="code" href="classbdm_1_1compositepdf.html#7ca3cd8ed92a7154f5b9ff13b1e9d52a" title="Number of mpdfs in the composite.">n</a> - 1 );i >= 0;i-- ) { |
| 205 | <a name="l00212"></a>00212 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )->dimensionc() ) { |
| 206 | <a name="l00213"></a>00213 <a class="code" href="classbdm_1_1compositepdf.html#23faf2debc4dde10836393b8c665914a" title="Elements of composition.">mpdfs</a> ( i )->condition ( <a class="code" href="classbdm_1_1mprod.html#acf679b3b1d48629c5a042d9ac0d973f" title="Data link for each mpdfs.">dls</a> ( i )->get_cond ( smp ,cond ) ); <span class="comment">// smp is val here!!</span> |
| 207 | <a name="l00214"></a>00214 } |
| 208 | <a name="l00215"></a>00215 smpi = <a class="code" href="classbdm_1_1mprod.html#eca722ed1b219727c6c0f8cbc6bf1e51" title="pointers to epdfs - shortcut to mpdfs().posterior()">epdfs</a> ( i )->sample(); |
| 209 | <a name="l00216"></a>00216 <span class="comment">// copy contribution of this pdf into smp</span> |
| 210 | <a name="l00217"></a>00217 <a class="code" href="classbdm_1_1mprod.html#acf679b3b1d48629c5a042d9ac0d973f" title="Data link for each mpdfs.">dls</a> ( i )->pushup ( smp, smpi ); |
| 211 | <a name="l00218"></a>00218 <span class="comment">// add ith likelihood contribution</span> |
| 212 | <a name="l00219"></a>00219 } |
| 213 | <a name="l00220"></a>00220 <span class="keywordflow">return</span> smp; |
| 214 | <a name="l00221"></a>00221 } |
| 215 | <a name="l00222"></a>00222 mat <a class="code" href="classbdm_1_1mprod.html#ee715a8013acf9892f6cb489db595555" title="Returns a sample from the density conditioned on cond, .">samplecond</a> ( <span class="keyword">const</span> vec &cond, <span class="keywordtype">int</span> N ) { |
| 216 | <a name="l00223"></a>00223 mat Smp ( dimension(),N ); |
| 217 | <a name="l00224"></a>00224 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<N;i++ ) {Smp.set_col ( i,<a class="code" href="classbdm_1_1mprod.html#ee715a8013acf9892f6cb489db595555" title="Returns a sample from the density conditioned on cond, .">samplecond</a> ( cond ) );} |
| 218 | <a name="l00225"></a>00225 <span class="keywordflow">return</span> Smp; |
| 219 | <a name="l00226"></a>00226 } |
| 220 | <a name="l00227"></a>00227 |
| 221 | <a name="l00228"></a>00228 ~<a class="code" href="classbdm_1_1mprod.html#680c3e2d95b116c7cfb227c7f2984525" title="Constructor from list of mFacs,.">mprod</a>() {}; |
| 222 | <a name="l00229"></a>00229 }; |
| 223 | <a name="l00230"></a>00230 |
| 224 | <a name="l00232"></a><a class="code" href="classbdm_1_1eprod.html">00232</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1eprod.html" title="Product of independent epdfs. For dependent pdfs, use mprod.">eprod</a>: <span class="keyword">public</span> <a class="code" href="classbdm_1_1epdf.html" title="Probability density function with numerical statistics, e.g. posterior density.">epdf</a> { |
| 225 | <a name="l00233"></a>00233 <span class="keyword">protected</span>: |
| 226 | <a name="l00235"></a><a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391">00235</a> Array<const epdf*> <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>; |
| 227 | <a name="l00237"></a><a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43">00237</a> Array<datalink*> <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a>; |
| 228 | <a name="l00238"></a>00238 <span class="keyword">public</span>: |
| 229 | <a name="l00239"></a>00239 <a class="code" href="classbdm_1_1eprod.html" title="Product of independent epdfs. For dependent pdfs, use mprod.">eprod</a> ( <span class="keyword">const</span> Array<const epdf*> epdfs0 ) : <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_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( epdfs0 ),<a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length() ) { |
| 230 | <a name="l00240"></a>00240 <span class="keywordtype">bool</span> independent=<span class="keyword">true</span>; |
193 | | <a name="l00242"></a>00242 <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i ) = <span class="keyword">new</span> <a class="code" href="classbdm_1_1datalink.html" title="DataLink is a connection between two data vectors Up and Down.">datalink</a> ( <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )-><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_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> ); |
194 | | <a name="l00243"></a>00243 } |
195 | | <a name="l00244"></a>00244 } |
196 | | <a name="l00245"></a>00245 |
197 | | <a name="l00246"></a><a class="code" href="classbdm_1_1eprod.html#1d494351e7e385ad3382387c96915d24">00246</a> vec <a class="code" href="classbdm_1_1eprod.html#1d494351e7e385ad3382387c96915d24" title="return expected value">mean</a>()<span class="keyword"> const </span>{ |
198 | | <a name="l00247"></a>00247 vec tmp ( <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> ); |
199 | | <a name="l00248"></a>00248 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
200 | | <a name="l00249"></a>00249 vec pom = <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->mean(); |
201 | | <a name="l00250"></a>00250 <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->pushup ( tmp, pom ); |
202 | | <a name="l00251"></a>00251 } |
203 | | <a name="l00252"></a>00252 <span class="keywordflow">return</span> tmp; |
204 | | <a name="l00253"></a>00253 } |
205 | | <a name="l00254"></a><a class="code" href="classbdm_1_1eprod.html#cc53a151f5ac5dfba68d425acc3a5615">00254</a> vec <a class="code" href="classbdm_1_1eprod.html#cc53a151f5ac5dfba68d425acc3a5615" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{ |
206 | | <a name="l00255"></a>00255 vec tmp ( <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> ); <span class="comment">//second moment</span> |
207 | | <a name="l00256"></a>00256 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
208 | | <a name="l00257"></a>00257 vec pom = <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->mean(); |
209 | | <a name="l00258"></a>00258 <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->pushup ( tmp, pow(pom,2) ); |
210 | | <a name="l00259"></a>00259 } |
211 | | <a name="l00260"></a>00260 <span class="keywordflow">return</span> tmp-pow(<a class="code" href="classbdm_1_1eprod.html#1d494351e7e385ad3382387c96915d24" title="return expected value">mean</a>(),2); |
212 | | <a name="l00261"></a>00261 } |
213 | | <a name="l00262"></a><a class="code" href="classbdm_1_1eprod.html#af48debea25d3473bcb71b6a77fac741">00262</a> vec <a class="code" href="classbdm_1_1eprod.html#af48debea25d3473bcb71b6a77fac741" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{ |
214 | | <a name="l00263"></a>00263 vec tmp ( <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> ); |
215 | | <a name="l00264"></a>00264 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
216 | | <a name="l00265"></a>00265 vec pom = <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->sample(); |
217 | | <a name="l00266"></a>00266 <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->pushup ( tmp, pom ); |
218 | | <a name="l00267"></a>00267 } |
219 | | <a name="l00268"></a>00268 <span class="keywordflow">return</span> tmp; |
220 | | <a name="l00269"></a>00269 } |
221 | | <a name="l00270"></a><a class="code" href="classbdm_1_1eprod.html#a5a91e67d2f74ff2b0b8eecde2fa42e2">00270</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eprod.html#a5a91e67d2f74ff2b0b8eecde2fa42e2" title="Compute log-probability of argument val.">evallog</a> ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{ |
222 | | <a name="l00271"></a>00271 <span class="keywordtype">double</span> tmp=0; |
223 | | <a name="l00272"></a>00272 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
224 | | <a name="l00273"></a>00273 tmp+=<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->evallog ( <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->pushdown ( val ) ); |
225 | | <a name="l00274"></a>00274 } |
226 | | <a name="l00275"></a>00275 it_assert_debug(std::isfinite(tmp),<span class="stringliteral">"Infinite"</span>); |
227 | | <a name="l00276"></a>00276 <span class="keywordflow">return</span> tmp; |
228 | | <a name="l00277"></a>00277 } |
229 | | <a name="l00279"></a><a class="code" href="classbdm_1_1eprod.html#5194b47dd05a5886e0745250b6704953">00279</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_1eprod.html#5194b47dd05a5886e0745250b6704953" title="access function">operator () </a>( <span class="keywordtype">int</span> i )<span class="keyword"> const </span>{it_assert_debug ( i<<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length(),<span class="stringliteral">"wrong index"</span> );<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i );} |
230 | | <a name="l00280"></a>00280 |
231 | | <a name="l00282"></a><a class="code" href="classbdm_1_1eprod.html#708b37971aab3667f20e325c358632cf">00282</a> <a class="code" href="classbdm_1_1eprod.html#708b37971aab3667f20e325c358632cf" title="Destructor.">~eprod</a>() {<span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length();i++ ) {<span class="keyword">delete</span> <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i );}} |
232 | | <a name="l00283"></a>00283 }; |
| 232 | <a name="l00242"></a>00242 independent=<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> ( <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )-><a class="code" href="classbdm_1_1epdf.html#a4ab378d5e004c3ff3e2d4e64f7bba21" title="Return name (fails when isnamed is false).">_rv</a>() ); |
| 233 | <a name="l00243"></a>00243 it_assert_debug ( independent==<span class="keyword">true</span>, <span class="stringliteral">"eprod:: given components are not independent ."</span> ); |
| 234 | <a name="l00244"></a>00244 } |
| 235 | <a name="l00245"></a>00245 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
| 236 | <a name="l00246"></a>00246 <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i ) = <span class="keyword">new</span> <a class="code" href="classbdm_1_1datalink.html" title="DataLink is a connection between two data vectors Up and Down.">datalink</a> ( <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )-><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_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> ); |
| 237 | <a name="l00247"></a>00247 } |
| 238 | <a name="l00248"></a>00248 } |
| 239 | <a name="l00249"></a>00249 |
| 240 | <a name="l00250"></a><a class="code" href="classbdm_1_1eprod.html#1d494351e7e385ad3382387c96915d24">00250</a> vec <a class="code" href="classbdm_1_1eprod.html#1d494351e7e385ad3382387c96915d24" title="return expected value">mean</a>()<span class="keyword"> const </span>{ |
| 241 | <a name="l00251"></a>00251 vec tmp ( <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> ); |
| 242 | <a name="l00252"></a>00252 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
| 243 | <a name="l00253"></a>00253 vec pom = <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->mean(); |
| 244 | <a name="l00254"></a>00254 <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->pushup ( tmp, pom ); |
| 245 | <a name="l00255"></a>00255 } |
| 246 | <a name="l00256"></a>00256 <span class="keywordflow">return</span> tmp; |
| 247 | <a name="l00257"></a>00257 } |
| 248 | <a name="l00258"></a><a class="code" href="classbdm_1_1eprod.html#cc53a151f5ac5dfba68d425acc3a5615">00258</a> vec <a class="code" href="classbdm_1_1eprod.html#cc53a151f5ac5dfba68d425acc3a5615" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{ |
| 249 | <a name="l00259"></a>00259 vec tmp ( <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> ); <span class="comment">//second moment</span> |
| 250 | <a name="l00260"></a>00260 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
| 251 | <a name="l00261"></a>00261 vec pom = <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->mean(); |
| 252 | <a name="l00262"></a>00262 <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->pushup ( tmp, pow(pom,2) ); |
| 253 | <a name="l00263"></a>00263 } |
| 254 | <a name="l00264"></a>00264 <span class="keywordflow">return</span> tmp-pow(<a class="code" href="classbdm_1_1eprod.html#1d494351e7e385ad3382387c96915d24" title="return expected value">mean</a>(),2); |
| 255 | <a name="l00265"></a>00265 } |
| 256 | <a name="l00266"></a><a class="code" href="classbdm_1_1eprod.html#af48debea25d3473bcb71b6a77fac741">00266</a> vec <a class="code" href="classbdm_1_1eprod.html#af48debea25d3473bcb71b6a77fac741" title="Returns a sample, from density .">sample</a>()<span class="keyword"> const </span>{ |
| 257 | <a name="l00267"></a>00267 vec tmp ( <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> ); |
| 258 | <a name="l00268"></a>00268 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
| 259 | <a name="l00269"></a>00269 vec pom = <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->sample(); |
| 260 | <a name="l00270"></a>00270 <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->pushup ( tmp, pom ); |
| 261 | <a name="l00271"></a>00271 } |
| 262 | <a name="l00272"></a>00272 <span class="keywordflow">return</span> tmp; |
| 263 | <a name="l00273"></a>00273 } |
| 264 | <a name="l00274"></a><a class="code" href="classbdm_1_1eprod.html#a5a91e67d2f74ff2b0b8eecde2fa42e2">00274</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1eprod.html#a5a91e67d2f74ff2b0b8eecde2fa42e2" title="Compute log-probability of argument val.">evallog</a> ( <span class="keyword">const</span> vec &val )<span class="keyword"> const </span>{ |
| 265 | <a name="l00275"></a>00275 <span class="keywordtype">double</span> tmp=0; |
| 266 | <a name="l00276"></a>00276 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length();i++ ) { |
| 267 | <a name="l00277"></a>00277 tmp+=<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i )->evallog ( <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i )->pushdown ( val ) ); |
| 268 | <a name="l00278"></a>00278 } |
| 269 | <a name="l00279"></a>00279 it_assert_debug(std::isfinite(tmp),<span class="stringliteral">"Infinite"</span>); |
| 270 | <a name="l00280"></a>00280 <span class="keywordflow">return</span> tmp; |
| 271 | <a name="l00281"></a>00281 } |
| 272 | <a name="l00283"></a><a class="code" href="classbdm_1_1eprod.html#5194b47dd05a5886e0745250b6704953">00283</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_1eprod.html#5194b47dd05a5886e0745250b6704953" title="access function">operator () </a>( <span class="keywordtype">int</span> i )<span class="keyword"> const </span>{it_assert_debug ( i<<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length(),<span class="stringliteral">"wrong index"</span> );<span class="keywordflow">return</span> <a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a> ( i );} |
234 | | <a name="l00285"></a>00285 |
235 | | <a name="l00289"></a><a class="code" href="classbdm_1_1mmix.html">00289</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mmix.html" title="Mixture of mpdfs with constant weights, all mpdfs are of equal type.">mmix</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> { |
236 | | <a name="l00290"></a>00290 <span class="keyword">protected</span>: |
237 | | <a name="l00292"></a><a class="code" href="classbdm_1_1mmix.html#52e0bcc70d5b26babeba08097579da9c">00292</a> Array<mpdf*> <a class="code" href="classbdm_1_1mmix.html#52e0bcc70d5b26babeba08097579da9c" title="Component (epdfs).">Coms</a>; |
238 | | <a name="l00294"></a><a class="code" href="classbdm_1_1mmix.html#0c4dd6ca6556ddd8ae3c5f3257c04b60">00294</a> <a class="code" href="classbdm_1_1emix.html" title="Mixture of epdfs.">emix</a> <a class="code" href="classbdm_1_1mmix.html#0c4dd6ca6556ddd8ae3c5f3257c04b60" title="Internal epdf.">Epdf</a>; |
239 | | <a name="l00295"></a>00295 <span class="keyword">public</span>: |
240 | | <a name="l00297"></a><a class="code" href="classbdm_1_1mmix.html#a0cf51b7daeb6751103e94e6b96213fb">00297</a> <a class="code" href="classbdm_1_1mmix.html#a0cf51b7daeb6751103e94e6b96213fb" title="Default constructor.">mmix</a> ( ) : <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> ( ), <a class="code" href="classbdm_1_1mmix.html#0c4dd6ca6556ddd8ae3c5f3257c04b60" title="Internal epdf.">Epdf</a> () {<a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a> = &<a class="code" href="classbdm_1_1mmix.html#0c4dd6ca6556ddd8ae3c5f3257c04b60" title="Internal epdf.">Epdf</a>;}; |
241 | | <a name="l00299"></a><a class="code" href="classbdm_1_1mmix.html#ad8d9df36cb0ca093a29af0eca12da32">00299</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mmix.html#ad8d9df36cb0ca093a29af0eca12da32" title="Set weights w and components R.">set_parameters</a> ( <span class="keyword">const</span> vec &w, <span class="keyword">const</span> Array<mpdf*> &<a class="code" href="classbdm_1_1mmix.html#52e0bcc70d5b26babeba08097579da9c" title="Component (epdfs).">Coms</a> ) { |
242 | | <a name="l00300"></a>00300 Array<epdf*> Eps ( Coms.length() ); |
243 | | <a name="l00301"></a>00301 |
244 | | <a name="l00302"></a>00302 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0;i < Coms.length();i++ ) { |
245 | | <a name="l00303"></a>00303 Eps ( i ) = & ( <a class="code" href="classbdm_1_1mmix.html#52e0bcc70d5b26babeba08097579da9c" title="Component (epdfs).">Coms</a> ( i )->_epdf() ); |
246 | | <a name="l00304"></a>00304 } |
247 | | <a name="l00305"></a>00305 <a class="code" href="classbdm_1_1mmix.html#0c4dd6ca6556ddd8ae3c5f3257c04b60" title="Internal epdf.">Epdf</a>.<a class="code" href="classbdm_1_1emix.html#d8c1aefba8302759836b5f26999ce840">set_parameters</a> ( w, Eps ); |
248 | | <a name="l00306"></a>00306 }; |
249 | | <a name="l00307"></a>00307 |
250 | | <a name="l00308"></a><a class="code" href="classbdm_1_1mmix.html#0a5241ecc9911e816b00b92d5c7c8df0">00308</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mmix.html#0a5241ecc9911e816b00b92d5c7c8df0" title="Update ep so that it represents this mpdf conditioned on rvc = cond.">condition</a> ( <span class="keyword">const</span> vec &cond ) { |
251 | | <a name="l00309"></a>00309 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0;i < <a class="code" href="classbdm_1_1mmix.html#52e0bcc70d5b26babeba08097579da9c" title="Component (epdfs).">Coms</a>.length();i++ ) {<a class="code" href="classbdm_1_1mmix.html#52e0bcc70d5b26babeba08097579da9c" title="Component (epdfs).">Coms</a> ( i )->condition ( cond );} |
| 274 | <a name="l00286"></a><a class="code" href="classbdm_1_1eprod.html#708b37971aab3667f20e325c358632cf">00286</a> <a class="code" href="classbdm_1_1eprod.html#708b37971aab3667f20e325c358632cf" title="Destructor.">~eprod</a>() {<span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0;i<<a class="code" href="classbdm_1_1eprod.html#fa0b0981730f0a8339b9ff3e29d78391" title="Components (epdfs).">epdfs</a>.length();i++ ) {<span class="keyword">delete</span> <a class="code" href="classbdm_1_1eprod.html#6b5a9be71a644f6009e7beda6c762a43" title="Array of indeces.">dls</a> ( i );}} |
| 275 | <a name="l00287"></a>00287 }; |
| 276 | <a name="l00288"></a>00288 |
| 277 | <a name="l00289"></a>00289 |
| 278 | <a name="l00293"></a><a class="code" href="classbdm_1_1mmix.html">00293</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1mmix.html" title="Mixture of mpdfs with constant weights, all mpdfs are of equal type.">mmix</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> { |
| 279 | <a name="l00294"></a>00294 <span class="keyword">protected</span>: |
| 280 | <a name="l00296"></a><a class="code" href="classbdm_1_1mmix.html#52e0bcc70d5b26babeba08097579da9c">00296</a> Array<mpdf*> <a class="code" href="classbdm_1_1mmix.html#52e0bcc70d5b26babeba08097579da9c" title="Component (epdfs).">Coms</a>; |
| 281 | <a name="l00298"></a><a class="code" href="classbdm_1_1mmix.html#0c4dd6ca6556ddd8ae3c5f3257c04b60">00298</a> <a class="code" href="classbdm_1_1emix.html" title="Mixture of epdfs.">emix</a> <a class="code" href="classbdm_1_1mmix.html#0c4dd6ca6556ddd8ae3c5f3257c04b60" title="Internal epdf.">Epdf</a>; |
| 282 | <a name="l00299"></a>00299 <span class="keyword">public</span>: |
| 283 | <a name="l00301"></a><a class="code" href="classbdm_1_1mmix.html#a0cf51b7daeb6751103e94e6b96213fb">00301</a> <a class="code" href="classbdm_1_1mmix.html#a0cf51b7daeb6751103e94e6b96213fb" title="Default constructor.">mmix</a> ( ) : <a class="code" href="classbdm_1_1mpdf.html" title="Conditional probability density, e.g. modeling some dependencies.">mpdf</a> ( ), <a class="code" href="classbdm_1_1mmix.html#0c4dd6ca6556ddd8ae3c5f3257c04b60" title="Internal epdf.">Epdf</a> () {<a class="code" href="classbdm_1_1mpdf.html#5eea43c56d38e4441bfb30270db949c0" title="pointer to internal epdf">ep</a> = &<a class="code" href="classbdm_1_1mmix.html#0c4dd6ca6556ddd8ae3c5f3257c04b60" title="Internal epdf.">Epdf</a>;}; |
| 284 | <a name="l00303"></a><a class="code" href="classbdm_1_1mmix.html#ad8d9df36cb0ca093a29af0eca12da32">00303</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1mmix.html#ad8d9df36cb0ca093a29af0eca12da32" title="Set weights w and components R.">set_parameters</a> ( <span class="keyword">const</span> vec &w, <span class="keyword">const</span> Array<mpdf*> &<a class="code" href="classbdm_1_1mmix.html#52e0bcc70d5b26babeba08097579da9c" title="Component (epdfs).">Coms</a> ) { |
| 285 | <a name="l00304"></a>00304 Array<epdf*> Eps ( Coms.length() ); |
| 286 | <a name="l00305"></a>00305 |
| 287 | <a name="l00306"></a>00306 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0;i < Coms.length();i++ ) { |
| 288 | <a name="l00307"></a>00307 Eps ( i ) = & ( <a class="code" href="classbdm_1_1mmix.html#52e0bcc70d5b26babeba08097579da9c" title="Component (epdfs).">Coms</a> ( i )->_epdf() ); |
| 289 | <a name="l00308"></a>00308 } |
| 290 | <a name="l00309"></a>00309 <a class="code" href="classbdm_1_1mmix.html#0c4dd6ca6556ddd8ae3c5f3257c04b60" title="Internal epdf.">Epdf</a>.<a class="code" href="classbdm_1_1emix.html#3a107a6b808a081389ef17af951c234a">set_parameters</a> ( w, Eps ); |