70 | | <a name="l00018"></a>00018 |
71 | | <a name="l00019"></a>00019 <span class="keyword">namespace </span>bdm { |
72 | | <a name="l00020"></a>00020 <span class="keyword">using</span> std::string; |
73 | | <a name="l00021"></a>00021 |
74 | | <a name="l00023"></a>00023 <span class="keyword">enum</span> MERGER_METHOD {ARITHMETIC = 1, GEOMETRIC = 2, LOGNORMAL = 3}; |
75 | | <a name="l00024"></a>00024 |
76 | | <a name="l00044"></a><a class="code" href="classbdm_1_1merger__base.html">00044</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1merger__base.html" title="Base class for general combination of pdfs on discrete support.">merger_base</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> { |
77 | | <a name="l00045"></a>00045 <span class="keyword">protected</span>: |
78 | | <a name="l00047"></a><a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88">00047</a> Array<shared_ptr<mpdf> > <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a>; |
79 | | <a name="l00048"></a>00048 |
80 | | <a name="l00050"></a><a class="code" href="classbdm_1_1merger__base.html#09bc4d43dec350a40d17953b8b59d3b7">00050</a> Array<datalink_m2e*> <a class="code" href="classbdm_1_1merger__base.html#09bc4d43dec350a40d17953b8b59d3b7" title="Data link for each mpdf in mpdfs.">dls</a>; |
81 | | <a name="l00051"></a>00051 |
82 | | <a name="l00053"></a><a class="code" href="classbdm_1_1merger__base.html#4e66803b04fc04b21b3716b3a317421f">00053</a> Array<RV> <a class="code" href="classbdm_1_1merger__base.html#4e66803b04fc04b21b3716b3a317421f" title="Array of rvs that are not modelled by mpdfs at all, .">rvzs</a>; |
83 | | <a name="l00054"></a>00054 |
84 | | <a name="l00056"></a><a class="code" href="classbdm_1_1merger__base.html#8098858f2edb1294122cbe4f05bf8694">00056</a> Array<datalink_m2e*> <a class="code" href="classbdm_1_1merger__base.html#8098858f2edb1294122cbe4f05bf8694" title="Data Links for extension .">zdls</a>; |
85 | | <a name="l00057"></a>00057 |
86 | | <a name="l00059"></a><a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541">00059</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a>; |
87 | | <a name="l00060"></a>00060 |
88 | | <a name="l00062"></a><a class="code" href="classbdm_1_1merger__base.html#4f6cd7ebe1c3c7556039dbfeb00f71f5">00062</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1merger__base.html#4f6cd7ebe1c3c7556039dbfeb00f71f5" title="number of sources">Nsources</a>; |
89 | | <a name="l00063"></a>00063 |
90 | | <a name="l00065"></a><a class="code" href="classbdm_1_1merger__base.html#ee197330820127f3d12106ddee6b25c7">00065</a> MERGER_METHOD <a class="code" href="classbdm_1_1merger__base.html#ee197330820127f3d12106ddee6b25c7" title="switch of the methoh used for merging">METHOD</a>; |
91 | | <a name="l00067"></a><a class="code" href="classbdm_1_1merger__base.html#7acdf3aeded70475ba8a26450a4e197c">00067</a> <span class="keyword">static</span> <span class="keyword">const</span> MERGER_METHOD <a class="code" href="classbdm_1_1merger__base.html#7acdf3aeded70475ba8a26450a4e197c" title="Default for METHOD.">DFLT_METHOD</a>; |
92 | | <a name="l00068"></a>00068 |
93 | | <a name="l00070"></a><a class="code" href="classbdm_1_1merger__base.html#972f64f6f388b929cf94d2c478116f14">00070</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1merger__base.html#972f64f6f388b929cf94d2c478116f14" title="Prior on the log-normal merging model.">beta</a>; |
94 | | <a name="l00072"></a><a class="code" href="classbdm_1_1merger__base.html#dfe17e57529d84e122e61401543e9de6">00072</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1merger__base.html#dfe17e57529d84e122e61401543e9de6" title="default for beta">DFLT_beta</a>; |
95 | | <a name="l00073"></a>00073 |
96 | | <a name="l00075"></a><a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e">00075</a> <a class="code" href="classbdm_1_1eEmp.html" title="Weighted empirical density.">eEmp</a> <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>; |
97 | | <a name="l00076"></a>00076 |
98 | | <a name="l00078"></a><a class="code" href="classbdm_1_1merger__base.html#dd180c651a75a131d125305f6bb017f7">00078</a> <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1merger__base.html#dd180c651a75a131d125305f6bb017f7" title="debug or not debug">DBG</a>; |
99 | | <a name="l00079"></a>00079 |
100 | | <a name="l00081"></a><a class="code" href="classbdm_1_1merger__base.html#b2c6278b996696cb711cb7be900ccf5b">00081</a> it_file* <a class="code" href="classbdm_1_1merger__base.html#b2c6278b996696cb711cb7be900ccf5b" title="debugging file">dbg_file</a>; |
101 | | <a name="l00082"></a>00082 <span class="keyword">public</span>: |
102 | | <a name="l00085"></a>00085 |
103 | | <a name="l00087"></a><a class="code" href="classbdm_1_1merger__base.html#f9d8c6c26c6520dbb17d4e80f635e7be">00087</a> <a class="code" href="classbdm_1_1merger__base.html#f9d8c6c26c6520dbb17d4e80f635e7be" title="Default constructor.">merger_base</a> () : <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a>(0), <a class="code" href="classbdm_1_1merger__base.html#4f6cd7ebe1c3c7556039dbfeb00f71f5" title="number of sources">Nsources</a>(0), <a class="code" href="classbdm_1_1merger__base.html#dd180c651a75a131d125305f6bb017f7" title="debug or not debug">DBG</a>(false), <a class="code" href="classbdm_1_1merger__base.html#b2c6278b996696cb711cb7be900ccf5b" title="debugging file">dbg_file</a>(0) { |
104 | | <a name="l00088"></a>00088 } |
105 | | <a name="l00089"></a>00089 |
106 | | <a name="l00091"></a>00091 <a class="code" href="classbdm_1_1merger__base.html#f9d8c6c26c6520dbb17d4e80f635e7be" title="Default constructor.">merger_base</a> ( <span class="keyword">const</span> Array<<a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<mpdf></a> > &S ); |
107 | | <a name="l00092"></a>00092 |
108 | | <a name="l00094"></a><a class="code" href="classbdm_1_1merger__base.html#871add803409c5cc3a634b4ff8fa997f">00094</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__base.html#871add803409c5cc3a634b4ff8fa997f" title="Function setting the main internal structures.">set_sources</a> ( <span class="keyword">const</span> Array<<a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<mpdf></a> > &Sources ) { |
109 | | <a name="l00095"></a>00095 <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a> = Sources; |
110 | | <a name="l00096"></a>00096 <a class="code" href="classbdm_1_1merger__base.html#4f6cd7ebe1c3c7556039dbfeb00f71f5" title="number of sources">Nsources</a> = <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a>.length(); |
111 | | <a name="l00097"></a>00097 <span class="comment">//set sizes</span> |
112 | | <a name="l00098"></a>00098 <a class="code" href="classbdm_1_1merger__base.html#09bc4d43dec350a40d17953b8b59d3b7" title="Data link for each mpdf in mpdfs.">dls</a>.set_size ( Sources.length() ); |
113 | | <a name="l00099"></a>00099 <a class="code" href="classbdm_1_1merger__base.html#4e66803b04fc04b21b3716b3a317421f" title="Array of rvs that are not modelled by mpdfs at all, .">rvzs</a>.set_size ( Sources.length() ); |
114 | | <a name="l00100"></a>00100 <a class="code" href="classbdm_1_1merger__base.html#8098858f2edb1294122cbe4f05bf8694" title="Data Links for extension .">zdls</a>.set_size ( Sources.length() ); |
115 | | <a name="l00101"></a>00101 |
116 | | <a name="l00102"></a>00102 <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> = get_composite_rv ( <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a>, <span class="comment">/* checkoverlap = */</span> <span class="keyword">false</span> ); |
117 | | <a name="l00103"></a>00103 |
118 | | <a name="l00104"></a>00104 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> rvc; |
119 | | <a name="l00105"></a>00105 <span class="comment">// Extend rv by rvc!</span> |
120 | | <a name="l00106"></a>00106 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a>.length(); i++ ) { |
121 | | <a name="l00107"></a>00107 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> rvx = <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a> ( i )->_rvc().subt ( <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> ); |
122 | | <a name="l00108"></a>00108 rvc.<a class="code" href="classbdm_1_1RV.html#87841b5ee43997b79789c0c22047e224" title="Add (concat) another variable to the current one,.">add</a> ( rvx ); <span class="comment">// add rv to common rvc</span> |
123 | | <a name="l00109"></a>00109 } |
124 | | <a name="l00110"></a>00110 |
125 | | <a name="l00111"></a>00111 <span class="comment">// join rv and rvc - see descriprion</span> |
126 | | <a name="l00112"></a>00112 <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#87841b5ee43997b79789c0c22047e224" title="Add (concat) another variable to the current one,.">add</a> ( rvc ); |
127 | | <a name="l00113"></a>00113 <span class="comment">// get dimension</span> |
128 | | <a name="l00114"></a>00114 <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(); |
129 | | <a name="l00115"></a>00115 |
130 | | <a name="l00116"></a>00116 <span class="comment">// create links between sources and common rv</span> |
131 | | <a name="l00117"></a>00117 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> xytmp; |
132 | | <a name="l00118"></a>00118 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a>.length(); i++ ) { |
133 | | <a name="l00119"></a>00119 <span class="comment">//Establich connection between mpdfs and merger</span> |
134 | | <a name="l00120"></a>00120 <a class="code" href="classbdm_1_1merger__base.html#09bc4d43dec350a40d17953b8b59d3b7" title="Data link for each mpdf in mpdfs.">dls</a> ( i ) = <span class="keyword">new</span> <a class="code" href="classbdm_1_1datalink__m2e.html" title="Data link with a condition.">datalink_m2e</a>; |
135 | | <a name="l00121"></a>00121 <a class="code" href="classbdm_1_1merger__base.html#09bc4d43dec350a40d17953b8b59d3b7" title="Data link for each mpdf in mpdfs.">dls</a> ( i )->set_connection ( <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</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_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a> ( i )->_rvc(), <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> ); |
136 | | <a name="l00122"></a>00122 |
137 | | <a name="l00123"></a>00123 <span class="comment">// find out what is missing in each mpdf</span> |
138 | | <a name="l00124"></a>00124 xytmp = <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a> ( i )->_rv(); |
139 | | <a name="l00125"></a>00125 xytmp.<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_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a> ( i )->_rvc() ); |
140 | | <a name="l00126"></a>00126 <span class="comment">// z_i = common_rv-xy</span> |
141 | | <a name="l00127"></a>00127 <a class="code" href="classbdm_1_1merger__base.html#4e66803b04fc04b21b3716b3a317421f" title="Array of rvs that are not modelled by mpdfs at all, .">rvzs</a> ( i ) = <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#aec44dabdf0a6d90fbae95e1356eda39" title="Subtract another variable from the current one.">subt</a> ( xytmp ); |
142 | | <a name="l00128"></a>00128 <span class="comment">//establish connection between extension (z_i|x,y)s and common rv</span> |
143 | | <a name="l00129"></a>00129 <a class="code" href="classbdm_1_1merger__base.html#8098858f2edb1294122cbe4f05bf8694" title="Data Links for extension .">zdls</a> ( i ) = <span class="keyword">new</span> <a class="code" href="classbdm_1_1datalink__m2e.html" title="Data link with a condition.">datalink_m2e</a>; |
144 | | <a name="l00130"></a>00130 <a class="code" href="classbdm_1_1merger__base.html#8098858f2edb1294122cbe4f05bf8694" title="Data Links for extension .">zdls</a> ( i )->set_connection ( <a class="code" href="classbdm_1_1merger__base.html#4e66803b04fc04b21b3716b3a317421f" title="Array of rvs that are not modelled by mpdfs at all, .">rvzs</a> ( i ), xytmp, <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> ) ; |
145 | | <a name="l00131"></a>00131 }; |
146 | | <a name="l00132"></a>00132 } |
147 | | <a name="l00134"></a><a class="code" href="classbdm_1_1merger__base.html#337e1e56ef95d3d3ee922e8b81be95f8">00134</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__base.html#337e1e56ef95d3d3ee922e8b81be95f8" title="Rectangular support each vector of XYZ specifies (begining-end) interval for each...">set_support</a> ( <span class="keyword">const</span> Array<vec> &XYZ, <span class="keyword">const</span> <span class="keywordtype">int</span> dimsize ) { |
148 | | <a name="l00135"></a>00135 <a class="code" href="classbdm_1_1merger__base.html#337e1e56ef95d3d3ee922e8b81be95f8" title="Rectangular support each vector of XYZ specifies (begining-end) interval for each...">set_support</a> ( XYZ, dimsize*ones_i ( XYZ.length() ) ); |
149 | | <a name="l00136"></a>00136 } |
150 | | <a name="l00138"></a><a class="code" href="classbdm_1_1merger__base.html#3e2c8028be0ccd10058d030250a91a60">00138</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__base.html#3e2c8028be0ccd10058d030250a91a60" title="Rectangular support each vector of XYZ specifies (begining-end) interval for each...">set_support</a> ( <span class="keyword">const</span> Array<vec> &XYZ, <span class="keyword">const</span> ivec &gridsize ) { |
151 | | <a name="l00139"></a>00139 <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = XYZ.length(); <span class="comment">//check with internal dim!!</span> |
152 | | <a name="l00140"></a>00140 <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a> = prod ( gridsize ); |
153 | | <a name="l00141"></a>00141 <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#c74c281d652356c19b6b079e42ca7ef1" title="Set sample.">set_parameters</a> ( <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a>, <span class="keyword">false</span> ); |
154 | | <a name="l00142"></a>00142 Array<vec> &samples = <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#c24966b0aaeb767bc8a6b4fd60931be2" title="access function">_samples</a>(); |
155 | | <a name="l00143"></a>00143 <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#d7f83cc0415cd44ae7cc8b4bdad93aef" title="Potentially dangerous, use with care.">_w</a>() = ones ( <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a> ) / <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a>; <span class="comment">//unifrom size of bins</span> |
156 | | <a name="l00144"></a>00144 <span class="comment">//set samples</span> |
157 | | <a name="l00145"></a>00145 ivec ind = zeros_i ( dim ); <span class="comment">//indeces of dimensions in for cycle;</span> |
158 | | <a name="l00146"></a>00146 vec smpi ( dim ); <span class="comment">// ith sample</span> |
159 | | <a name="l00147"></a>00147 vec steps = zeros ( dim ); <span class="comment">// ith sample</span> |
160 | | <a name="l00148"></a>00148 <span class="comment">// first corner</span> |
161 | | <a name="l00149"></a>00149 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> j = 0; j < dim; j++ ) { |
162 | | <a name="l00150"></a>00150 smpi ( j ) = XYZ ( j ) ( 0 ); <span class="comment">/* beginning of the interval*/</span> |
163 | | <a name="l00151"></a>00151 it_assert ( gridsize ( j ) != 0.0, <span class="stringliteral">"Zeros in gridsize!"</span> ); |
164 | | <a name="l00152"></a>00152 steps ( j ) = ( XYZ ( j ) ( 1 ) - smpi ( j ) ) / gridsize ( j ); |
165 | | <a name="l00153"></a>00153 } |
166 | | <a name="l00154"></a>00154 <span class="comment">// fill samples</span> |
167 | | <a name="l00155"></a>00155 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a>; i++ ) { |
168 | | <a name="l00156"></a>00156 <span class="comment">// copy</span> |
169 | | <a name="l00157"></a>00157 samples ( i ) = smpi; |
170 | | <a name="l00158"></a>00158 <span class="comment">// go through all dimensions</span> |
171 | | <a name="l00159"></a>00159 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> j = 0; j < dim; j++ ) { |
172 | | <a name="l00160"></a>00160 <span class="keywordflow">if</span> ( ind ( j ) == gridsize ( j ) - 1 ) { <span class="comment">//j-th index is full</span> |
173 | | <a name="l00161"></a>00161 ind ( j ) = 0; <span class="comment">//shift back</span> |
174 | | <a name="l00162"></a>00162 smpi ( j ) = XYZ ( j ) ( 0 ); |
175 | | <a name="l00163"></a>00163 |
176 | | <a name="l00164"></a>00164 <span class="keywordflow">if</span> ( i < Npoints - 1 ) { |
177 | | <a name="l00165"></a>00165 ind ( j + 1 ) ++; <span class="comment">//increase the next dimension;</span> |
178 | | <a name="l00166"></a>00166 smpi ( j + 1 ) += steps ( j + 1 ); |
179 | | <a name="l00167"></a>00167 <span class="keywordflow">break</span>; |
180 | | <a name="l00168"></a>00168 } |
181 | | <a name="l00169"></a>00169 |
182 | | <a name="l00170"></a>00170 } <span class="keywordflow">else</span> { |
183 | | <a name="l00171"></a>00171 ind ( j ) ++; |
184 | | <a name="l00172"></a>00172 smpi ( j ) += steps ( j ); |
185 | | <a name="l00173"></a>00173 <span class="keywordflow">break</span>; |
186 | | <a name="l00174"></a>00174 } |
187 | | <a name="l00175"></a>00175 } |
188 | | <a name="l00176"></a>00176 } |
189 | | <a name="l00177"></a>00177 } |
190 | | <a name="l00179"></a><a class="code" href="classbdm_1_1merger__base.html#e4514484bac243585b0a1e44325e8add">00179</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__base.html#e4514484bac243585b0a1e44325e8add" title="set debug file">set_debug_file</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> fname ) { |
191 | | <a name="l00180"></a>00180 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1merger__base.html#dd180c651a75a131d125305f6bb017f7" title="debug or not debug">DBG</a> ) <span class="keyword">delete</span> <a class="code" href="classbdm_1_1merger__base.html#b2c6278b996696cb711cb7be900ccf5b" title="debugging file">dbg_file</a>; |
192 | | <a name="l00181"></a>00181 <a class="code" href="classbdm_1_1merger__base.html#b2c6278b996696cb711cb7be900ccf5b" title="debugging file">dbg_file</a> = <span class="keyword">new</span> it_file ( fname ); |
193 | | <a name="l00182"></a>00182 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1merger__base.html#b2c6278b996696cb711cb7be900ccf5b" title="debugging file">dbg_file</a> ) <a class="code" href="classbdm_1_1merger__base.html#dd180c651a75a131d125305f6bb017f7" title="debug or not debug">DBG</a> = <span class="keyword">true</span>; |
194 | | <a name="l00183"></a>00183 } |
195 | | <a name="l00185"></a><a class="code" href="classbdm_1_1merger__base.html#86698b7fd1e4320e9830d7dc24ee6c9e">00185</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__base.html#86698b7fd1e4320e9830d7dc24ee6c9e" title="Set internal parameters used in approximation.">set_method</a> ( MERGER_METHOD MTH = <a class="code" href="classbdm_1_1merger__base.html#7acdf3aeded70475ba8a26450a4e197c" title="Default for METHOD.">DFLT_METHOD</a>, <span class="keywordtype">double</span> beta0 = <a class="code" href="classbdm_1_1merger__base.html#dfe17e57529d84e122e61401543e9de6" title="default for beta">DFLT_beta</a> ) { |
196 | | <a name="l00186"></a>00186 <a class="code" href="classbdm_1_1merger__base.html#ee197330820127f3d12106ddee6b25c7" title="switch of the methoh used for merging">METHOD</a> = MTH; |
197 | | <a name="l00187"></a>00187 <a class="code" href="classbdm_1_1merger__base.html#972f64f6f388b929cf94d2c478116f14" title="Prior on the log-normal merging model.">beta</a> = beta0; |
198 | | <a name="l00188"></a>00188 } |
199 | | <a name="l00190"></a><a class="code" href="classbdm_1_1merger__base.html#28af7b365ecd8c3a15f0e934496871e0">00190</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__base.html#28af7b365ecd8c3a15f0e934496871e0" title="Set support points from a pdf by drawing N samples.">set_support</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> &overall, <span class="keywordtype">int</span> N ) { |
200 | | <a name="l00191"></a>00191 <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#e7f8f98310c1de51bd5c8a1c87528f72" title="Set samples and weights.">set_statistics</a> ( overall, N ); |
201 | | <a name="l00192"></a>00192 <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a> = N; |
202 | | <a name="l00193"></a>00193 } |
| 70 | <a name="l00018"></a>00018 <span class="preprocessor">#include "<a class="code" href="discrete_8h.html" title="Probability distributions for discrete support densities.">discrete.h</a>"</span> |
| 71 | <a name="l00019"></a>00019 |
| 72 | <a name="l00020"></a>00020 <span class="keyword">namespace </span>bdm { |
| 73 | <a name="l00021"></a>00021 <span class="keyword">using</span> std::string; |
| 74 | <a name="l00022"></a>00022 |
| 75 | <a name="l00024"></a>00024 <span class="keyword">enum</span> MERGER_METHOD {ARITHMETIC = 1, GEOMETRIC = 2, LOGNORMAL = 3}; |
| 76 | <a name="l00025"></a>00025 |
| 77 | <a name="l00045"></a><a class="code" href="classbdm_1_1merger__base.html">00045</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1merger__base.html" title="Base class for general combination of pdfs on discrete support.">merger_base</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> { |
| 78 | <a name="l00046"></a>00046 <span class="keyword">protected</span>: |
| 79 | <a name="l00048"></a><a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88">00048</a> Array<shared_ptr<mpdf> > <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a>; |
| 80 | <a name="l00049"></a>00049 |
| 81 | <a name="l00051"></a><a class="code" href="classbdm_1_1merger__base.html#09bc4d43dec350a40d17953b8b59d3b7">00051</a> Array<datalink_m2e*> <a class="code" href="classbdm_1_1merger__base.html#09bc4d43dec350a40d17953b8b59d3b7" title="Data link for each mpdf in mpdfs.">dls</a>; |
| 82 | <a name="l00052"></a>00052 |
| 83 | <a name="l00054"></a><a class="code" href="classbdm_1_1merger__base.html#4e66803b04fc04b21b3716b3a317421f">00054</a> Array<RV> <a class="code" href="classbdm_1_1merger__base.html#4e66803b04fc04b21b3716b3a317421f" title="Array of rvs that are not modelled by mpdfs at all, .">rvzs</a>; |
| 84 | <a name="l00055"></a>00055 |
| 85 | <a name="l00057"></a><a class="code" href="classbdm_1_1merger__base.html#8098858f2edb1294122cbe4f05bf8694">00057</a> Array<datalink_m2e*> <a class="code" href="classbdm_1_1merger__base.html#8098858f2edb1294122cbe4f05bf8694" title="Data Links for extension .">zdls</a>; |
| 86 | <a name="l00058"></a>00058 |
| 87 | <a name="l00060"></a><a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541">00060</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a>; |
| 88 | <a name="l00061"></a>00061 |
| 89 | <a name="l00063"></a><a class="code" href="classbdm_1_1merger__base.html#4f6cd7ebe1c3c7556039dbfeb00f71f5">00063</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1merger__base.html#4f6cd7ebe1c3c7556039dbfeb00f71f5" title="number of sources">Nsources</a>; |
| 90 | <a name="l00064"></a>00064 |
| 91 | <a name="l00066"></a><a class="code" href="classbdm_1_1merger__base.html#ee197330820127f3d12106ddee6b25c7">00066</a> MERGER_METHOD <a class="code" href="classbdm_1_1merger__base.html#ee197330820127f3d12106ddee6b25c7" title="switch of the methoh used for merging">METHOD</a>; |
| 92 | <a name="l00068"></a><a class="code" href="classbdm_1_1merger__base.html#7acdf3aeded70475ba8a26450a4e197c">00068</a> <span class="keyword">static</span> <span class="keyword">const</span> MERGER_METHOD <a class="code" href="classbdm_1_1merger__base.html#7acdf3aeded70475ba8a26450a4e197c" title="Default for METHOD.">DFLT_METHOD</a>; |
| 93 | <a name="l00069"></a>00069 |
| 94 | <a name="l00071"></a><a class="code" href="classbdm_1_1merger__base.html#972f64f6f388b929cf94d2c478116f14">00071</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1merger__base.html#972f64f6f388b929cf94d2c478116f14" title="Prior on the log-normal merging model.">beta</a>; |
| 95 | <a name="l00073"></a><a class="code" href="classbdm_1_1merger__base.html#dfe17e57529d84e122e61401543e9de6">00073</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1merger__base.html#dfe17e57529d84e122e61401543e9de6" title="default for beta">DFLT_beta</a>; |
| 96 | <a name="l00074"></a>00074 |
| 97 | <a name="l00076"></a><a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e">00076</a> <a class="code" href="classbdm_1_1eEmp.html" title="Weighted empirical density.">eEmp</a> <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>; |
| 98 | <a name="l00077"></a>00077 |
| 99 | <a name="l00079"></a><a class="code" href="classbdm_1_1merger__base.html#dd180c651a75a131d125305f6bb017f7">00079</a> <span class="keywordtype">bool</span> <a class="code" href="classbdm_1_1merger__base.html#dd180c651a75a131d125305f6bb017f7" title="debug or not debug">DBG</a>; |
| 100 | <a name="l00080"></a>00080 |
| 101 | <a name="l00082"></a><a class="code" href="classbdm_1_1merger__base.html#b2c6278b996696cb711cb7be900ccf5b">00082</a> it_file* <a class="code" href="classbdm_1_1merger__base.html#b2c6278b996696cb711cb7be900ccf5b" title="debugging file">dbg_file</a>; |
| 102 | <a name="l00083"></a>00083 <span class="keyword">public</span>: |
| 103 | <a name="l00086"></a>00086 |
| 104 | <a name="l00088"></a><a class="code" href="classbdm_1_1merger__base.html#f9d8c6c26c6520dbb17d4e80f635e7be">00088</a> <a class="code" href="classbdm_1_1merger__base.html#f9d8c6c26c6520dbb17d4e80f635e7be" title="Default constructor.">merger_base</a> () : <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a>(0), <a class="code" href="classbdm_1_1merger__base.html#4f6cd7ebe1c3c7556039dbfeb00f71f5" title="number of sources">Nsources</a>(0), <a class="code" href="classbdm_1_1merger__base.html#dd180c651a75a131d125305f6bb017f7" title="debug or not debug">DBG</a>(false), <a class="code" href="classbdm_1_1merger__base.html#b2c6278b996696cb711cb7be900ccf5b" title="debugging file">dbg_file</a>(0) { |
| 105 | <a name="l00089"></a>00089 } |
| 106 | <a name="l00090"></a>00090 |
| 107 | <a name="l00092"></a>00092 <a class="code" href="classbdm_1_1merger__base.html#f9d8c6c26c6520dbb17d4e80f635e7be" title="Default constructor.">merger_base</a> ( <span class="keyword">const</span> Array<<a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<mpdf></a> > &S ); |
| 108 | <a name="l00093"></a>00093 |
| 109 | <a name="l00095"></a><a class="code" href="classbdm_1_1merger__base.html#871add803409c5cc3a634b4ff8fa997f">00095</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__base.html#871add803409c5cc3a634b4ff8fa997f" title="Function setting the main internal structures.">set_sources</a> ( <span class="keyword">const</span> Array<<a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<mpdf></a> > &Sources ) { |
| 110 | <a name="l00096"></a>00096 <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a> = Sources; |
| 111 | <a name="l00097"></a>00097 <a class="code" href="classbdm_1_1merger__base.html#4f6cd7ebe1c3c7556039dbfeb00f71f5" title="number of sources">Nsources</a> = <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a>.length(); |
| 112 | <a name="l00098"></a>00098 <span class="comment">//set sizes</span> |
| 113 | <a name="l00099"></a>00099 <a class="code" href="classbdm_1_1merger__base.html#09bc4d43dec350a40d17953b8b59d3b7" title="Data link for each mpdf in mpdfs.">dls</a>.set_size ( Sources.length() ); |
| 114 | <a name="l00100"></a>00100 <a class="code" href="classbdm_1_1merger__base.html#4e66803b04fc04b21b3716b3a317421f" title="Array of rvs that are not modelled by mpdfs at all, .">rvzs</a>.set_size ( Sources.length() ); |
| 115 | <a name="l00101"></a>00101 <a class="code" href="classbdm_1_1merger__base.html#8098858f2edb1294122cbe4f05bf8694" title="Data Links for extension .">zdls</a>.set_size ( Sources.length() ); |
| 116 | <a name="l00102"></a>00102 |
| 117 | <a name="l00103"></a>00103 <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> = get_composite_rv ( <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a>, <span class="comment">/* checkoverlap = */</span> <span class="keyword">false</span> ); |
| 118 | <a name="l00104"></a>00104 |
| 119 | <a name="l00105"></a>00105 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> rvc; |
| 120 | <a name="l00106"></a>00106 <span class="comment">// Extend rv by rvc!</span> |
| 121 | <a name="l00107"></a>00107 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a>.length(); i++ ) { |
| 122 | <a name="l00108"></a>00108 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> rvx = <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a> ( i )->_rvc().subt ( <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> ); |
| 123 | <a name="l00109"></a>00109 rvc.<a class="code" href="classbdm_1_1RV.html#87841b5ee43997b79789c0c22047e224" title="Add (concat) another variable to the current one,.">add</a> ( rvx ); <span class="comment">// add rv to common rvc</span> |
| 124 | <a name="l00110"></a>00110 } |
| 125 | <a name="l00111"></a>00111 |
| 126 | <a name="l00112"></a>00112 <span class="comment">// join rv and rvc - see descriprion</span> |
| 127 | <a name="l00113"></a>00113 <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#87841b5ee43997b79789c0c22047e224" title="Add (concat) another variable to the current one,.">add</a> ( rvc ); |
| 128 | <a name="l00114"></a>00114 <span class="comment">// get dimension</span> |
| 129 | <a name="l00115"></a>00115 <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> = <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#de30156104f61d86c94f758861418089">_dsize</a>(); |
| 130 | <a name="l00116"></a>00116 |
| 131 | <a name="l00117"></a>00117 <span class="comment">// create links between sources and common rv</span> |
| 132 | <a name="l00118"></a>00118 <a class="code" href="classbdm_1_1RV.html" title="Class representing variables, most often random variables.">RV</a> xytmp; |
| 133 | <a name="l00119"></a>00119 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a>.length(); i++ ) { |
| 134 | <a name="l00120"></a>00120 <span class="comment">//Establich connection between mpdfs and merger</span> |
| 135 | <a name="l00121"></a>00121 <a class="code" href="classbdm_1_1merger__base.html#09bc4d43dec350a40d17953b8b59d3b7" title="Data link for each mpdf in mpdfs.">dls</a> ( i ) = <span class="keyword">new</span> <a class="code" href="classbdm_1_1datalink__m2e.html" title="Data link with a condition.">datalink_m2e</a>; |
| 136 | <a name="l00122"></a>00122 <a class="code" href="classbdm_1_1merger__base.html#09bc4d43dec350a40d17953b8b59d3b7" title="Data link for each mpdf in mpdfs.">dls</a> ( i )->set_connection ( <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</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_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a> ( i )->_rvc(), <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> ); |
| 137 | <a name="l00123"></a>00123 |
| 138 | <a name="l00124"></a>00124 <span class="comment">// find out what is missing in each mpdf</span> |
| 139 | <a name="l00125"></a>00125 xytmp = <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a> ( i )->_rv(); |
| 140 | <a name="l00126"></a>00126 xytmp.<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_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a> ( i )->_rvc() ); |
| 141 | <a name="l00127"></a>00127 <span class="comment">// z_i = common_rv-xy</span> |
| 142 | <a name="l00128"></a>00128 <a class="code" href="classbdm_1_1merger__base.html#4e66803b04fc04b21b3716b3a317421f" title="Array of rvs that are not modelled by mpdfs at all, .">rvzs</a> ( i ) = <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a>.<a class="code" href="classbdm_1_1RV.html#aec44dabdf0a6d90fbae95e1356eda39" title="Subtract another variable from the current one.">subt</a> ( xytmp ); |
| 143 | <a name="l00129"></a>00129 <span class="comment">//establish connection between extension (z_i|x,y)s and common rv</span> |
| 144 | <a name="l00130"></a>00130 <a class="code" href="classbdm_1_1merger__base.html#8098858f2edb1294122cbe4f05bf8694" title="Data Links for extension .">zdls</a> ( i ) = <span class="keyword">new</span> <a class="code" href="classbdm_1_1datalink__m2e.html" title="Data link with a condition.">datalink_m2e</a>; |
| 145 | <a name="l00131"></a>00131 <a class="code" href="classbdm_1_1merger__base.html#8098858f2edb1294122cbe4f05bf8694" title="Data Links for extension .">zdls</a> ( i )->set_connection ( <a class="code" href="classbdm_1_1merger__base.html#4e66803b04fc04b21b3716b3a317421f" title="Array of rvs that are not modelled by mpdfs at all, .">rvzs</a> ( i ), xytmp, <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> ) ; |
| 146 | <a name="l00132"></a>00132 }; |
| 147 | <a name="l00133"></a>00133 } |
| 148 | <a name="l00135"></a><a class="code" href="classbdm_1_1merger__base.html#a9f469f841bb8d9cb9f30b9e3b93d26f">00135</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__base.html#a9f469f841bb8d9cb9f30b9e3b93d26f" title="Set support points from rectangular grid.">set_support</a> ( <a class="code" href="classbdm_1_1rectangular__support.html">rectangular_support</a> &Sup) { |
| 149 | <a name="l00136"></a>00136 <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a> = Sup.<a class="code" href="classbdm_1_1rectangular__support.html#a2cc3a7250b969675bc8f9034aa2a7d2" title="Access function.">points</a>(); |
| 150 | <a name="l00137"></a>00137 <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#c74c281d652356c19b6b079e42ca7ef1" title="Set sample.">set_parameters</a> ( <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a>, <span class="keyword">false</span> ); |
| 151 | <a name="l00138"></a>00138 Array<vec> &samples = <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#c24966b0aaeb767bc8a6b4fd60931be2" title="access function">_samples</a>(); |
| 152 | <a name="l00139"></a>00139 <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#d7f83cc0415cd44ae7cc8b4bdad93aef" title="Potentially dangerous, use with care.">_w</a>() = ones ( <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a> ) / <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a>; <span class="comment">//unifrom size of bins</span> |
| 153 | <a name="l00140"></a>00140 <span class="comment">//set samples</span> |
| 154 | <a name="l00141"></a>00141 samples(0)=Sup.<a class="code" href="classbdm_1_1rectangular__support.html#5e0baba7f6e7dc131e8c9131d37b4f94" title="set the first vector to corner and store result in actvec">first_vec</a>(); |
| 155 | <a name="l00142"></a>00142 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j=1; j < <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a>; j++ ) { |
| 156 | <a name="l00143"></a>00143 samples ( j ) = Sup.<a class="code" href="classbdm_1_1rectangular__support.html#adc4f5bdfd1b6f863cdf7961964eb23f" title="Get next active vector, call ONLY after first_vector()!">next_vec</a>(); |
| 157 | <a name="l00144"></a>00144 } |
| 158 | <a name="l00145"></a>00145 } |
| 159 | <a name="l00147"></a><a class="code" href="classbdm_1_1merger__base.html#0165a2b0eaaebb7a38cfb352b6150cda">00147</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__base.html#0165a2b0eaaebb7a38cfb352b6150cda" title="Set support points from dicrete grid.">set_support</a> ( <a class="code" href="classbdm_1_1discrete__support.html" title="Discrete support with stored support points.">discrete_support</a> &Sup) { |
| 160 | <a name="l00148"></a>00148 <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a> = Sup.<a class="code" href="classbdm_1_1discrete__support.html#dc3d175266b65168ba3f3a5f568078a1" title="Access function.">points</a>(); |
| 161 | <a name="l00149"></a>00149 <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#c74c281d652356c19b6b079e42ca7ef1" title="Set sample.">set_parameters</a>(Sup.<a class="code" href="classbdm_1_1discrete__support.html#1e9af8da7fa2ac2c03b3cec1d4407b1d" title="access function">_Spoints</a>()); |
| 162 | <a name="l00150"></a>00150 } |
| 163 | <a name="l00152"></a><a class="code" href="classbdm_1_1merger__base.html#e4514484bac243585b0a1e44325e8add">00152</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__base.html#e4514484bac243585b0a1e44325e8add" title="set debug file">set_debug_file</a> ( <span class="keyword">const</span> <span class="keywordtype">string</span> fname ) { |
| 164 | <a name="l00153"></a>00153 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1merger__base.html#dd180c651a75a131d125305f6bb017f7" title="debug or not debug">DBG</a> ) <span class="keyword">delete</span> <a class="code" href="classbdm_1_1merger__base.html#b2c6278b996696cb711cb7be900ccf5b" title="debugging file">dbg_file</a>; |
| 165 | <a name="l00154"></a>00154 <a class="code" href="classbdm_1_1merger__base.html#b2c6278b996696cb711cb7be900ccf5b" title="debugging file">dbg_file</a> = <span class="keyword">new</span> it_file ( fname ); |
| 166 | <a name="l00155"></a>00155 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1merger__base.html#b2c6278b996696cb711cb7be900ccf5b" title="debugging file">dbg_file</a> ) <a class="code" href="classbdm_1_1merger__base.html#dd180c651a75a131d125305f6bb017f7" title="debug or not debug">DBG</a> = <span class="keyword">true</span>; |
| 167 | <a name="l00156"></a>00156 } |
| 168 | <a name="l00158"></a><a class="code" href="classbdm_1_1merger__base.html#86698b7fd1e4320e9830d7dc24ee6c9e">00158</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__base.html#86698b7fd1e4320e9830d7dc24ee6c9e" title="Set internal parameters used in approximation.">set_method</a> ( MERGER_METHOD MTH = <a class="code" href="classbdm_1_1merger__base.html#7acdf3aeded70475ba8a26450a4e197c" title="Default for METHOD.">DFLT_METHOD</a>, <span class="keywordtype">double</span> beta0 = <a class="code" href="classbdm_1_1merger__base.html#dfe17e57529d84e122e61401543e9de6" title="default for beta">DFLT_beta</a> ) { |
| 169 | <a name="l00159"></a>00159 <a class="code" href="classbdm_1_1merger__base.html#ee197330820127f3d12106ddee6b25c7" title="switch of the methoh used for merging">METHOD</a> = MTH; |
| 170 | <a name="l00160"></a>00160 <a class="code" href="classbdm_1_1merger__base.html#972f64f6f388b929cf94d2c478116f14" title="Prior on the log-normal merging model.">beta</a> = beta0; |
| 171 | <a name="l00161"></a>00161 } |
| 172 | <a name="l00163"></a><a class="code" href="classbdm_1_1merger__base.html#28af7b365ecd8c3a15f0e934496871e0">00163</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__base.html#28af7b365ecd8c3a15f0e934496871e0" title="Set support points from a pdf by drawing N samples.">set_support</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> &overall, <span class="keywordtype">int</span> N ) { |
| 173 | <a name="l00164"></a>00164 <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#e7f8f98310c1de51bd5c8a1c87528f72" title="Set samples and weights.">set_statistics</a> ( overall, N ); |
| 174 | <a name="l00165"></a>00165 <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a> = N; |
| 175 | <a name="l00166"></a>00166 } |
| 176 | <a name="l00167"></a>00167 |
| 177 | <a name="l00169"></a><a class="code" href="classbdm_1_1merger__base.html#32d7e1dd6d91f77c81df7e82aac18689">00169</a> <span class="keyword">virtual</span> <a class="code" href="classbdm_1_1merger__base.html#32d7e1dd6d91f77c81df7e82aac18689" title="Destructor.">~merger_base</a>() { |
| 178 | <a name="l00170"></a>00170 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1merger__base.html#4f6cd7ebe1c3c7556039dbfeb00f71f5" title="number of sources">Nsources</a>; i++ ) { |
| 179 | <a name="l00171"></a>00171 <span class="keyword">delete</span> <a class="code" href="classbdm_1_1merger__base.html#09bc4d43dec350a40d17953b8b59d3b7" title="Data link for each mpdf in mpdfs.">dls</a> ( i ); |
| 180 | <a name="l00172"></a>00172 <span class="keyword">delete</span> <a class="code" href="classbdm_1_1merger__base.html#8098858f2edb1294122cbe4f05bf8694" title="Data Links for extension .">zdls</a> ( i ); |
| 181 | <a name="l00173"></a>00173 } |
| 182 | <a name="l00174"></a>00174 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1merger__base.html#dd180c651a75a131d125305f6bb017f7" title="debug or not debug">DBG</a> ) <span class="keyword">delete</span> <a class="code" href="classbdm_1_1merger__base.html#b2c6278b996696cb711cb7be900ccf5b" title="debugging file">dbg_file</a>; |
| 183 | <a name="l00175"></a>00175 }; |
| 184 | <a name="l00177"></a>00177 |
| 185 | <a name="l00180"></a>00180 |
| 186 | <a name="l00182"></a><a class="code" href="classbdm_1_1merger__base.html#df4a0094dcc40b3057675443bccb6511">00182</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__base.html#df4a0094dcc40b3057675443bccb6511" title="Merge given sources in given points.">merge</a> () { |
| 187 | <a name="l00183"></a>00183 <a class="code" href="classbdm_1_1merger__base.html#400e222d4c41dc57ac19e6735429c4cb" title="This method TODO.">validate</a>(); |
| 188 | <a name="l00184"></a>00184 |
| 189 | <a name="l00185"></a>00185 <span class="comment">//check if sources overlap:</span> |
| 190 | <a name="l00186"></a>00186 <span class="keywordtype">bool</span> OK = <span class="keyword">true</span>; |
| 191 | <a name="l00187"></a>00187 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a>.length(); i++ ) { |
| 192 | <a name="l00188"></a>00188 OK &= ( <a class="code" href="classbdm_1_1merger__base.html#4e66803b04fc04b21b3716b3a317421f" title="Array of rvs that are not modelled by mpdfs at all, .">rvzs</a> ( i )._dsize() == 0 ); <span class="comment">// z_i is empty</span> |
| 193 | <a name="l00189"></a>00189 OK &= ( <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a> ( i )->_rvc()._dsize() == 0 ); <span class="comment">// y_i is empty</span> |
| 194 | <a name="l00190"></a>00190 } |
| 195 | <a name="l00191"></a>00191 |
| 196 | <a name="l00192"></a>00192 <span class="keywordflow">if</span> ( OK ) { |
| 197 | <a name="l00193"></a>00193 mat lW = zeros ( <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a>.length(), <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#d7f83cc0415cd44ae7cc8b4bdad93aef" title="Potentially dangerous, use with care.">_w</a>().length() ); |
216 | | <a name="l00212"></a>00212 <span class="comment">//check if sources overlap:</span> |
217 | | <a name="l00213"></a>00213 <span class="keywordtype">bool</span> OK = <span class="keyword">true</span>; |
218 | | <a name="l00214"></a>00214 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a>.length(); i++ ) { |
219 | | <a name="l00215"></a>00215 OK &= ( <a class="code" href="classbdm_1_1merger__base.html#4e66803b04fc04b21b3716b3a317421f" title="Array of rvs that are not modelled by mpdfs at all, .">rvzs</a> ( i )._dsize() == 0 ); <span class="comment">// z_i is empty</span> |
220 | | <a name="l00216"></a>00216 OK &= ( <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a> ( i )->_rvc()._dsize() == 0 ); <span class="comment">// y_i is empty</span> |
221 | | <a name="l00217"></a>00217 } |
222 | | <a name="l00218"></a>00218 |
223 | | <a name="l00219"></a>00219 <span class="keywordflow">if</span> ( OK ) { |
224 | | <a name="l00220"></a>00220 mat lW = zeros ( <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a>.length(), <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#d7f83cc0415cd44ae7cc8b4bdad93aef" title="Potentially dangerous, use with care.">_w</a>().length() ); |
225 | | <a name="l00221"></a>00221 |
226 | | <a name="l00222"></a>00222 vec emptyvec ( 0 ); |
227 | | <a name="l00223"></a>00223 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a>.length(); i++ ) { |
228 | | <a name="l00224"></a>00224 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> j = 0; j < <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#d7f83cc0415cd44ae7cc8b4bdad93aef" title="Potentially dangerous, use with care.">_w</a>().length(); j++ ) { |
229 | | <a name="l00225"></a>00225 lW ( i, j ) = <a class="code" href="classbdm_1_1merger__base.html#3127be48ba35960b943d31aa8b9abf88" title="Elements of composition.">mpdfs</a> ( i )->evallogcond ( <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#c24966b0aaeb767bc8a6b4fd60931be2" title="access function">_samples</a>() ( j ), emptyvec ); |
230 | | <a name="l00226"></a>00226 } |
231 | | <a name="l00227"></a>00227 } |
232 | | <a name="l00228"></a>00228 |
233 | | <a name="l00229"></a>00229 vec w_nn = <a class="code" href="classbdm_1_1merger__base.html#1f52bf47d2cdd23a95b19e3da902e431" title="Merge log-likelihood values in points using method specified by parameter METHOD...">merge_points</a> ( lW ); |
234 | | <a name="l00230"></a>00230 vec wtmp = exp ( w_nn - max ( w_nn ) ); |
235 | | <a name="l00231"></a>00231 <span class="comment">//renormalize</span> |
236 | | <a name="l00232"></a>00232 <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#d7f83cc0415cd44ae7cc8b4bdad93aef" title="Potentially dangerous, use with care.">_w</a>() = wtmp / sum ( wtmp ); |
237 | | <a name="l00233"></a>00233 } <span class="keywordflow">else</span> { |
238 | | <a name="l00234"></a>00234 it_error ( <span class="stringliteral">"Sources are not compatible - use merger_mix"</span> ); |
239 | | <a name="l00235"></a>00235 } |
240 | | <a name="l00236"></a>00236 }; |
241 | | <a name="l00237"></a>00237 |
242 | | <a name="l00238"></a>00238 |
243 | | <a name="l00240"></a>00240 vec <a class="code" href="classbdm_1_1merger__base.html#1f52bf47d2cdd23a95b19e3da902e431" title="Merge log-likelihood values in points using method specified by parameter METHOD...">merge_points</a> ( mat &lW ); |
244 | | <a name="l00241"></a>00241 |
245 | | <a name="l00242"></a>00242 |
246 | | <a name="l00245"></a><a class="code" href="classbdm_1_1merger__base.html#021acbf1a6e3bfde2a1b9c1c73cea6e0">00245</a> vec <a class="code" href="classbdm_1_1merger__base.html#021acbf1a6e3bfde2a1b9c1c73cea6e0" title="weight w is a">mean</a>()<span class="keyword"> const </span>{ |
247 | | <a name="l00246"></a>00246 <span class="keyword">const</span> Vec<double> &w = <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#d7f83cc0415cd44ae7cc8b4bdad93aef" title="Potentially dangerous, use with care.">_w</a>(); |
248 | | <a name="l00247"></a>00247 <span class="keyword">const</span> Array<vec> &S = <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#c24966b0aaeb767bc8a6b4fd60931be2" title="access function">_samples</a>(); |
249 | | <a name="l00248"></a>00248 vec tmp = zeros ( <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> ); |
250 | | <a name="l00249"></a>00249 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a>; i++ ) { |
251 | | <a name="l00250"></a>00250 tmp += w ( i ) * S ( i ); |
252 | | <a name="l00251"></a>00251 } |
253 | | <a name="l00252"></a>00252 <span class="keywordflow">return</span> tmp; |
254 | | <a name="l00253"></a>00253 } |
255 | | <a name="l00254"></a>00254 mat covariance()<span class="keyword"> const </span>{ |
256 | | <a name="l00255"></a>00255 <span class="keyword">const</span> vec &w = <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#d7f83cc0415cd44ae7cc8b4bdad93aef" title="Potentially dangerous, use with care.">_w</a>(); |
257 | | <a name="l00256"></a>00256 <span class="keyword">const</span> Array<vec> &S = <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#c24966b0aaeb767bc8a6b4fd60931be2" title="access function">_samples</a>(); |
258 | | <a name="l00257"></a>00257 |
259 | | <a name="l00258"></a>00258 vec mea = <a class="code" href="classbdm_1_1merger__base.html#021acbf1a6e3bfde2a1b9c1c73cea6e0" title="weight w is a">mean</a>(); |
260 | | <a name="l00259"></a>00259 |
261 | | <a name="l00260"></a>00260 <span class="comment">// cout << sum (w) << "," << w*w << endl;</span> |
262 | | <a name="l00261"></a>00261 |
263 | | <a name="l00262"></a>00262 mat Tmp = zeros ( <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>, <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> ); |
264 | | <a name="l00263"></a>00263 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a>; i++ ) { |
265 | | <a name="l00264"></a>00264 Tmp += w ( i ) * outer_product ( S ( i ), S ( i ) ); |
266 | | <a name="l00265"></a>00265 } |
267 | | <a name="l00266"></a>00266 <span class="keywordflow">return</span> Tmp - outer_product ( mea, mea ); |
268 | | <a name="l00267"></a>00267 } |
269 | | <a name="l00268"></a><a class="code" href="classbdm_1_1merger__base.html#76fe431922844d132b4e1ecf70f53c99">00268</a> vec <a class="code" href="classbdm_1_1merger__base.html#76fe431922844d132b4e1ecf70f53c99" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{ |
270 | | <a name="l00269"></a>00269 <span class="keyword">const</span> vec &w = <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#d7f83cc0415cd44ae7cc8b4bdad93aef" title="Potentially dangerous, use with care.">_w</a>(); |
271 | | <a name="l00270"></a>00270 <span class="keyword">const</span> Array<vec> &S = <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#c24966b0aaeb767bc8a6b4fd60931be2" title="access function">_samples</a>(); |
272 | | <a name="l00271"></a>00271 |
273 | | <a name="l00272"></a>00272 vec tmp = zeros ( <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> ); |
274 | | <a name="l00273"></a>00273 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1merger__base.html#4f6cd7ebe1c3c7556039dbfeb00f71f5" title="number of sources">Nsources</a>; i++ ) { |
275 | | <a name="l00274"></a>00274 tmp += w ( i ) * pow ( S ( i ), 2 ); |
276 | | <a name="l00275"></a>00275 } |
277 | | <a name="l00276"></a>00276 <span class="keywordflow">return</span> tmp - pow ( <a class="code" href="classbdm_1_1merger__base.html#021acbf1a6e3bfde2a1b9c1c73cea6e0" title="weight w is a">mean</a>(), 2 ); |
278 | | <a name="l00277"></a>00277 } |
279 | | <a name="l00279"></a>00279 |
| 216 | <a name="l00213"></a>00213 vec <a class="code" href="classbdm_1_1merger__base.html#1f52bf47d2cdd23a95b19e3da902e431" title="Merge log-likelihood values in points using method specified by parameter METHOD...">merge_points</a> ( mat &lW ); |
| 217 | <a name="l00214"></a>00214 |
| 218 | <a name="l00215"></a>00215 |
| 219 | <a name="l00218"></a><a class="code" href="classbdm_1_1merger__base.html#021acbf1a6e3bfde2a1b9c1c73cea6e0">00218</a> vec <a class="code" href="classbdm_1_1merger__base.html#021acbf1a6e3bfde2a1b9c1c73cea6e0" title="weight w is a">mean</a>()<span class="keyword"> const </span>{ |
| 220 | <a name="l00219"></a>00219 <span class="keyword">const</span> Vec<double> &w = <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#d7f83cc0415cd44ae7cc8b4bdad93aef" title="Potentially dangerous, use with care.">_w</a>(); |
| 221 | <a name="l00220"></a>00220 <span class="keyword">const</span> Array<vec> &S = <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#c24966b0aaeb767bc8a6b4fd60931be2" title="access function">_samples</a>(); |
| 222 | <a name="l00221"></a>00221 vec tmp = zeros ( <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> ); |
| 223 | <a name="l00222"></a>00222 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a>; i++ ) { |
| 224 | <a name="l00223"></a>00223 tmp += w ( i ) * S ( i ); |
| 225 | <a name="l00224"></a>00224 } |
| 226 | <a name="l00225"></a>00225 <span class="keywordflow">return</span> tmp; |
| 227 | <a name="l00226"></a>00226 } |
| 228 | <a name="l00227"></a>00227 mat covariance()<span class="keyword"> const </span>{ |
| 229 | <a name="l00228"></a>00228 <span class="keyword">const</span> vec &w = <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#d7f83cc0415cd44ae7cc8b4bdad93aef" title="Potentially dangerous, use with care.">_w</a>(); |
| 230 | <a name="l00229"></a>00229 <span class="keyword">const</span> Array<vec> &S = <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#c24966b0aaeb767bc8a6b4fd60931be2" title="access function">_samples</a>(); |
| 231 | <a name="l00230"></a>00230 |
| 232 | <a name="l00231"></a>00231 vec mea = <a class="code" href="classbdm_1_1merger__base.html#021acbf1a6e3bfde2a1b9c1c73cea6e0" title="weight w is a">mean</a>(); |
| 233 | <a name="l00232"></a>00232 |
| 234 | <a name="l00233"></a>00233 <span class="comment">// cout << sum (w) << "," << w*w << endl;</span> |
| 235 | <a name="l00234"></a>00234 |
| 236 | <a name="l00235"></a>00235 mat Tmp = zeros ( <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a>, <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> ); |
| 237 | <a name="l00236"></a>00236 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1merger__base.html#39d263d92aa85553730c44958a92a541" title="number of support points">Npoints</a>; i++ ) { |
| 238 | <a name="l00237"></a>00237 Tmp += w ( i ) * outer_product ( S ( i ), S ( i ) ); |
| 239 | <a name="l00238"></a>00238 } |
| 240 | <a name="l00239"></a>00239 <span class="keywordflow">return</span> Tmp - outer_product ( mea, mea ); |
| 241 | <a name="l00240"></a>00240 } |
| 242 | <a name="l00241"></a><a class="code" href="classbdm_1_1merger__base.html#76fe431922844d132b4e1ecf70f53c99">00241</a> vec <a class="code" href="classbdm_1_1merger__base.html#76fe431922844d132b4e1ecf70f53c99" title="return expected variance (not covariance!)">variance</a>()<span class="keyword"> const </span>{ |
| 243 | <a name="l00242"></a>00242 <span class="keyword">const</span> vec &w = <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#d7f83cc0415cd44ae7cc8b4bdad93aef" title="Potentially dangerous, use with care.">_w</a>(); |
| 244 | <a name="l00243"></a>00243 <span class="keyword">const</span> Array<vec> &S = <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>.<a class="code" href="classbdm_1_1eEmp.html#c24966b0aaeb767bc8a6b4fd60931be2" title="access function">_samples</a>(); |
| 245 | <a name="l00244"></a>00244 |
| 246 | <a name="l00245"></a>00245 vec tmp = zeros ( <a class="code" href="classbdm_1_1epdf.html#16adac20ec7fe07e1ea0b27d917788ce" title="dimension of the random variable">dim</a> ); |
| 247 | <a name="l00246"></a>00246 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < <a class="code" href="classbdm_1_1merger__base.html#4f6cd7ebe1c3c7556039dbfeb00f71f5" title="number of sources">Nsources</a>; i++ ) { |
| 248 | <a name="l00247"></a>00247 tmp += w ( i ) * pow ( S ( i ), 2 ); |
| 249 | <a name="l00248"></a>00248 } |
| 250 | <a name="l00249"></a>00249 <span class="keywordflow">return</span> tmp - pow ( <a class="code" href="classbdm_1_1merger__base.html#021acbf1a6e3bfde2a1b9c1c73cea6e0" title="weight w is a">mean</a>(), 2 ); |
| 251 | <a name="l00250"></a>00250 } |
| 252 | <a name="l00252"></a>00252 |
| 253 | <a name="l00255"></a>00255 |
| 254 | <a name="l00257"></a><a class="code" href="classbdm_1_1merger__base.html#fb682e470103f4e0b353b7c9200d177f">00257</a> <a class="code" href="classbdm_1_1eEmp.html" title="Weighted empirical density.">eEmp</a>& <a class="code" href="classbdm_1_1merger__base.html#fb682e470103f4e0b353b7c9200d177f" title="Access function.">_Smp</a>() { |
| 255 | <a name="l00258"></a>00258 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1merger__base.html#a042ce6ee1fb91048ea89bec9934718e" title="Projection to empirical density (could also be piece-wise linear).">eSmp</a>; |
| 256 | <a name="l00259"></a>00259 } |
| 257 | <a name="l00260"></a>00260 |
| 258 | <a name="l00262"></a><a class="code" href="classbdm_1_1merger__base.html#10dd390fc6f0d1733bb07cb51977160c">00262</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__base.html#10dd390fc6f0d1733bb07cb51977160c" title="load from setting">from_setting</a> ( <span class="keyword">const</span> Setting& <span class="keyword">set</span> ) { |
| 259 | <a name="l00263"></a>00263 <span class="comment">// get support</span> |
| 260 | <a name="l00264"></a>00264 <span class="comment">// find which method to use</span> |
| 261 | <a name="l00265"></a>00265 <span class="keywordtype">string</span> meth_str; |
| 262 | <a name="l00266"></a>00266 UI::get<string> ( meth_str, <span class="keyword">set</span>, <span class="stringliteral">"method"</span>, UI::compulsory ); |
| 263 | <a name="l00267"></a>00267 <span class="keywordflow">if</span> ( !strcmp ( meth_str.c_str(), <span class="stringliteral">"arithmetic"</span> ) ) |
| 264 | <a name="l00268"></a>00268 <a class="code" href="classbdm_1_1merger__base.html#86698b7fd1e4320e9830d7dc24ee6c9e" title="Set internal parameters used in approximation.">set_method</a> ( ARITHMETIC ); |
| 265 | <a name="l00269"></a>00269 <span class="keywordflow">else</span> { |
| 266 | <a name="l00270"></a>00270 <span class="keywordflow">if</span> ( !strcmp ( meth_str.c_str(), <span class="stringliteral">"geometric"</span> ) ) |
| 267 | <a name="l00271"></a>00271 <a class="code" href="classbdm_1_1merger__base.html#86698b7fd1e4320e9830d7dc24ee6c9e" title="Set internal parameters used in approximation.">set_method</a> ( GEOMETRIC ); |
| 268 | <a name="l00272"></a>00272 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( !strcmp ( meth_str.c_str(), <span class="stringliteral">"lognormal"</span> ) ) { |
| 269 | <a name="l00273"></a>00273 <a class="code" href="classbdm_1_1merger__base.html#86698b7fd1e4320e9830d7dc24ee6c9e" title="Set internal parameters used in approximation.">set_method</a> ( LOGNORMAL ); |
| 270 | <a name="l00274"></a>00274 <span class="keyword">set</span>.lookupValue ( <span class="stringliteral">"beta"</span>, <a class="code" href="classbdm_1_1merger__base.html#972f64f6f388b929cf94d2c478116f14" title="Prior on the log-normal merging model.">beta</a> ); |
| 271 | <a name="l00275"></a>00275 } |
| 272 | <a name="l00276"></a>00276 } |
| 273 | <a name="l00277"></a>00277 <span class="keywordtype">string</span> <a class="code" href="classbdm_1_1merger__base.html#b2c6278b996696cb711cb7be900ccf5b" title="debugging file">dbg_file</a>; |
| 274 | <a name="l00278"></a>00278 <span class="keywordflow">if</span> ( <a class="code" href="classbdm_1_1UI.html#cd1667e6fec99ec64dabcb3ca2ff922d">UI::get</a> ( dbg_file, <span class="keyword">set</span>, <span class="stringliteral">"dbg_file"</span> ) ) |
| 275 | <a name="l00279"></a>00279 <a class="code" href="classbdm_1_1merger__base.html#e4514484bac243585b0a1e44325e8add" title="set debug file">set_debug_file</a> ( dbg_file ); |
| 276 | <a name="l00280"></a>00280 <span class="comment">//validate() - not used</span> |
| 277 | <a name="l00281"></a>00281 } |
315 | | <a name="l00321"></a><a class="code" href="classbdm_1_1merger__mix.html">00321</a> <span class="keyword">class </span><a class="code" href="classbdm_1_1merger__mix.html" title="Merger using importance sampling with mixture proposal density.">merger_mix</a> : <span class="keyword">public</span> <a class="code" href="classbdm_1_1merger__base.html" title="Base class for general combination of pdfs on discrete support.">merger_base</a> { |
316 | | <a name="l00322"></a>00322 <span class="keyword">protected</span>: |
317 | | <a name="l00324"></a><a class="code" href="classbdm_1_1merger__mix.html#cb885228de5b2822d33d7cea4de53112">00324</a> <a class="code" href="classbdm_1_1MixEF.html" title="Mixture of Exponential Family Densities.">MixEF</a> <a class="code" href="classbdm_1_1merger__mix.html#cb885228de5b2822d33d7cea4de53112" title="Internal mixture of EF models.">Mix</a>; |
318 | | <a name="l00326"></a><a class="code" href="classbdm_1_1merger__mix.html#83275ad036e7acda876babfa6ac1f07f">00326</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1merger__mix.html#83275ad036e7acda876babfa6ac1f07f" title="Number of components in a mixture.">Ncoms</a>; |
319 | | <a name="l00328"></a><a class="code" href="classbdm_1_1merger__mix.html#cb7d8918bea514f62321988dfd0d6b58">00328</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1merger__mix.html#cb7d8918bea514f62321988dfd0d6b58" title="coefficient of resampling [0,1]">effss_coef</a>; |
320 | | <a name="l00330"></a><a class="code" href="classbdm_1_1merger__mix.html#996571da3a24431a9d159e625b0717cd">00330</a> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1merger__mix.html#996571da3a24431a9d159e625b0717cd" title="stop after niter iterations">stop_niter</a>; |
321 | | <a name="l00331"></a>00331 |
322 | | <a name="l00333"></a><a class="code" href="classbdm_1_1merger__mix.html#615688c5aeea9a7eee2b0b4424e8ceab">00333</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="classbdm_1_1merger__mix.html#615688c5aeea9a7eee2b0b4424e8ceab" title="default value for Ncoms">DFLT_Ncoms</a>; |
323 | | <a name="l00335"></a><a class="code" href="classbdm_1_1merger__mix.html#3ee8d9f7055b573c02e6a35875ec2397">00335</a> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1merger__mix.html#3ee8d9f7055b573c02e6a35875ec2397" title="default value for efss_coef;">DFLT_effss_coef</a>; |
324 | | <a name="l00336"></a>00336 |
325 | | <a name="l00337"></a>00337 <span class="keyword">public</span>: |
326 | | <a name="l00340"></a>00340 <a class="code" href="classbdm_1_1merger__mix.html" title="Merger using importance sampling with mixture proposal density.">merger_mix</a> ():<a class="code" href="classbdm_1_1merger__mix.html#83275ad036e7acda876babfa6ac1f07f" title="Number of components in a mixture.">Ncoms</a>(0), <a class="code" href="classbdm_1_1merger__mix.html#cb7d8918bea514f62321988dfd0d6b58" title="coefficient of resampling [0,1]">effss_coef</a>(0), <a class="code" href="classbdm_1_1merger__mix.html#996571da3a24431a9d159e625b0717cd" title="stop after niter iterations">stop_niter</a>(0) { } |
327 | | <a name="l00341"></a>00341 |
328 | | <a name="l00342"></a>00342 <a class="code" href="classbdm_1_1merger__mix.html" title="Merger using importance sampling with mixture proposal density.">merger_mix</a> ( <span class="keyword">const</span> Array<<a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<mpdf></a> > &S ): |
329 | | <a name="l00343"></a>00343 <a class="code" href="classbdm_1_1merger__mix.html#83275ad036e7acda876babfa6ac1f07f" title="Number of components in a mixture.">Ncoms</a>(0), <a class="code" href="classbdm_1_1merger__mix.html#cb7d8918bea514f62321988dfd0d6b58" title="coefficient of resampling [0,1]">effss_coef</a>(0), <a class="code" href="classbdm_1_1merger__mix.html#996571da3a24431a9d159e625b0717cd" title="stop after niter iterations">stop_niter</a>(0) { |
330 | | <a name="l00344"></a>00344 <a class="code" href="classbdm_1_1merger__mix.html#ff4c1e544c33073438e7f5da38b0f3b8" title="Set sources and prepare all internal structures.">set_sources</a> ( S ); |
331 | | <a name="l00345"></a>00345 } |
332 | | <a name="l00346"></a>00346 |
333 | | <a name="l00348"></a><a class="code" href="classbdm_1_1merger__mix.html#ff4c1e544c33073438e7f5da38b0f3b8">00348</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__mix.html#ff4c1e544c33073438e7f5da38b0f3b8" title="Set sources and prepare all internal structures.">set_sources</a> ( <span class="keyword">const</span> Array<<a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<mpdf></a> > &S ) { |
334 | | <a name="l00349"></a>00349 <a class="code" href="classbdm_1_1merger__mix.html#ff4c1e544c33073438e7f5da38b0f3b8" title="Set sources and prepare all internal structures.">merger_base::set_sources</a> ( S ); |
335 | | <a name="l00350"></a>00350 <a class="code" href="classbdm_1_1merger__base.html#4f6cd7ebe1c3c7556039dbfeb00f71f5" title="number of sources">Nsources</a> = S.length(); |
336 | | <a name="l00351"></a>00351 } |
337 | | <a name="l00352"></a>00352 |
338 | | <a name="l00354"></a><a class="code" href="classbdm_1_1merger__mix.html#a6d90b23edca00d392cd472297a57fe3">00354</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__mix.html#a6d90b23edca00d392cd472297a57fe3" title="Set internal parameters used in approximation.">set_parameters</a> ( <span class="keywordtype">int</span> Ncoms0 = <a class="code" href="classbdm_1_1merger__mix.html#615688c5aeea9a7eee2b0b4424e8ceab" title="default value for Ncoms">DFLT_Ncoms</a>, <span class="keywordtype">double</span> effss_coef0 = <a class="code" href="classbdm_1_1merger__mix.html#3ee8d9f7055b573c02e6a35875ec2397" title="default value for efss_coef;">DFLT_effss_coef</a> ) { |
339 | | <a name="l00355"></a>00355 <a class="code" href="classbdm_1_1merger__mix.html#83275ad036e7acda876babfa6ac1f07f" title="Number of components in a mixture.">Ncoms</a> = Ncoms0; |
340 | | <a name="l00356"></a>00356 <a class="code" href="classbdm_1_1merger__mix.html#cb7d8918bea514f62321988dfd0d6b58" title="coefficient of resampling [0,1]">effss_coef</a> = effss_coef0; |
341 | | <a name="l00357"></a>00357 } |
342 | | <a name="l00359"></a>00359 |
343 | | <a name="l00362"></a>00362 |
344 | | <a name="l00364"></a>00364 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__mix.html#6e800116f761e46b33a822d7cea01dc8" title="Merge values using mixture approximation.">merge</a> (); |
345 | | <a name="l00365"></a>00365 |
346 | | <a name="l00367"></a><a class="code" href="classbdm_1_1merger__mix.html#0991d4ac37cc7fc44b5b065983de3dd8">00367</a> vec <a class="code" href="classbdm_1_1merger__mix.html#0991d4ac37cc7fc44b5b065983de3dd8" title="sample from the approximating mixture">sample</a> ()<span class="keyword"> const </span>{ |
347 | | <a name="l00368"></a>00368 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1merger__mix.html#cb885228de5b2822d33d7cea4de53112" title="Internal mixture of EF models.">Mix</a>.<a class="code" href="classbdm_1_1MixEF.html#4830916adef7891a207e42f39aaf787b">posterior</a>().<a class="code" href="classbdm_1_1epdf.html#75ba57a89681a8efec488f5796c7cc1b" title="Returns a sample, from density .">sample</a>(); |
| 306 | <a name="l00321"></a><a class="code" href="classbdm_1_1merger__mix.html#ff4c1e544c33073438e7f5da38b0f3b8">00321</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__mix.html#ff4c1e544c33073438e7f5da38b0f3b8" title="Set sources and prepare all internal structures.">set_sources</a> ( <span class="keyword">const</span> Array<<a class="code" href="classbdm_1_1shared__ptr.html">shared_ptr<mpdf></a> > &S ) { |
| 307 | <a name="l00322"></a>00322 <a class="code" href="classbdm_1_1merger__mix.html#ff4c1e544c33073438e7f5da38b0f3b8" title="Set sources and prepare all internal structures.">merger_base::set_sources</a> ( S ); |
| 308 | <a name="l00323"></a>00323 <a class="code" href="classbdm_1_1merger__base.html#4f6cd7ebe1c3c7556039dbfeb00f71f5" title="number of sources">Nsources</a> = S.length(); |
| 309 | <a name="l00324"></a>00324 } |
| 310 | <a name="l00325"></a>00325 |
| 311 | <a name="l00327"></a><a class="code" href="classbdm_1_1merger__mix.html#a6d90b23edca00d392cd472297a57fe3">00327</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__mix.html#a6d90b23edca00d392cd472297a57fe3" title="Set internal parameters used in approximation.">set_parameters</a> ( <span class="keywordtype">int</span> Ncoms0 = <a class="code" href="classbdm_1_1merger__mix.html#615688c5aeea9a7eee2b0b4424e8ceab" title="default value for Ncoms">DFLT_Ncoms</a>, <span class="keywordtype">double</span> effss_coef0 = <a class="code" href="classbdm_1_1merger__mix.html#3ee8d9f7055b573c02e6a35875ec2397" title="default value for efss_coef;">DFLT_effss_coef</a> ) { |
| 312 | <a name="l00328"></a>00328 <a class="code" href="classbdm_1_1merger__mix.html#83275ad036e7acda876babfa6ac1f07f" title="Number of components in a mixture.">Ncoms</a> = Ncoms0; |
| 313 | <a name="l00329"></a>00329 <a class="code" href="classbdm_1_1merger__mix.html#cb7d8918bea514f62321988dfd0d6b58" title="coefficient of resampling [0,1]">effss_coef</a> = effss_coef0; |
| 314 | <a name="l00330"></a>00330 } |
| 315 | <a name="l00332"></a>00332 |
| 316 | <a name="l00335"></a>00335 |
| 317 | <a name="l00337"></a>00337 <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__mix.html#6e800116f761e46b33a822d7cea01dc8" title="Merge values using mixture approximation.">merge</a> (); |
| 318 | <a name="l00338"></a>00338 |
| 319 | <a name="l00340"></a><a class="code" href="classbdm_1_1merger__mix.html#0991d4ac37cc7fc44b5b065983de3dd8">00340</a> vec <a class="code" href="classbdm_1_1merger__mix.html#0991d4ac37cc7fc44b5b065983de3dd8" title="sample from the approximating mixture">sample</a> ()<span class="keyword"> const </span>{ |
| 320 | <a name="l00341"></a>00341 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1merger__mix.html#cb885228de5b2822d33d7cea4de53112" title="Internal mixture of EF models.">Mix</a>.<a class="code" href="classbdm_1_1MixEF.html#4830916adef7891a207e42f39aaf787b">posterior</a>().<a class="code" href="classbdm_1_1epdf.html#75ba57a89681a8efec488f5796c7cc1b" title="Returns a sample, from density .">sample</a>(); |
| 321 | <a name="l00342"></a>00342 } |
| 322 | <a name="l00344"></a><a class="code" href="classbdm_1_1merger__mix.html#9737ad6d1ecf4e0cdd6cea6a40875a34">00344</a> <span class="keywordtype">double</span> <a class="code" href="classbdm_1_1merger__mix.html#9737ad6d1ecf4e0cdd6cea6a40875a34" title="loglikelihood computed on mixture models">evallog</a> ( <span class="keyword">const</span> vec &dt )<span class="keyword"> const </span>{ |
| 323 | <a name="l00345"></a>00345 vec dtf = ones ( dt.length() + 1 ); |
| 324 | <a name="l00346"></a>00346 dtf.set_subvector ( 0, dt ); |
| 325 | <a name="l00347"></a>00347 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1merger__mix.html#cb885228de5b2822d33d7cea4de53112" title="Internal mixture of EF models.">Mix</a>.<a class="code" href="classbdm_1_1MixEF.html#da724da464a75e07521941e430929efa">logpred</a> ( dtf ); |
| 326 | <a name="l00348"></a>00348 } |
| 327 | <a name="l00350"></a>00350 |
| 328 | <a name="l00354"></a><a class="code" href="classbdm_1_1merger__mix.html#fa37f0606bbdab195986995b77d57b67">00354</a> <a class="code" href="classbdm_1_1MixEF.html" title="Mixture of Exponential Family Densities.">MixEF</a>& <a class="code" href="classbdm_1_1merger__mix.html#fa37f0606bbdab195986995b77d57b67" title="Access function.">_Mix</a>() { |
| 329 | <a name="l00355"></a>00355 <span class="keywordflow">return</span> <a class="code" href="classbdm_1_1merger__mix.html#cb885228de5b2822d33d7cea4de53112" title="Internal mixture of EF models.">Mix</a>; |
| 330 | <a name="l00356"></a>00356 } |
| 331 | <a name="l00358"></a><a class="code" href="classbdm_1_1merger__mix.html#1daae5402e15784f2ec1e88324930c12">00358</a> <a class="code" href="classbdm_1_1emix.html" title="Mixture of epdfs.">emix</a>* <a class="code" href="classbdm_1_1merger__mix.html#1daae5402e15784f2ec1e88324930c12" title="Access function.">proposal</a>() { |
| 332 | <a name="l00359"></a>00359 <a class="code" href="classbdm_1_1emix.html" title="Mixture of epdfs.">emix</a>* tmp = <a class="code" href="classbdm_1_1merger__mix.html#cb885228de5b2822d33d7cea4de53112" title="Internal mixture of EF models.">Mix</a>.<a class="code" href="classbdm_1_1MixEF.html#edc50e9640f049b846084748b18469a2" title="Constructs a predictive density .">epredictor</a>(); |
| 333 | <a name="l00360"></a>00360 tmp-><a class="code" href="classbdm_1_1emix.html#04a8632cfa9299ae937228eb732fd61e" title="Name its rv.">set_rv</a> ( <a class="code" href="classbdm_1_1epdf.html#62c5b8ff71d9ebe6cd58d3c342eb1dc8" title="Description of the random variable.">rv</a> ); |
| 334 | <a name="l00361"></a>00361 <span class="keywordflow">return</span> tmp; |
| 335 | <a name="l00362"></a>00362 } |
| 336 | <a name="l00364"></a><a class="code" href="classbdm_1_1merger__mix.html#9f12b2c66344e25e6b3ef0255d000478">00364</a> <span class="keywordtype">void</span> <a class="code" href="classbdm_1_1merger__mix.html#9f12b2c66344e25e6b3ef0255d000478" title="from_settings">from_setting</a> ( <span class="keyword">const</span> Setting& <span class="keyword">set</span> ) { |
| 337 | <a name="l00365"></a>00365 <a class="code" href="classbdm_1_1merger__mix.html#9f12b2c66344e25e6b3ef0255d000478" title="from_settings">merger_base::from_setting</a> ( <span class="keyword">set</span> ); |
| 338 | <a name="l00366"></a>00366 <span class="keyword">set</span>.lookupValue ( <span class="stringliteral">"ncoms"</span>, <a class="code" href="classbdm_1_1merger__mix.html#83275ad036e7acda876babfa6ac1f07f" title="Number of components in a mixture.">Ncoms</a> ); |
| 339 | <a name="l00367"></a>00367 <span class="keyword">set</span>.lookupValue ( <span class="stringliteral">"effss_coef"</span>, <a class="code" href="classbdm_1_1merger__mix.html#cb7d8918bea514f62321988dfd0d6b58" title="coefficient of resampling [0,1]">effss_coef</a> ); |
| 340 | <a name="l00368"></a>00368 <span class="keyword">set</span>.lookupValue ( <span class="stringliteral">"stop_niter"</span>, <a class="code" href="classbdm_1_1merger__mix.html#996571da3a24431a9d159e625b0717cd" title="stop after niter iterations">stop_niter</a> ); |