ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_sampleVar::setVarMeanMerged Interface Reference

Return the (weighted) merged variance and mean of a complex or real sample resulting from the merger of two separate (weighted) samples \(A\) and \(B\).
More...

Detailed Description

Return the (weighted) merged variance and mean of a complex or real sample resulting from the merger of two separate (weighted) samples \(A\) and \(B\).

See the documentation of pm_sampleVar and pm_sampleMean for more information and definition online updating of sample variance and mean.

Note
The input and output variances of this generic interface are all biased variances.
A biased variance can be readily unbiased by multiplying it with the appropriate bias-correction factors detailed in the documentation of pm_sampleVar.
Parameters
[out]varMerged: The output object of the same type and kind and rank and shape as meanA, containing the biased variance of the sample resulting form the merger of the two samples.
(optional. If missing, the resulting merged variance will be written to the argument varB.)
[out]meanMerged: The output object of the same type and kind and rank and shape as meanA, containing the mean of the sample resulting form the merger of the two samples.
(optional. If missing, the resulting merged mean will be written to the argument meanB.)
[in,out]varB: The input or input/output object of type real of the same kind and rank and shape as the input argument meanA, containing the biased variance of the second sample that must be merged with the first sample.
If the input argument varMerged is missing, then varB contains the updated biased variance of the merged sample on return.
Otherwise, the contents of varB remain intact upon return.
[in,out]meanB: The input or input/output object of the same type and kind and rank and shape as the input argument meanA, containing the mean of the second sample that must be merged with the first sample.
If the input argument meanMerged is missing, then meanB contains the updated mean of the merged sample on return.
Otherwise, the contents of meanB remain intact upon return.
[in]varA: The input scalar or contiguous vector of shape (1:ndim) of type real of the same kind as the kind of the input argument meanA, containing the biased variance of the first sample that must be merged with the second sample.
[in]meanA: The input scalar or contiguous vector of shape (1:ndim) of,
  1. type complex of kind any supported by the processor (e.g., CK, CK32, CK64, or CK128),
  2. type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
containing the mean of the first sample that must be merged with the second sample.
[in]fracA: The input scalar of type real of the same kind as kind of varA, containing the ratio of the sum of the weights of all points in sample \(A\) to sum of weights of all points in the merged sample.
If the sample is unweighted, then fracA is simply size(sampleA) / (size(sampleA) + size(sampleB)).


Possible calling interfaces

! univariate sample
call setVarMeanMerged(varB, meanB, varA, meanA, fracA)
call setVarMeanMerged(varMerged, meanMerged, varB, meanB, varA, meanA, fracA)
! ndim-dimensional sample
call setVarMeanMerged(varB(1:ndim), varA(1:ndim), meanDiff(1:ndim), fracA)
call setVarMeanMerged(varMerged(1:ndim), varB(1:ndim), varA(1:ndim), meanDiff(1:ndim), fracA)
Return the (weighted) merged variance and mean of a complex or real sample resulting from the merger ...
This module contains classes and procedures for computing the properties related to the covariance ma...
Warning
The condition 0 < fracA .and. fracA < 1 must hold for the corresponding input arguments.
The condition size(varB) == size(varA) must hold for the corresponding input arguments.
The condition size(varA) == size(meanA) must hold for the corresponding input arguments.
The condition size(varA) == size(meanB) must hold for the corresponding input arguments.
The condition size(varA) == size(varMearged) must hold for the corresponding input arguments.
The condition size(varA) == size(meanMearged) must hold for the corresponding input arguments.
These conditions are verified only if the library is built with the preprocessor macro CHECK_ENABLED=1.
The pure procedure(s) documented herein become impure when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1.
By default, these procedures are pure in release build and impure in debug and testing builds.
See also
getCor
setCor
getCov
setCov
getVar
setVar
getMean
setMean
getCovMerged
setCovMerged
getVarMerged
setVarMerged
getMeanMerged
setMeanMerged
setVarMeanMerged
setVarMeanMerged


Example usage

1program example
2
3 use pm_kind, only: SK, IK
4 use pm_kind, only: TKG => RKS ! All other real types are also supported.
5 use pm_sampleVar, only: getVar
6 use pm_sampleMean, only: getMean
10 use pm_distUnif, only: getUnifRand
11 use pm_arrayRange, only: getRange
12 use pm_io, only: display_type
13
14 implicit none
15
16 integer(IK), parameter :: nsam = 2
17 integer(IK), allocatable :: iweight(:)
18 integer(IK) :: isam, ndim, lb(nsam), ub(nsam)
19 integer(IK) :: dim, itry, ntry = 5
20 type(display_type) :: disp
21 disp = display_type(file = "main.out.F90")
22
23 call disp%skip()
24 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
25 call disp%show("!Compute the biased merged variance and mean of a univariate sample.")
26 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
27 call disp%skip()
28
29 block
30 real(TKG) :: mean(0:nsam), meanMerged
31 real(TKG), allocatable :: sample(:)
32 real(TKG) :: var(0:nsam), varMerged
33 do itry = 1, ntry
34 call disp%skip()
35 call disp%show("lb(1) = 1; ub(1) = getUnifRand(2, 7)")
36 lb(1) = 1; ub(1) = getUnifRand(2, 7)
37 call disp%show("do isam = 2, nsam")
38 call disp%show(" lb(isam) = ub(isam - 1) + 1")
39 call disp%show(" ub(isam) = ub(isam - 1) + getUnifRand(2, 7)")
40 call disp%show("end do")
41 do isam = 2, nsam
42 lb(isam) = ub(isam - 1) + 1
43 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
44 end do
45 call disp%show("lb")
46 call disp%show( lb )
47 call disp%show("ub")
48 call disp%show( ub )
49 call disp%show("sample = getUnifRand(0., 1., ub(nsam))")
50 sample = getUnifRand(0., 1., ub(nsam))
51 call disp%show("sample")
52 call disp%show( sample )
53 call disp%show("mean(0) = getMean(sample)")
54 mean(0) = getMean(sample)
55 call disp%show("mean(0) ! reference")
56 call disp%show( mean(0) )
57 call disp%show("var(0) = getVar(sample)")
58 var(0) = getVar(sample)
59 call disp%show("var(0) ! reference")
60 call disp%show( var(0) )
61 call disp%show("do isam = 1, nsam")
62 call disp%show(" var(isam) = getVar(sample(lb(isam):ub(isam)))")
63 call disp%show(" mean(isam) = getMean(sample(lb(isam):ub(isam)))")
64 call disp%show("end do")
65 do isam = 1, nsam
66 var(isam) = getVar(sample(lb(isam):ub(isam)))
67 mean(isam) = getMean(sample(lb(isam):ub(isam)))
68 end do
69 call disp%show("call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))")
70 call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
71 call disp%show("meanMerged")
72 call disp%show( meanMerged )
73 call disp%show("varMerged")
74 call disp%show( varMerged )
75 call disp%show("call setVarMeanMerged(var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))")
76 call setVarMeanMerged(var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
77 call disp%show("mean(2)")
78 call disp%show( mean(2) )
79 call disp%show("mean(0) ! reference")
80 call disp%show( mean(0) )
81 call disp%show("var(2)")
82 call disp%show( var(2) )
83 call disp%show("var(0) ! reference")
84 call disp%show( var(0) )
85 call disp%skip()
86 end do
87 end block
88
89 block
90 complex(TKG) :: mean(0:nsam), meanMerged
91 complex(TKG), allocatable :: sample(:)
92 real(TKG) :: var(0:nsam), varMerged
93 do itry = 1, ntry
94 call disp%skip()
95 call disp%show("lb(1) = 1; ub(1) = getUnifRand(2, 7)")
96 lb(1) = 1; ub(1) = getUnifRand(2, 7)
97 call disp%show("do isam = 2, nsam")
98 call disp%show(" lb(isam) = ub(isam - 1) + 1")
99 call disp%show(" ub(isam) = ub(isam - 1) + getUnifRand(2, 7)")
100 call disp%show("end do")
101 do isam = 2, nsam
102 lb(isam) = ub(isam - 1) + 1
103 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
104 end do
105 call disp%show("lb")
106 call disp%show( lb )
107 call disp%show("ub")
108 call disp%show( ub )
109 call disp%show("sample = cmplx(getUnifRand(-1., +1., ub(nsam)), getUnifRand(-1., +1., ub(nsam)), TKG)")
110 sample = cmplx(getUnifRand(-1., +1., ub(nsam)), getUnifRand(-1., +1., ub(nsam)), TKG)
111 call disp%show("sample")
112 call disp%show( sample )
113 call disp%show("mean(0) = getMean(sample)")
114 mean(0) = getMean(sample)
115 call disp%show("mean(0) ! reference")
116 call disp%show( mean(0) )
117 call disp%show("var(0) = getVar(sample)")
118 var(0) = getVar(sample)
119 call disp%show("var(0) ! reference")
120 call disp%show( var(0) )
121 call disp%show("do isam = 1, nsam")
122 call disp%show(" var(isam) = getVar(sample(lb(isam):ub(isam)))")
123 call disp%show(" mean(isam) = getMean(sample(lb(isam):ub(isam)))")
124 call disp%show("end do")
125 do isam = 1, nsam
126 var(isam) = getVar(sample(lb(isam):ub(isam)))
127 mean(isam) = getMean(sample(lb(isam):ub(isam)))
128 end do
129 call disp%show("call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))")
130 call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
131 call disp%show("meanMerged")
132 call disp%show( meanMerged )
133 call disp%show("varMerged")
134 call disp%show( varMerged )
135 call disp%show("call setVarMeanMerged(var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))")
136 call setVarMeanMerged(var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
137 call disp%show("mean(2)")
138 call disp%show( mean(2) )
139 call disp%show("mean(0) ! reference")
140 call disp%show( mean(0) )
141 call disp%show("var(2)")
142 call disp%show( var(2) )
143 call disp%show("var(0) ! reference")
144 call disp%show( var(0) )
145 call disp%skip()
146 end do
147 end block
148
149 call disp%skip()
150 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
151 call disp%show("!Compute the biased merged variance and mean of a frequency weighted univariate sample.")
152 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
153 call disp%skip()
154
155 block
156 real(TKG) :: mean(0:nsam), meanMerged
157 real(TKG), allocatable :: sample(:)
158 real(TKG) :: var(0:nsam), varMerged
159 do itry = 1, ntry
160 call disp%skip()
161 call disp%show("lb(1) = 1; ub(1) = getUnifRand(2, 7)")
162 lb(1) = 1; ub(1) = getUnifRand(2, 7)
163 call disp%show("do isam = 2, nsam")
164 call disp%show(" lb(isam) = ub(isam - 1) + 1")
165 call disp%show(" ub(isam) = ub(isam - 1) + getUnifRand(2, 7)")
166 call disp%show("end do")
167 do isam = 2, nsam
168 lb(isam) = ub(isam - 1) + 1
169 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
170 end do
171 call disp%show("lb")
172 call disp%show( lb )
173 call disp%show("ub")
174 call disp%show( ub )
175 call disp%show("sample = getUnifRand(0., 1., ub(nsam))")
176 sample = getUnifRand(0., 1., ub(nsam))
177 call disp%show("sample")
178 call disp%show( sample )
179 call disp%show("iweight = getUnifRand(1, 10, size(sample, 1, IK))")
180 iweight = getUnifRand(1, 10, size(sample, 1, IK))
181 call disp%show("iweight")
182 call disp%show( iweight )
183 call disp%show("mean(0) = getMean(sample, iweight)")
184 mean(0) = getMean(sample, iweight)
185 call disp%show("mean(0) ! reference")
186 call disp%show( mean(0) )
187 call disp%show("var(0) = getVar(sample, iweight)")
188 var(0) = getVar(sample, iweight)
189 call disp%show("var(0) ! reference")
190 call disp%show( var(0) )
191 call disp%show("do isam = 1, nsam")
192 call disp%show(" var(isam) = getVar(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))")
193 call disp%show(" mean(isam) = getMean(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))")
194 call disp%show("end do")
195 do isam = 1, nsam
196 var(isam) = getVar(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
197 mean(isam) = getMean(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
198 end do
199 call disp%show("call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))")
200 call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
201 call disp%show("meanMerged")
202 call disp%show( meanMerged )
203 call disp%show("varMerged")
204 call disp%show( varMerged )
205 call disp%show("call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))")
206 call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
207 call disp%show("mean(2)")
208 call disp%show( mean(2) )
209 call disp%show("mean(0) ! reference")
210 call disp%show( mean(0) )
211 call disp%show("var(2)")
212 call disp%show( var(2) )
213 call disp%show("var(0) ! reference")
214 call disp%show( var(0) )
215 call disp%skip()
216 end do
217 end block
218
219 block
220 complex(TKG) :: mean(0:nsam), meanMerged
221 complex(TKG), allocatable :: sample(:)
222 real(TKG) :: var(0:nsam), varMerged
223 do itry = 1, ntry
224 call disp%skip()
225 call disp%show("lb(1) = 1; ub(1) = getUnifRand(2, 7)")
226 lb(1) = 1; ub(1) = getUnifRand(2, 7)
227 call disp%show("do isam = 2, nsam")
228 call disp%show(" lb(isam) = ub(isam - 1) + 1")
229 call disp%show(" ub(isam) = ub(isam - 1) + getUnifRand(2, 7)")
230 call disp%show("end do")
231 do isam = 2, nsam
232 lb(isam) = ub(isam - 1) + 1
233 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
234 end do
235 call disp%show("lb")
236 call disp%show( lb )
237 call disp%show("ub")
238 call disp%show( ub )
239 call disp%show("sample = cmplx(getUnifRand(0., 1., ub(nsam)), -getUnifRand(0., 1., ub(nsam)), TKG)")
240 sample = cmplx(getUnifRand(0., 1., ub(nsam)), -getUnifRand(0., 1., ub(nsam)), TKG)
241 call disp%show("sample")
242 call disp%show( sample )
243 call disp%show("iweight = getUnifRand(1, 10, size(sample, 1, IK))")
244 iweight = getUnifRand(1, 10, size(sample, 1, IK))
245 call disp%show("iweight")
246 call disp%show( iweight )
247 call disp%show("mean(0) = getMean(sample, iweight)")
248 mean(0) = getMean(sample, iweight)
249 call disp%show("mean(0) ! reference")
250 call disp%show( mean(0) )
251 call disp%show("var(0) = getVar(sample, iweight)")
252 var(0) = getVar(sample, iweight)
253 call disp%show("var(0) ! reference")
254 call disp%show( var(0) )
255 call disp%show("do isam = 1, nsam")
256 call disp%show(" var(isam) = getVar(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))")
257 call disp%show(" mean(isam) = getMean(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))")
258 call disp%show("end do")
259 do isam = 1, nsam
260 var(isam) = getVar(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
261 mean(isam) = getMean(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
262 end do
263 call disp%show("call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))")
264 call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
265 call disp%show("meanMerged")
266 call disp%show( meanMerged )
267 call disp%show("varMerged")
268 call disp%show( varMerged )
269 call disp%show("call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))")
270 call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
271 call disp%show("mean(2)")
272 call disp%show( mean(2) )
273 call disp%show("mean(0) ! reference")
274 call disp%show( mean(0) )
275 call disp%show("var(2)")
276 call disp%show( var(2) )
277 call disp%show("var(0) ! reference")
278 call disp%show( var(0) )
279 call disp%skip()
280 end do
281 end block
282
283 call disp%skip()
284 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
285 call disp%show("!Compute the biased merged variance and mean of a reliability weighted univariate sample.")
286 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
287 call disp%skip()
288
289 block
290 real(TKG) :: mean(0:nsam), meanMerged
291 real(TKG), allocatable :: sample(:)
292 real(TKG), allocatable :: rweight(:)
293 real(TKG) :: var(0:nsam), varMerged
294 do itry = 1, ntry
295 call disp%skip()
296 call disp%show("lb(1) = 1; ub(1) = getUnifRand(2, 7)")
297 lb(1) = 1; ub(1) = getUnifRand(2, 7)
298 call disp%show("do isam = 2, nsam")
299 call disp%show(" lb(isam) = ub(isam - 1) + 1")
300 call disp%show(" ub(isam) = ub(isam - 1) + getUnifRand(2, 7)")
301 call disp%show("end do")
302 do isam = 2, nsam
303 lb(isam) = ub(isam - 1) + 1
304 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
305 end do
306 call disp%show("lb")
307 call disp%show( lb )
308 call disp%show("ub")
309 call disp%show( ub )
310 call disp%show("sample = getUnifRand(0., 1., ub(nsam))")
311 sample = getUnifRand(0., 1., ub(nsam))
312 call disp%show("sample")
313 call disp%show( sample )
314 call disp%show("rweight = getUnifRand(1., 2., size(sample, 1, IK))")
315 rweight = getUnifRand(1., 2., size(sample, 1, IK))
316 call disp%show("rweight")
317 call disp%show( rweight )
318 call disp%show("mean(0) = getMean(sample, rweight)")
319 mean(0) = getMean(sample, rweight)
320 call disp%show("mean(0) ! reference")
321 call disp%show( mean(0) )
322 call disp%show("var(0) = getVar(sample, rweight)")
323 var(0) = getVar(sample, rweight)
324 call disp%show("var(0) ! reference")
325 call disp%show( var(0) )
326 call disp%show("do isam = 1, nsam")
327 call disp%show(" var(isam) = getVar(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))")
328 call disp%show(" mean(isam) = getMean(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))")
329 call disp%show("end do")
330 do isam = 1, nsam
331 var(isam) = getVar(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
332 mean(isam) = getMean(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
333 end do
334 call disp%show("call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))")
335 call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
336 call disp%show("meanMerged")
337 call disp%show( meanMerged )
338 call disp%show("varMerged")
339 call disp%show( varMerged )
340 call disp%show("call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))")
341 call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
342 call disp%show("mean(2)")
343 call disp%show( mean(2) )
344 call disp%show("mean(0) ! reference")
345 call disp%show( mean(0) )
346 call disp%show("var(2)")
347 call disp%show( var(2) )
348 call disp%show("var(0) ! reference")
349 call disp%show( var(0) )
350 call disp%skip()
351 end do
352 end block
353
354 block
355 complex(TKG) :: mean(0:nsam), meanMerged
356 complex(TKG), allocatable :: sample(:)
357 real(TKG), allocatable :: rweight(:)
358 real(TKG) :: var(0:nsam), varMerged
359 do itry = 1, ntry
360 call disp%skip()
361 call disp%show("lb(1) = 1; ub(1) = getUnifRand(2, 7)")
362 lb(1) = 1; ub(1) = getUnifRand(2, 7)
363 call disp%show("do isam = 2, nsam")
364 call disp%show(" lb(isam) = ub(isam - 1) + 1")
365 call disp%show(" ub(isam) = ub(isam - 1) + getUnifRand(2, 7)")
366 call disp%show("end do")
367 do isam = 2, nsam
368 lb(isam) = ub(isam - 1) + 1
369 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
370 end do
371 call disp%show("lb")
372 call disp%show( lb )
373 call disp%show("ub")
374 call disp%show( ub )
375 call disp%show("sample = cmplx(getUnifRand(0., 1., ub(nsam)), -getUnifRand(0., 1., ub(nsam)), TKG)")
376 sample = cmplx(getUnifRand(0., 1., ub(nsam)), -getUnifRand(0., 1., ub(nsam)), TKG)
377 call disp%show("sample")
378 call disp%show( sample )
379 call disp%show("rweight = getUnifRand(1., 2., size(sample, 1, IK))")
380 rweight = getUnifRand(1., 2., size(sample, 1, IK))
381 call disp%show("rweight")
382 call disp%show( rweight )
383 call disp%show("mean(0) = getMean(sample, rweight)")
384 mean(0) = getMean(sample, rweight)
385 call disp%show("mean(0) ! reference")
386 call disp%show( mean(0) )
387 call disp%show("var(0) = getVar(sample, rweight)")
388 var(0) = getVar(sample, rweight)
389 call disp%show("var(0) ! reference")
390 call disp%show( var(0) )
391 call disp%show("do isam = 1, nsam")
392 call disp%show(" var(isam) = getVar(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))")
393 call disp%show(" mean(isam) = getMean(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))")
394 call disp%show("end do")
395 do isam = 1, nsam
396 var(isam) = getVar(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
397 mean(isam) = getMean(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
398 end do
399 call disp%show("call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))")
400 call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
401 call disp%show("meanMerged")
402 call disp%show( meanMerged )
403 call disp%show("varMerged")
404 call disp%show( varMerged )
405 call disp%show("call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))")
406 call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
407 call disp%show("mean(2)")
408 call disp%show( mean(2) )
409 call disp%show("mean(0) ! reference")
410 call disp%show( mean(0) )
411 call disp%show("var(2)")
412 call disp%show( var(2) )
413 call disp%show("var(0) ! reference")
414 call disp%show( var(0) )
415 call disp%skip()
416 end do
417 end block
418
419 call disp%skip()
420 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
421 call disp%show("!Compute the biased merged variance and mean of a multivariate sample.")
422 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
423 call disp%skip()
424
425 block
426 real(TKG), allocatable :: sample(:,:)
427 real(TKG), allocatable :: mean(:,:), meanMerged(:)
428 real(TKG), allocatable :: var(:,:), varMerged(:)
429 do itry = 1, ntry
430 call disp%skip()
431 call disp%show("dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)")
432 dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
433 call disp%show("do isam = 2, nsam")
434 call disp%show(" lb(isam) = ub(isam - 1) + 1")
435 call disp%show(" ub(isam) = ub(isam - 1) + getUnifRand(2, 7)")
436 call disp%show("end do")
437 do isam = 2, nsam
438 lb(isam) = ub(isam - 1) + 1
439 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
440 end do
441 call disp%show("lb")
442 call disp%show( lb )
443 call disp%show("ub")
444 call disp%show( ub )
445 call disp%show("ndim = getUnifRand(1, minval(ub - lb + 1, 1))")
446 ndim = getUnifRand(1, minval(ub - lb + 1, 1))
447 call disp%show("call setRebound(var, [1_IK, 0_IK], [ndim, nsam])")
448 call setRebound(var, [1_IK, 0_IK], [ndim, nsam])
449 call disp%show("call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])")
450 call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
451 call disp%show("call setResized(meanMerged, ndim)")
452 call setResized(meanMerged, ndim)
453 call disp%show("call setResized(varMerged, ndim)")
454 call setResized(varMerged, ndim)
455 call disp%show("sample = getUnifRand(-1., +1., ndim, ub(nsam))")
456 sample = getUnifRand(-1., +1., ndim, ub(nsam))
457 call disp%show("sample")
458 call disp%show( sample )
459 call disp%show("mean(:,0) = getVar(sample, dim)")
460 mean(:,0) = getVar(sample, dim)
461 call disp%show("mean(:,0) ! reference")
462 call disp%show( mean(:,0) )
463 call disp%show("var(:,0) = getVar(sample, dim)")
464 var(:,0) = getVar(sample, dim)
465 call disp%show("var(:,0) ! reference")
466 call disp%show( var(:,0) )
467 call disp%show("do isam = 1, nsam")
468 call disp%show(" var(:,isam) = getVar(sample(:,lb(isam):ub(isam)), dim)")
469 call disp%show(" mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)")
470 call disp%show("end do")
471 do isam = 1, nsam
472 var(:,isam) = getVar(sample(:,lb(isam):ub(isam)), dim)
473 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
474 end do
475 call disp%show("call setVarMeanMerged(varMerged, meanMerged, var(:,2), mean(:,2), var(:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG))")
476 call setVarMeanMerged(varMerged, meanMerged, var(:,2), mean(:,2), var(:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG))
477 call disp%show("meanMerged")
478 call disp%show( meanMerged )
479 call disp%show("varMerged")
480 call disp%show( varMerged )
481 call disp%show("call setVarMeanMerged(var(:,2), mean(:,2), var(:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG))")
482 call setVarMeanMerged(var(:,2), mean(:,2), var(:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG))
483 call disp%show("mean(:,2)")
484 call disp%show( mean(:,2) )
485 call disp%show("mean(:,0) ! reference")
486 call disp%show( mean(:,0) )
487 call disp%show("var(:,2)")
488 call disp%show( var(:,2) )
489 call disp%show("var(:,0) ! reference")
490 call disp%show( var(:,0) )
491 call disp%skip()
492 end do
493 end block
494
495 block
496 complex(TKG), allocatable :: sample(:,:)
497 complex(TKG), allocatable :: mean(:,:), meanMerged(:)
498 real(TKG), allocatable :: var(:,:), varMerged(:)
499 do itry = 1, ntry
500 call disp%skip()
501 call disp%show("dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)")
502 dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
503 call disp%show("do isam = 2, nsam")
504 call disp%show(" lb(isam) = ub(isam - 1) + 1")
505 call disp%show(" ub(isam) = ub(isam - 1) + getUnifRand(2, 7)")
506 call disp%show("end do")
507 do isam = 2, nsam
508 lb(isam) = ub(isam - 1) + 1
509 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
510 end do
511 call disp%show("lb")
512 call disp%show( lb )
513 call disp%show("ub")
514 call disp%show( ub )
515 call disp%show("ndim = getUnifRand(1, minval(ub - lb + 1, 1))")
516 ndim = getUnifRand(1, minval(ub - lb + 1, 1))
517 call disp%show("call setRebound(var, [1_IK, 0_IK], [ndim, nsam])")
518 call setRebound(var, [1_IK, 0_IK], [ndim, nsam])
519 call disp%show("call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])")
520 call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
521 call disp%show("call setResized(meanMerged, ndim)")
522 call setResized(meanMerged, ndim)
523 call disp%show("call setResized(varMerged, ndim)")
524 call setResized(varMerged, ndim)
525 call disp%show("sample = cmplx(getUnifRand(-1., +1., ndim, ub(nsam)), -getUnifRand(-1., +1., ndim, ub(nsam)), TKG)")
526 sample = cmplx(getUnifRand(-1., +1., ndim, ub(nsam)), -getUnifRand(-1., +1., ndim, ub(nsam)), TKG)
527 call disp%show("sample")
528 call disp%show( sample )
529 call disp%show("mean(:,0) = getVar(sample, dim)")
530 mean(:,0) = getVar(sample, dim)
531 call disp%show("mean(:,0) ! reference")
532 call disp%show( mean(:,0) )
533 call disp%show("var(:,0) = getVar(sample, dim)")
534 var(:,0) = getVar(sample, dim)
535 call disp%show("var(:,0) ! reference")
536 call disp%show( var(:,0) )
537 call disp%show("do isam = 1, nsam")
538 call disp%show(" var(:,isam) = getVar(sample(:,lb(isam):ub(isam)), dim)")
539 call disp%show(" mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)")
540 call disp%show("end do")
541 do isam = 1, nsam
542 var(:,isam) = getVar(sample(:,lb(isam):ub(isam)), dim)
543 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
544 end do
545 call disp%show("call setVarMeanMerged(varMerged, meanMerged, var(:,2), mean(:,2), var(:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG))")
546 call setVarMeanMerged(varMerged, meanMerged, var(:,2), mean(:,2), var(:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG))
547 call disp%show("meanMerged")
548 call disp%show( meanMerged )
549 call disp%show("varMerged")
550 call disp%show( varMerged )
551 call disp%show("call setVarMeanMerged(var(:,2), mean(:,2), var(:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG))")
552 call setVarMeanMerged(var(:,2), mean(:,2), var(:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG))
553 call disp%show("mean(:,2)")
554 call disp%show( mean(:,2) )
555 call disp%show("mean(:,0) ! reference")
556 call disp%show( mean(:,0) )
557 call disp%show("var(:,2)")
558 call disp%show( var(:,2) )
559 call disp%show("var(:,0) ! reference")
560 call disp%show( var(:,0) )
561 call disp%skip()
562 end do
563 end block
564
565 call disp%skip()
566 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
567 call disp%show("!Compute the biased merged variance and mean of a frequency weighted multivariate sample.")
568 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
569 call disp%skip()
570
571 block
572 real(TKG), allocatable :: sample(:,:)
573 real(TKG), allocatable :: mean(:,:), meanMerged(:)
574 real(TKG), allocatable :: var(:,:), varMerged(:)
575 do itry = 1, ntry
576 call disp%skip()
577 call disp%show("dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)")
578 dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
579 call disp%show("do isam = 2, nsam")
580 call disp%show(" lb(isam) = ub(isam - 1) + 1")
581 call disp%show(" ub(isam) = ub(isam - 1) + getUnifRand(2, 7)")
582 call disp%show("end do")
583 do isam = 2, nsam
584 lb(isam) = ub(isam - 1) + 1
585 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
586 end do
587 call disp%show("lb")
588 call disp%show( lb )
589 call disp%show("ub")
590 call disp%show( ub )
591 call disp%show("ndim = getUnifRand(1, minval(ub - lb + 1, 1))")
592 ndim = getUnifRand(1, minval(ub - lb + 1, 1))
593 call disp%show("call setRebound(var, [1_IK, 0_IK], [ndim, nsam])")
594 call setRebound(var, [1_IK, 0_IK], [ndim, nsam])
595 call disp%show("call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])")
596 call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
597 call disp%show("call setResized(meanMerged, ndim)")
598 call setResized(meanMerged, ndim)
599 call disp%show("call setResized(varMerged, ndim)")
600 call setResized(varMerged, ndim)
601 call disp%show("sample = getUnifRand(-1., +1., ndim, ub(nsam))")
602 sample = getUnifRand(-1., +1., ndim, ub(nsam))
603 call disp%show("sample")
604 call disp%show( sample )
605 call disp%show("iweight = getUnifRand(1, 10, size(sample, dim, IK))")
606 iweight = getUnifRand(1, 10, size(sample, dim, IK))
607 call disp%show("iweight")
608 call disp%show( iweight )
609 call disp%show("mean(:,0) = getVar(sample, 2_IK, iweight)")
610 mean(:,0) = getVar(sample, 2_IK, iweight)
611 call disp%show("mean(:,0) ! reference")
612 call disp%show( mean(:,0) )
613 call disp%show("var(:,0) = getVar(sample, 2_IK, iweight)")
614 var(:,0) = getVar(sample, 2_IK, iweight)
615 call disp%show("var(:,0) ! reference")
616 call disp%show( var(:,0) )
617 call disp%show("do isam = 1, nsam")
618 call disp%show(" var(:,isam) = getVar(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))")
619 call disp%show(" mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))")
620 call disp%show("end do")
621 do isam = 1, nsam
622 var(:,isam) = getVar(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
623 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
624 end do
625 call disp%show("call setVarMeanMerged(varMerged, meanMerged, var(:,2), mean(:,2), var(:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))")
626 call setVarMeanMerged(varMerged, meanMerged, var(:,2), mean(:,2), var(:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
627 call disp%show("meanMerged")
628 call disp%show( meanMerged )
629 call disp%show("varMerged")
630 call disp%show( varMerged )
631 call disp%show("call setVarMeanMerged(var(:,2), mean(:,2), var(:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))")
632 call setVarMeanMerged(var(:,2), mean(:,2), var(:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
633 call disp%show("mean(:,2)")
634 call disp%show( mean(:,2) )
635 call disp%show("mean(:,0) ! reference")
636 call disp%show( mean(:,0) )
637 call disp%show("var(:,2)")
638 call disp%show( var(:,2) )
639 call disp%show("var(:,0) ! reference")
640 call disp%show( var(:,0) )
641 call disp%skip()
642 end do
643 end block
644
645 block
646 complex(TKG), allocatable :: sample(:,:)
647 complex(TKG), allocatable :: mean(:,:), meanMerged(:)
648 real(TKG), allocatable :: var(:,:), varMerged(:)
649 do itry = 1, ntry
650 call disp%skip()
651 call disp%show("dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)")
652 dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
653 call disp%show("do isam = 2, nsam")
654 call disp%show(" lb(isam) = ub(isam - 1) + 1")
655 call disp%show(" ub(isam) = ub(isam - 1) + getUnifRand(2, 7)")
656 call disp%show("end do")
657 do isam = 2, nsam
658 lb(isam) = ub(isam - 1) + 1
659 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
660 end do
661 call disp%show("lb")
662 call disp%show( lb )
663 call disp%show("ub")
664 call disp%show( ub )
665 call disp%show("ndim = getUnifRand(1, minval(ub - lb + 1, 1))")
666 ndim = getUnifRand(1, minval(ub - lb + 1, 1))
667 call disp%show("call setRebound(var, [1_IK, 0_IK], [ndim, nsam])")
668 call setRebound(var, [1_IK, 0_IK], [ndim, nsam])
669 call disp%show("call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])")
670 call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
671 call disp%show("call setResized(meanMerged, ndim)")
672 call setResized(meanMerged, ndim)
673 call disp%show("call setResized(varMerged, ndim)")
674 call setResized(varMerged, ndim)
675 call disp%show("sample = cmplx(getUnifRand(-1., +1., ndim, ub(nsam)), getUnifRand(-1., +1., ndim, ub(nsam)), TKG)")
676 sample = cmplx(getUnifRand(-1., +1., ndim, ub(nsam)), getUnifRand(-1., +1., ndim, ub(nsam)), TKG)
677 call disp%show("sample")
678 call disp%show( sample )
679 call disp%show("iweight = getUnifRand(1, 10, size(sample, dim, IK))")
680 iweight = getUnifRand(1, 10, size(sample, dim, IK))
681 call disp%show("iweight")
682 call disp%show( iweight )
683 call disp%show("mean(:,0) = getVar(sample, 2_IK, iweight)")
684 mean(:,0) = getVar(sample, 2_IK, iweight)
685 call disp%show("mean(:,0) ! reference")
686 call disp%show( mean(:,0) )
687 call disp%show("var(:,0) = getVar(sample, 2_IK, iweight)")
688 var(:,0) = getVar(sample, 2_IK, iweight)
689 call disp%show("var(:,0) ! reference")
690 call disp%show( var(:,0) )
691 call disp%show("do isam = 1, nsam")
692 call disp%show(" var(:,isam) = getVar(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))")
693 call disp%show(" mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))")
694 call disp%show("end do")
695 do isam = 1, nsam
696 var(:,isam) = getVar(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
697 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
698 end do
699 call disp%show("call setVarMeanMerged(varMerged, meanMerged, var(:,2), mean(:,2), var(:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))")
700 call setVarMeanMerged(varMerged, meanMerged, var(:,2), mean(:,2), var(:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
701 call disp%show("meanMerged")
702 call disp%show( meanMerged )
703 call disp%show("varMerged")
704 call disp%show( varMerged )
705 call disp%show("call setVarMeanMerged(var(:,2), mean(:,2), var(:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))")
706 call setVarMeanMerged(var(:,2), mean(:,2), var(:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
707 call disp%show("mean(:,2)")
708 call disp%show( mean(:,2) )
709 call disp%show("mean(:,0) ! reference")
710 call disp%show( mean(:,0) )
711 call disp%show("var(:,2)")
712 call disp%show( var(:,2) )
713 call disp%show("var(:,0) ! reference")
714 call disp%show( var(:,0) )
715 call disp%skip()
716 end do
717 end block
718
719 call disp%skip()
720 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
721 call disp%show("!Compute the biased merged variance and mean of a reliability weighted multivariate sample.")
722 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
723 call disp%skip()
724
725 block
726 real(TKG), allocatable :: sample(:,:)
727 real(TKG), allocatable :: mean(:,:), meanMerged(:)
728 real(TKG), allocatable :: var(:,:), varMerged(:)
729 real(TKG), allocatable :: rweight(:)
730 do itry = 1, ntry
731 call disp%skip()
732 call disp%show("dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)")
733 dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
734 call disp%show("do isam = 2, nsam")
735 call disp%show(" lb(isam) = ub(isam - 1) + 1")
736 call disp%show(" ub(isam) = ub(isam - 1) + getUnifRand(2, 7)")
737 call disp%show("end do")
738 do isam = 2, nsam
739 lb(isam) = ub(isam - 1) + 1
740 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
741 end do
742 call disp%show("lb")
743 call disp%show( lb )
744 call disp%show("ub")
745 call disp%show( ub )
746 call disp%show("ndim = getUnifRand(1, minval(ub - lb + 1, 1))")
747 ndim = getUnifRand(1, minval(ub - lb + 1, 1))
748 call disp%show("call setRebound(var, [1_IK, 0_IK], [ndim, nsam])")
749 call setRebound(var, [1_IK, 0_IK], [ndim, nsam])
750 call disp%show("call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])")
751 call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
752 call disp%show("call setResized(meanMerged, ndim)")
753 call setResized(meanMerged, ndim)
754 call disp%show("call setResized(varMerged, ndim)")
755 call setResized(varMerged, ndim)
756 call disp%show("sample = getUnifRand(-1., +1., ndim, ub(nsam))")
757 sample = getUnifRand(-1., +1., ndim, ub(nsam))
758 call disp%show("sample")
759 call disp%show( sample )
760 call disp%show("rweight = getUnifRand(1., 2., size(sample, dim, IK))")
761 rweight = getUnifRand(1., 2., size(sample, dim, IK))
762 call disp%show("rweight")
763 call disp%show( rweight )
764 call disp%show("mean(:,0) = getVar(sample, 2_IK, rweight)")
765 mean(:,0) = getVar(sample, 2_IK, rweight)
766 call disp%show("mean(:,0) ! reference")
767 call disp%show( mean(:,0) )
768 call disp%show("var(:,0) = getVar(sample, 2_IK, rweight)")
769 var(:,0) = getVar(sample, 2_IK, rweight)
770 call disp%show("var(:,0) ! reference")
771 call disp%show( var(:,0) )
772 call disp%show("do isam = 1, nsam")
773 call disp%show(" var(:,isam) = getVar(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))")
774 call disp%show(" mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))")
775 call disp%show("end do")
776 do isam = 1, nsam
777 var(:,isam) = getVar(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
778 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
779 end do
780 call disp%show("call setVarMeanMerged(varMerged, meanMerged, var(:,2), mean(:,2), var(:,1), mean(:,1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))")
781 call setVarMeanMerged(varMerged, meanMerged, var(:,2), mean(:,2), var(:,1), mean(:,1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
782 call disp%show("meanMerged")
783 call disp%show( meanMerged )
784 call disp%show("varMerged")
785 call disp%show( varMerged )
786 call disp%show("call setVarMeanMerged(var(:,2), mean(:,2), var(:,1), mean(:,1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))")
787 call setVarMeanMerged(var(:,2), mean(:,2), var(:,1), mean(:,1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
788 call disp%show("mean(:,2)")
789 call disp%show( mean(:,2) )
790 call disp%show("mean(:,0) ! reference")
791 call disp%show( mean(:,0) )
792 call disp%show("var(:,2)")
793 call disp%show( var(:,2) )
794 call disp%show("var(:,0) ! reference")
795 call disp%show( var(:,0) )
796 call disp%skip()
797 end do
798 end block
799
800 block
801 complex(TKG), allocatable :: sample(:,:)
802 complex(TKG), allocatable :: mean(:,:), meanMerged(:)
803 real(TKG), allocatable :: var(:,:), varMerged(:)
804 real(TKG), allocatable :: rweight(:)
805 do itry = 1, ntry
806 call disp%skip()
807 call disp%show("dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)")
808 dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
809 call disp%show("do isam = 2, nsam")
810 call disp%show(" lb(isam) = ub(isam - 1) + 1")
811 call disp%show(" ub(isam) = ub(isam - 1) + getUnifRand(2, 7)")
812 call disp%show("end do")
813 do isam = 2, nsam
814 lb(isam) = ub(isam - 1) + 1
815 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
816 end do
817 call disp%show("lb")
818 call disp%show( lb )
819 call disp%show("ub")
820 call disp%show( ub )
821 call disp%show("ndim = getUnifRand(1, minval(ub - lb + 1, 1))")
822 ndim = getUnifRand(1, minval(ub - lb + 1, 1))
823 call disp%show("call setRebound(var, [1_IK, 0_IK], [ndim, nsam])")
824 call setRebound(var, [1_IK, 0_IK], [ndim, nsam])
825 call disp%show("call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])")
826 call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
827 call disp%show("call setResized(meanMerged, ndim)")
828 call setResized(meanMerged, ndim)
829 call disp%show("call setResized(varMerged, ndim)")
830 call setResized(varMerged, ndim)
831 call disp%show("sample = cmplx(getUnifRand(-1., +1., ndim, ub(nsam)), getUnifRand(-1., +1., ndim, ub(nsam)), TKG)")
832 sample = cmplx(getUnifRand(-1., +1., ndim, ub(nsam)), getUnifRand(-1., +1., ndim, ub(nsam)), TKG)
833 call disp%show("sample")
834 call disp%show( sample )
835 call disp%show("rweight = getUnifRand(1., 2., size(sample, dim, IK))")
836 rweight = getUnifRand(1., 2., size(sample, dim, IK))
837 call disp%show("rweight")
838 call disp%show( rweight )
839 call disp%show("mean(:,0) = getVar(sample, 2_IK, rweight)")
840 mean(:,0) = getVar(sample, 2_IK, rweight)
841 call disp%show("mean(:,0) ! reference")
842 call disp%show( mean(:,0) )
843 call disp%show("var(:,0) = getVar(sample, 2_IK, rweight)")
844 var(:,0) = getVar(sample, 2_IK, rweight)
845 call disp%show("var(:,0) ! reference")
846 call disp%show( var(:,0) )
847 call disp%show("do isam = 1, nsam")
848 call disp%show(" var(:,isam) = getVar(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))")
849 call disp%show(" mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))")
850 call disp%show("end do")
851 do isam = 1, nsam
852 var(:,isam) = getVar(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
853 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
854 end do
855 call disp%show("call setVarMeanMerged(varMerged, meanMerged, var(:,2), mean(:,2), var(:,1), mean(:,1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))")
856 call setVarMeanMerged(varMerged, meanMerged, var(:,2), mean(:,2), var(:,1), mean(:,1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
857 call disp%show("meanMerged")
858 call disp%show( meanMerged )
859 call disp%show("varMerged")
860 call disp%show( varMerged )
861 call disp%show("call setVarMeanMerged(var(:,2), mean(:,2), var(:,1), mean(:,1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))")
862 call setVarMeanMerged(var(:,2), mean(:,2), var(:,1), mean(:,1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
863 call disp%show("mean(:,2)")
864 call disp%show( mean(:,2) )
865 call disp%show("mean(:,0) ! reference")
866 call disp%show( mean(:,0) )
867 call disp%show("var(:,2)")
868 call disp%show( var(:,2) )
869 call disp%show("var(:,0) ! reference")
870 call disp%show( var(:,0) )
871 call disp%skip()
872 end do
873 end block
874
875end program example
Generate minimally-spaced character, integer, real sequences or sequences at fixed intervals of size ...
Resize (shrink or expand) an input allocatable array of rank 1..3 to arbitrary new lower and upper bo...
Allocate or resize (shrink or expand) an input allocatable scalar string or array of rank 1....
Generate and return a scalar or a contiguous array of rank 1 of length s1 of randomly uniformly distr...
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11726
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
Generate and return the (weighted) mean of an input sample of nsam observations with ndim = 1 or 2 at...
Generate and return the variance of the input sample of type complex or real of shape (nsam) or (ndim...
This module contains procedures and generic interfaces for generating ranges of discrete character,...
This module contains procedures and generic interfaces for resizing allocatable arrays of various typ...
This module contains procedures and generic interfaces for resizing allocatable arrays of various typ...
This module contains classes and procedures for computing various statistical quantities related to t...
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
integer, parameter RKS
The single-precision real kind in Fortran mode. On most platforms, this is an 32-bit real kind.
Definition: pm_kind.F90:567
This module contains classes and procedures for computing the first moment (i.e., the statistical mea...
Generate and return an object of type display_type.
Definition: pm_io.F90:10282

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
2!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3!Compute the biased merged variance and mean of a univariate sample.
4!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5
6
7lb(1) = 1; ub(1) = getUnifRand(2, 7)
8do isam = 2, nsam
9 lb(isam) = ub(isam - 1) + 1
10 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
11end do
12lb
13+1, +4
14ub
15+3, +6
16sample = getUnifRand(0., 1., ub(nsam))
17sample
18+0.300738692, +0.826546073, +0.904453993, +0.388791502, +0.707582772, +0.952494144
19mean(0) = getMean(sample)
20mean(0) ! reference
21+0.680101216
22var(0) = getVar(sample)
23var(0) ! reference
24+0.625851229E-1
25do isam = 1, nsam
26 var(isam) = getVar(sample(lb(isam):ub(isam)))
27 mean(isam) = getMean(sample(lb(isam):ub(isam)))
28end do
29call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
30meanMerged
31+0.680101216
32varMerged
33+0.625851154E-1
34call setVarMeanMerged(var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
35mean(2)
36+0.680101216
37mean(0) ! reference
38+0.680101216
39var(2)
40+0.625851154E-1
41var(0) ! reference
42+0.625851229E-1
43
44
45lb(1) = 1; ub(1) = getUnifRand(2, 7)
46do isam = 2, nsam
47 lb(isam) = ub(isam - 1) + 1
48 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
49end do
50lb
51+1, +3
52ub
53+2, +4
54sample = getUnifRand(0., 1., ub(nsam))
55sample
56+0.451598644, +0.816199720, +0.182628632E-3, +0.347925842
57mean(0) = getMean(sample)
58mean(0) ! reference
59+0.403976738
60var(0) = getVar(sample)
61var(0) ! reference
62+0.845967531E-1
63do isam = 1, nsam
64 var(isam) = getVar(sample(lb(isam):ub(isam)))
65 mean(isam) = getMean(sample(lb(isam):ub(isam)))
66end do
67call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
68meanMerged
69+0.403976738
70varMerged
71+0.845967606E-1
72call setVarMeanMerged(var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
73mean(2)
74+0.403976738
75mean(0) ! reference
76+0.403976738
77var(2)
78+0.845967606E-1
79var(0) ! reference
80+0.845967531E-1
81
82
83lb(1) = 1; ub(1) = getUnifRand(2, 7)
84do isam = 2, nsam
85 lb(isam) = ub(isam - 1) + 1
86 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
87end do
88lb
89+1, +5
90ub
91+4, +7
92sample = getUnifRand(0., 1., ub(nsam))
93sample
94+0.912773132, +0.402607918, +0.374722421, +0.778887272E-1, +0.958424330, +0.178530216, +0.515347719
95mean(0) = getMean(sample)
96mean(0) ! reference
97+0.488613516
98var(0) = getVar(sample)
99var(0) ! reference
100+0.980804190E-1
101do isam = 1, nsam
102 var(isam) = getVar(sample(lb(isam):ub(isam)))
103 mean(isam) = getMean(sample(lb(isam):ub(isam)))
104end do
105call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
106meanMerged
107+0.488613486
108varMerged
109+0.980804190E-1
110call setVarMeanMerged(var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
111mean(2)
112+0.488613486
113mean(0) ! reference
114+0.488613516
115var(2)
116+0.980804190E-1
117var(0) ! reference
118+0.980804190E-1
119
120
121lb(1) = 1; ub(1) = getUnifRand(2, 7)
122do isam = 2, nsam
123 lb(isam) = ub(isam - 1) + 1
124 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
125end do
126lb
127+1, +7
128ub
129+6, +12
130sample = getUnifRand(0., 1., ub(nsam))
131sample
132+0.579243839, +0.365756810, +0.975298882, +0.150066078, +0.794467330E-1, +0.588669062, +0.288138032, +0.895552337, +0.190088153, +0.616138697, +0.854666471, +0.493799806
133mean(0) = getMean(sample)
134mean(0) ! reference
135+0.506405413
136var(0) = getVar(sample)
137var(0) ! reference
138+0.828004852E-1
139do isam = 1, nsam
140 var(isam) = getVar(sample(lb(isam):ub(isam)))
141 mean(isam) = getMean(sample(lb(isam):ub(isam)))
142end do
143call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
144meanMerged
145+0.506405413
146varMerged
147+0.828004852E-1
148call setVarMeanMerged(var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
149mean(2)
150+0.506405413
151mean(0) ! reference
152+0.506405413
153var(2)
154+0.828004852E-1
155var(0) ! reference
156+0.828004852E-1
157
158
159lb(1) = 1; ub(1) = getUnifRand(2, 7)
160do isam = 2, nsam
161 lb(isam) = ub(isam - 1) + 1
162 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
163end do
164lb
165+1, +8
166ub
167+7, +11
168sample = getUnifRand(0., 1., ub(nsam))
169sample
170+0.444651842E-1, +0.178797841E-1, +0.486887693E-1, +0.292090833, +0.113872349, +0.828850269, +0.783131242, +0.673079848, +0.489113569, +0.925929666, +0.946931660
171mean(0) = getMean(sample)
172mean(0) ! reference
173+0.469457597
174var(0) = getVar(sample)
175var(0) ! reference
176+0.129567116
177do isam = 1, nsam
178 var(isam) = getVar(sample(lb(isam):ub(isam)))
179 mean(isam) = getMean(sample(lb(isam):ub(isam)))
180end do
181call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
182meanMerged
183+0.469457567
184varMerged
185+0.129567102
186call setVarMeanMerged(var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
187mean(2)
188+0.469457567
189mean(0) ! reference
190+0.469457597
191var(2)
192+0.129567102
193var(0) ! reference
194+0.129567116
195
196
197lb(1) = 1; ub(1) = getUnifRand(2, 7)
198do isam = 2, nsam
199 lb(isam) = ub(isam - 1) + 1
200 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
201end do
202lb
203+1, +7
204ub
205+6, +12
206sample = cmplx(getUnifRand(-1., +1., ub(nsam)), getUnifRand(-1., +1., ub(nsam)), TKG)
207sample
208(+0.801158905, +0.962853432E-3), (+0.210760355, +0.602453232), (-0.984127879, +0.956022024), (+0.110168099, -0.636793494), (-0.704571128, -0.118475676), (-0.509290576, -0.652885079), (-0.427154779, +0.631077290E-1), (-0.708558559E-1, +0.205811262E-1), (-0.694830179, -0.457609057), (+0.292301059, -0.659750700E-1), (-0.781919956, +0.835206509), (+0.727935791, -0.540279627)
209mean(0) = getMean(sample)
210mean(0) ! reference
211(-0.169202164, +0.526289165E-3)
212var(0) = getVar(sample)
213var(0) ! reference
214+0.608877420
215do isam = 1, nsam
216 var(isam) = getVar(sample(lb(isam):ub(isam)))
217 mean(isam) = getMean(sample(lb(isam):ub(isam)))
218end do
219call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
220meanMerged
221(-0.169202179, +0.526289456E-3)
222varMerged
223+0.608877480
224call setVarMeanMerged(var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
225mean(2)
226(-0.169202179, +0.526289456E-3)
227mean(0) ! reference
228(-0.169202164, +0.526289165E-3)
229var(2)
230+0.608877480
231var(0) ! reference
232+0.608877420
233
234
235lb(1) = 1; ub(1) = getUnifRand(2, 7)
236do isam = 2, nsam
237 lb(isam) = ub(isam - 1) + 1
238 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
239end do
240lb
241+1, +5
242ub
243+4, +8
244sample = cmplx(getUnifRand(-1., +1., ub(nsam)), getUnifRand(-1., +1., ub(nsam)), TKG)
245sample
246(+0.529052019, -0.868605375E-1), (-0.493851066, -0.366667509E-1), (-0.260193944, +0.392078161), (-0.200027227E-1, +0.929609656), (-0.612545013, +0.222085357), (-0.443601847, +0.670454979), (-0.545647740, +0.533435345), (-0.352996111, -0.934483647)
247mean(0) = getMean(sample)
248mean(0) ! reference
249(-0.274973303, +0.211206570)
250var(0) = getVar(sample)
251var(0) ! reference
252+0.413487852
253do isam = 1, nsam
254 var(isam) = getVar(sample(lb(isam):ub(isam)))
255 mean(isam) = getMean(sample(lb(isam):ub(isam)))
256end do
257call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
258meanMerged
259(-0.274973303, +0.211206570)
260varMerged
261+0.413487792
262call setVarMeanMerged(var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
263mean(2)
264(-0.274973303, +0.211206570)
265mean(0) ! reference
266(-0.274973303, +0.211206570)
267var(2)
268+0.413487792
269var(0) ! reference
270+0.413487852
271
272
273lb(1) = 1; ub(1) = getUnifRand(2, 7)
274do isam = 2, nsam
275 lb(isam) = ub(isam - 1) + 1
276 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
277end do
278lb
279+1, +7
280ub
281+6, +8
282sample = cmplx(getUnifRand(-1., +1., ub(nsam)), getUnifRand(-1., +1., ub(nsam)), TKG)
283sample
284(-0.806439161, -0.688816190), (+0.126288772, +0.262729406), (-0.130549192, -0.820411921), (+0.512068272E-1, +0.401137114), (+0.659992576, +0.424023509), (+0.516079664, +0.233240485), (-0.906788826, +0.970872045), (-0.495441437, -0.576867700)
285mean(0) = getMean(sample)
286mean(0) ! reference
287(-0.123206347, +0.257383436E-1)
288var(0) = getVar(sample)
289var(0) ! reference
290+0.651990533
291do isam = 1, nsam
292 var(isam) = getVar(sample(lb(isam):ub(isam)))
293 mean(isam) = getMean(sample(lb(isam):ub(isam)))
294end do
295call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
296meanMerged
297(-0.123206347, +0.257383436E-1)
298varMerged
299+0.651990414
300call setVarMeanMerged(var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
301mean(2)
302(-0.123206347, +0.257383436E-1)
303mean(0) ! reference
304(-0.123206347, +0.257383436E-1)
305var(2)
306+0.651990414
307var(0) ! reference
308+0.651990533
309
310
311lb(1) = 1; ub(1) = getUnifRand(2, 7)
312do isam = 2, nsam
313 lb(isam) = ub(isam - 1) + 1
314 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
315end do
316lb
317+1, +6
318ub
319+5, +12
320sample = cmplx(getUnifRand(-1., +1., ub(nsam)), getUnifRand(-1., +1., ub(nsam)), TKG)
321sample
322(+0.540003300, +0.109041452), (-0.367841721E-1, +0.277980685), (+0.877188444, -0.245737076), (-0.336740017, -0.323849559), (-0.850127816, -0.184817672), (+0.687840700, -0.316632271), (+0.957695961, -0.303204417), (-0.897617340E-1, -0.770005941), (-0.925921321, -0.153110504), (+0.934314966, -0.251621485), (-0.526561618, -0.843809247), (+0.247843266E-1, -0.198450327)
323mean(0) = getMean(sample)
324mean(0) ! reference
325(+0.104660921, -0.267018020)
326var(0) = getVar(sample)
327var(0) ! reference
328+0.519154489
329do isam = 1, nsam
330 var(isam) = getVar(sample(lb(isam):ub(isam)))
331 mean(isam) = getMean(sample(lb(isam):ub(isam)))
332end do
333call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
334meanMerged
335(+0.104660928, -0.267018050)
336varMerged
337+0.519154489
338call setVarMeanMerged(var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
339mean(2)
340(+0.104660928, -0.267018050)
341mean(0) ! reference
342(+0.104660921, -0.267018020)
343var(2)
344+0.519154489
345var(0) ! reference
346+0.519154489
347
348
349lb(1) = 1; ub(1) = getUnifRand(2, 7)
350do isam = 2, nsam
351 lb(isam) = ub(isam - 1) + 1
352 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
353end do
354lb
355+1, +5
356ub
357+4, +11
358sample = cmplx(getUnifRand(-1., +1., ub(nsam)), getUnifRand(-1., +1., ub(nsam)), TKG)
359sample
360(-0.469204903, -0.226135015), (-0.386271119, +0.397879481), (-0.199822664, -0.411331773), (+0.356772304, +0.825235963), (+0.310785055, -0.351433516), (-0.238024712, -0.188817978), (-0.478876948, -0.407534361), (-0.495306730, -0.966156840), (-0.424324989, +0.835064173), (+0.737160206, -0.971837282), (-0.949585438, +0.102951050)
361mean(0) = getMean(sample)
362mean(0) ! reference
363(-0.203336373, -0.123828739)
364var(0) = getVar(sample)
365var(0) ! reference
366+0.557901859
367do isam = 1, nsam
368 var(isam) = getVar(sample(lb(isam):ub(isam)))
369 mean(isam) = getMean(sample(lb(isam):ub(isam)))
370end do
371call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
372meanMerged
373(-0.203336358, -0.123828739)
374varMerged
375+0.557901859
376call setVarMeanMerged(var(2), mean(2), var(1), mean(1), ub(1) / real(ub(2), TKG))
377mean(2)
378(-0.203336358, -0.123828739)
379mean(0) ! reference
380(-0.203336373, -0.123828739)
381var(2)
382+0.557901859
383var(0) ! reference
384+0.557901859
385
386
387!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
388!Compute the biased merged variance and mean of a frequency weighted univariate sample.
389!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
390
391
392lb(1) = 1; ub(1) = getUnifRand(2, 7)
393do isam = 2, nsam
394 lb(isam) = ub(isam - 1) + 1
395 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
396end do
397lb
398+1, +6
399ub
400+5, +10
401sample = getUnifRand(0., 1., ub(nsam))
402sample
403+0.701505542E-1, +0.508313477, +0.663662851, +0.766035795, +0.129113495, +0.488194823E-1, +0.533005714, +0.840995431, +0.714910030E-1, +0.621918678
404iweight = getUnifRand(1, 10, size(sample, 1, IK))
405iweight
406+6, +6, +7, +10, +9, +3, +9, +7, +10, +6
407mean(0) = getMean(sample, iweight)
408mean(0) ! reference
409+0.441311032
410var(0) = getVar(sample, iweight)
411var(0) ! reference
412+0.869956687E-1
413do isam = 1, nsam
414 var(isam) = getVar(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
415 mean(isam) = getMean(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
416end do
417call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
418meanMerged
419+0.441311061
420varMerged
421+0.869956613E-1
422call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
423mean(2)
424+0.441311061
425mean(0) ! reference
426+0.441311032
427var(2)
428+0.869956613E-1
429var(0) ! reference
430+0.869956687E-1
431
432
433lb(1) = 1; ub(1) = getUnifRand(2, 7)
434do isam = 2, nsam
435 lb(isam) = ub(isam - 1) + 1
436 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
437end do
438lb
439+1, +3
440ub
441+2, +6
442sample = getUnifRand(0., 1., ub(nsam))
443sample
444+0.596907258, +0.626886666, +0.858889878, +0.510622203, +0.609003961, +0.780717015
445iweight = getUnifRand(1, 10, size(sample, 1, IK))
446iweight
447+8, +5, +9, +1, +7, +4
448mean(0) = getMean(sample, iweight)
449mean(0) ! reference
450+0.692241669
451var(0) = getVar(sample, iweight)
452var(0) ! reference
453+0.134354997E-1
454do isam = 1, nsam
455 var(isam) = getVar(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
456 mean(isam) = getMean(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
457end do
458call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
459meanMerged
460+0.692241669
461varMerged
462+0.134354997E-1
463call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
464mean(2)
465+0.692241669
466mean(0) ! reference
467+0.692241669
468var(2)
469+0.134354997E-1
470var(0) ! reference
471+0.134354997E-1
472
473
474lb(1) = 1; ub(1) = getUnifRand(2, 7)
475do isam = 2, nsam
476 lb(isam) = ub(isam - 1) + 1
477 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
478end do
479lb
480+1, +3
481ub
482+2, +7
483sample = getUnifRand(0., 1., ub(nsam))
484sample
485+0.335113466, +0.973845780, +0.818820000E-1, +0.996913373, +0.634366870, +0.131615400E-1, +0.471685588
486iweight = getUnifRand(1, 10, size(sample, 1, IK))
487iweight
488+5, +4, +1, +6, +2, +5, +5
489mean(0) = getMean(sample, iweight)
490mean(0) ! reference
491+0.547402918
492var(0) = getVar(sample, iweight)
493var(0) ! reference
494+0.137595579
495do isam = 1, nsam
496 var(isam) = getVar(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
497 mean(isam) = getMean(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
498end do
499call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
500meanMerged
501+0.547402978
502varMerged
503+0.137595579
504call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
505mean(2)
506+0.547402978
507mean(0) ! reference
508+0.547402918
509var(2)
510+0.137595579
511var(0) ! reference
512+0.137595579
513
514
515lb(1) = 1; ub(1) = getUnifRand(2, 7)
516do isam = 2, nsam
517 lb(isam) = ub(isam - 1) + 1
518 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
519end do
520lb
521+1, +6
522ub
523+5, +11
524sample = getUnifRand(0., 1., ub(nsam))
525sample
526+0.422895610, +0.638454258, +0.829345107, +0.559985995, +0.598645210E-1, +0.914627314E-2, +0.829150975, +0.150096893, +0.981886268, +0.852020204, +0.153485954
527iweight = getUnifRand(1, 10, size(sample, 1, IK))
528iweight
529+4, +6, +4, +8, +2, +9, +1, +2, +5, +7, +4
530mean(0) = getMean(sample, iweight)
531mean(0) ! reference
532+0.502663136
533var(0) = getVar(sample, iweight)
534var(0) ! reference
535+0.115749151
536do isam = 1, nsam
537 var(isam) = getVar(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
538 mean(isam) = getMean(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
539end do
540call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
541meanMerged
542+0.502663195
543varMerged
544+0.115749151
545call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
546mean(2)
547+0.502663195
548mean(0) ! reference
549+0.502663136
550var(2)
551+0.115749151
552var(0) ! reference
553+0.115749151
554
555
556lb(1) = 1; ub(1) = getUnifRand(2, 7)
557do isam = 2, nsam
558 lb(isam) = ub(isam - 1) + 1
559 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
560end do
561lb
562+1, +4
563ub
564+3, +5
565sample = getUnifRand(0., 1., ub(nsam))
566sample
567+0.173784912, +0.158469498, +0.739210546, +0.495084107, +0.337988734E-1
568iweight = getUnifRand(1, 10, size(sample, 1, IK))
569iweight
570+9, +1, +4, +8, +10
571mean(0) = getMean(sample, iweight)
572mean(0) ! reference
573+0.280563682
574var(0) = getVar(sample, iweight)
575var(0) ! reference
576+0.605009720E-1
577do isam = 1, nsam
578 var(isam) = getVar(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
579 mean(isam) = getMean(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
580end do
581call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
582meanMerged
583+0.280563653
584varMerged
585+0.605009645E-1
586call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
587mean(2)
588+0.280563653
589mean(0) ! reference
590+0.280563682
591var(2)
592+0.605009645E-1
593var(0) ! reference
594+0.605009720E-1
595
596
597lb(1) = 1; ub(1) = getUnifRand(2, 7)
598do isam = 2, nsam
599 lb(isam) = ub(isam - 1) + 1
600 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
601end do
602lb
603+1, +3
604ub
605+2, +9
606sample = cmplx(getUnifRand(0., 1., ub(nsam)), -getUnifRand(0., 1., ub(nsam)), TKG)
607sample
608(+0.558308482, -0.966540754), (+0.431492269, -0.113531291), (+0.833939731, -0.940448761), (+0.305300236, -0.650056243), (+0.320975304, -0.355702698), (+0.492913067, -0.250933945), (+0.995503962, -0.222379148), (+0.487275422, -0.607189894), (+0.863998532, -0.644135475E-1)
609iweight = getUnifRand(1, 10, size(sample, 1, IK))
610iweight
611+6, +3, +4, +1, +2, +6, +1, +1, +2
612mean(0) = getMean(sample, iweight)
613mean(0) ! reference
614(+0.580599725, -0.527965188)
615var(0) = getVar(sample, iweight)
616var(0) ! reference
617+0.166873232
618do isam = 1, nsam
619 var(isam) = getVar(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
620 mean(isam) = getMean(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
621end do
622call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
623meanMerged
624(+0.580599666, -0.527965188)
625varMerged
626+0.166873217
627call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
628mean(2)
629(+0.580599666, -0.527965188)
630mean(0) ! reference
631(+0.580599725, -0.527965188)
632var(2)
633+0.166873217
634var(0) ! reference
635+0.166873232
636
637
638lb(1) = 1; ub(1) = getUnifRand(2, 7)
639do isam = 2, nsam
640 lb(isam) = ub(isam - 1) + 1
641 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
642end do
643lb
644+1, +3
645ub
646+2, +6
647sample = cmplx(getUnifRand(0., 1., ub(nsam)), -getUnifRand(0., 1., ub(nsam)), TKG)
648sample
649(+0.358182371, -0.448367715), (+0.775513649, -0.144074440), (+0.779866338, -0.909540296), (+0.611526370E-1, -0.319255292), (+0.598419309E-1, -0.532354891), (+0.359419882, -0.894570708)
650iweight = getUnifRand(1, 10, size(sample, 1, IK))
651iweight
652+10, +1, +3, +6, +2, +2
653mean(0) = getMean(sample, iweight)
654mean(0) ! reference
655(+0.329265654, -0.505239785)
656var(0) = getVar(sample, iweight)
657var(0) ! reference
658+0.106677353
659do isam = 1, nsam
660 var(isam) = getVar(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
661 mean(isam) = getMean(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
662end do
663call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
664meanMerged
665(+0.329265654, -0.505239785)
666varMerged
667+0.106677361
668call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
669mean(2)
670(+0.329265654, -0.505239785)
671mean(0) ! reference
672(+0.329265654, -0.505239785)
673var(2)
674+0.106677361
675var(0) ! reference
676+0.106677353
677
678
679lb(1) = 1; ub(1) = getUnifRand(2, 7)
680do isam = 2, nsam
681 lb(isam) = ub(isam - 1) + 1
682 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
683end do
684lb
685+1, +4
686ub
687+3, +8
688sample = cmplx(getUnifRand(0., 1., ub(nsam)), -getUnifRand(0., 1., ub(nsam)), TKG)
689sample
690(+0.711909115, -0.841032982), (+0.269236028, -0.573951840), (+0.687201858, -0.726742506), (+0.318318903, -0.564504802), (+0.490798354E-1, -0.957034111), (+0.461083829, -0.359048188), (+0.902928472, -0.827983439), (+0.382648230, -0.613879204)
691iweight = getUnifRand(1, 10, size(sample, 1, IK))
692iweight
693+7, +6, +7, +8, +8, +4, +10, +9
694mean(0) = getMean(sample, iweight)
695mean(0) ! reference
696(+0.485861659, -0.709006667)
697var(0) = getVar(sample, iweight)
698var(0) ! reference
699+0.103683129
700do isam = 1, nsam
701 var(isam) = getVar(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
702 mean(isam) = getMean(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
703end do
704call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
705meanMerged
706(+0.485861659, -0.709006667)
707varMerged
708+0.103683144
709call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
710mean(2)
711(+0.485861659, -0.709006667)
712mean(0) ! reference
713(+0.485861659, -0.709006667)
714var(2)
715+0.103683144
716var(0) ! reference
717+0.103683129
718
719
720lb(1) = 1; ub(1) = getUnifRand(2, 7)
721do isam = 2, nsam
722 lb(isam) = ub(isam - 1) + 1
723 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
724end do
725lb
726+1, +7
727ub
728+6, +11
729sample = cmplx(getUnifRand(0., 1., ub(nsam)), -getUnifRand(0., 1., ub(nsam)), TKG)
730sample
731(+0.987938046E-1, -0.979642093), (+0.266931891, -0.334516943), (+0.602450013, -0.584214926E-2), (+0.656891644, -0.182013988), (+0.396838129, -0.253311217), (+0.639068127, -0.202912629), (+0.478952527E-1, -0.126890540), (+0.652961493, -0.565283179), (+0.987951398, -0.313381433), (+0.266513228, -0.516300797), (+0.464500844, -0.696025372)
732iweight = getUnifRand(1, 10, size(sample, 1, IK))
733iweight
734+9, +4, +1, +8, +4, +2, +3, +5, +4, +10, +4
735mean(0) = getMean(sample, iweight)
736mean(0) ! reference
737(+0.417840362, -0.471177638)
738var(0) = getVar(sample, iweight)
739var(0) ! reference
740+0.151217729
741do isam = 1, nsam
742 var(isam) = getVar(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
743 mean(isam) = getMean(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
744end do
745call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
746meanMerged
747(+0.417840362, -0.471177667)
748varMerged
749+0.151217729
750call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
751mean(2)
752(+0.417840362, -0.471177667)
753mean(0) ! reference
754(+0.417840362, -0.471177638)
755var(2)
756+0.151217729
757var(0) ! reference
758+0.151217729
759
760
761lb(1) = 1; ub(1) = getUnifRand(2, 7)
762do isam = 2, nsam
763 lb(isam) = ub(isam - 1) + 1
764 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
765end do
766lb
767+1, +5
768ub
769+4, +7
770sample = cmplx(getUnifRand(0., 1., ub(nsam)), -getUnifRand(0., 1., ub(nsam)), TKG)
771sample
772(+0.255483687, -0.863725185), (+0.252958536E-1, -0.131093144), (+0.827879131, -0.233905315E-1), (+0.141663313, -0.838022411), (+0.123178959E-1, -0.273090243), (+0.521687031, -0.840979874), (+0.168640614, -0.666367531)
773iweight = getUnifRand(1, 10, size(sample, 1, IK))
774iweight
775+4, +6, +10, +3, +8, +6, +1
776mean(0) = getMean(sample, iweight)
777mean(0) ! reference
778(+0.349336773, -0.391747385)
779var(0) = getVar(sample, iweight)
780var(0) ! reference
781+0.233056664
782do isam = 1, nsam
783 var(isam) = getVar(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
784 mean(isam) = getMean(sample(lb(isam):ub(isam)), iweight(lb(isam):ub(isam)))
785end do
786call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
787meanMerged
788(+0.349336773, -0.391747385)
789varMerged
790+0.233056650
791call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
792mean(2)
793(+0.349336773, -0.391747385)
794mean(0) ! reference
795(+0.349336773, -0.391747385)
796var(2)
797+0.233056650
798var(0) ! reference
799+0.233056664
800
801
802!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
803!Compute the biased merged variance and mean of a reliability weighted univariate sample.
804!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
805
806
807lb(1) = 1; ub(1) = getUnifRand(2, 7)
808do isam = 2, nsam
809 lb(isam) = ub(isam - 1) + 1
810 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
811end do
812lb
813+1, +8
814ub
815+7, +14
816sample = getUnifRand(0., 1., ub(nsam))
817sample
818+0.132835269, +0.871566176, +0.775098443, +0.907114089, +0.543647945, +0.767972767, +0.747309387, +0.377118051, +0.887677670, +0.682251513, +0.542521238, +0.744446516E-1, +0.393683314, +0.756820977
819rweight = getUnifRand(1., 2., size(sample, 1, IK))
820rweight
821+1.22699714, +1.18399847, +1.77490568, +1.27476716, +1.69784927, +1.09041381, +1.34542489, +1.66541398, +1.75653911, +1.59754062, +1.79350400, +1.21765828, +1.75040889, +1.15708590
822mean(0) = getMean(sample, rweight)
823mean(0) ! reference
824+0.603851974
825var(0) = getVar(sample, rweight)
826var(0) ! reference
827+0.622879639E-1
828do isam = 1, nsam
829 var(isam) = getVar(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
830 mean(isam) = getMean(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
831end do
832call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
833meanMerged
834+0.603851974
835varMerged
836+0.622879639E-1
837call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
838mean(2)
839+0.603851974
840mean(0) ! reference
841+0.603851974
842var(2)
843+0.622879639E-1
844var(0) ! reference
845+0.622879639E-1
846
847
848lb(1) = 1; ub(1) = getUnifRand(2, 7)
849do isam = 2, nsam
850 lb(isam) = ub(isam - 1) + 1
851 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
852end do
853lb
854+1, +7
855ub
856+6, +12
857sample = getUnifRand(0., 1., ub(nsam))
858sample
859+0.385523200, +0.151785374, +0.892585039, +0.805965960, +0.524945855, +0.951787770, +0.701613188, +0.747123420, +0.696798205, +0.673267841E-1, +0.535488605, +0.402875066
860rweight = getUnifRand(1., 2., size(sample, 1, IK))
861rweight
862+1.49040484, +1.00088000, +1.05744600, +1.19077814, +1.57509434, +1.39221954, +1.51680493, +1.29833269, +1.62845206, +1.46337569, +1.35242033, +1.58305430
863mean(0) = getMean(sample, rweight)
864mean(0) ! reference
865+0.568693519
866var(0) = getVar(sample, rweight)
867var(0) ! reference
868+0.674956143E-1
869do isam = 1, nsam
870 var(isam) = getVar(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
871 mean(isam) = getMean(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
872end do
873call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
874meanMerged
875+0.568693519
876varMerged
877+0.674956143E-1
878call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
879mean(2)
880+0.568693519
881mean(0) ! reference
882+0.568693519
883var(2)
884+0.674956143E-1
885var(0) ! reference
886+0.674956143E-1
887
888
889lb(1) = 1; ub(1) = getUnifRand(2, 7)
890do isam = 2, nsam
891 lb(isam) = ub(isam - 1) + 1
892 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
893end do
894lb
895+1, +4
896ub
897+3, +8
898sample = getUnifRand(0., 1., ub(nsam))
899sample
900+0.396233797E-2, +0.786422789, +0.471328497E-1, +0.602182388, +0.485928059, +0.486149132, +0.131243944, +0.834346592
901rweight = getUnifRand(1., 2., size(sample, 1, IK))
902rweight
903+1.84344220, +1.58568430, +1.44832397, +1.95216489, +1.72541952, +1.59418809, +1.16701436, +1.19981599
904mean(0) = getMean(sample, rweight)
905mean(0) ! reference
906+0.420724869
907var(0) = getVar(sample, rweight)
908var(0) ! reference
909+0.891571492E-1
910do isam = 1, nsam
911 var(isam) = getVar(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
912 mean(isam) = getMean(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
913end do
914call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
915meanMerged
916+0.420724869
917varMerged
918+0.891571566E-1
919call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
920mean(2)
921+0.420724869
922mean(0) ! reference
923+0.420724869
924var(2)
925+0.891571566E-1
926var(0) ! reference
927+0.891571492E-1
928
929
930lb(1) = 1; ub(1) = getUnifRand(2, 7)
931do isam = 2, nsam
932 lb(isam) = ub(isam - 1) + 1
933 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
934end do
935lb
936+1, +7
937ub
938+6, +10
939sample = getUnifRand(0., 1., ub(nsam))
940sample
941+0.205258787, +0.893208385E-1, +0.946596920, +0.893974543, +0.386933804, +0.815021157, +0.759558976, +0.529469252, +0.297594368, +0.870348871
942rweight = getUnifRand(1., 2., size(sample, 1, IK))
943rweight
944+1.13571191, +1.66045403, +1.64836907, +1.13851058, +1.44940674, +1.60287857, +1.35368907, +1.59423661, +1.40005064, +1.72472763
945mean(0) = getMean(sample, rweight)
946mean(0) ! reference
947+0.585859418
948var(0) = getVar(sample, rweight)
949var(0) ! reference
950+0.910973400E-1
951do isam = 1, nsam
952 var(isam) = getVar(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
953 mean(isam) = getMean(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
954end do
955call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
956meanMerged
957+0.585859418
958varMerged
959+0.910973251E-1
960call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
961mean(2)
962+0.585859418
963mean(0) ! reference
964+0.585859418
965var(2)
966+0.910973251E-1
967var(0) ! reference
968+0.910973400E-1
969
970
971lb(1) = 1; ub(1) = getUnifRand(2, 7)
972do isam = 2, nsam
973 lb(isam) = ub(isam - 1) + 1
974 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
975end do
976lb
977+1, +3
978ub
979+2, +7
980sample = getUnifRand(0., 1., ub(nsam))
981sample
982+0.505931675, +0.527020872, +0.486540020, +0.537758350, +0.387741745, +0.720295787, +0.962912679
983rweight = getUnifRand(1., 2., size(sample, 1, IK))
984rweight
985+1.53134251, +1.26934409, +1.86794567, +1.85778236, +1.29841423, +1.20967221, +1.44157910
986mean(0) = getMean(sample, rweight)
987mean(0) ! reference
988+0.583661079
989var(0) = getVar(sample, rweight)
990var(0) ! reference
991+0.300327372E-1
992do isam = 1, nsam
993 var(isam) = getVar(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
994 mean(isam) = getMean(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
995end do
996call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
997meanMerged
998+0.583661079
999varMerged
1000+0.300327390E-1
1001call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1002mean(2)
1003+0.583661079
1004mean(0) ! reference
1005+0.583661079
1006var(2)
1007+0.300327390E-1
1008var(0) ! reference
1009+0.300327372E-1
1010
1011
1012lb(1) = 1; ub(1) = getUnifRand(2, 7)
1013do isam = 2, nsam
1014 lb(isam) = ub(isam - 1) + 1
1015 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
1016end do
1017lb
1018+1, +7
1019ub
1020+6, +9
1021sample = cmplx(getUnifRand(0., 1., ub(nsam)), -getUnifRand(0., 1., ub(nsam)), TKG)
1022sample
1023(+0.145176530, -0.660803080), (+0.692834854E-1, -0.524664700), (+0.921244144, -0.426119447), (+0.899475634, -0.535263300), (+0.473420918, -0.416758120), (+0.604838371, -0.511714697), (+0.342711806E-1, -0.805644035), (+0.487457275, -0.203567863), (+0.541109562, -0.115936935)
1024rweight = getUnifRand(1., 2., size(sample, 1, IK))
1025rweight
1026+1.60351181, +1.49233472, +1.12591147, +1.94855857, +1.01515245, +1.90431690, +1.26000714, +1.62076271, +1.59752035
1027mean(0) = getMean(sample, rweight)
1028mean(0) ! reference
1029(+0.475835502, -0.463820279)
1030var(0) = getVar(sample, rweight)
1031var(0) ! reference
1032+0.133821428
1033do isam = 1, nsam
1034 var(isam) = getVar(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
1035 mean(isam) = getMean(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
1036end do
1037call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1038meanMerged
1039(+0.475835532, -0.463820308)
1040varMerged
1041+0.133821428
1042call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1043mean(2)
1044(+0.475835532, -0.463820308)
1045mean(0) ! reference
1046(+0.475835502, -0.463820279)
1047var(2)
1048+0.133821428
1049var(0) ! reference
1050+0.133821428
1051
1052
1053lb(1) = 1; ub(1) = getUnifRand(2, 7)
1054do isam = 2, nsam
1055 lb(isam) = ub(isam - 1) + 1
1056 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
1057end do
1058lb
1059+1, +7
1060ub
1061+6, +9
1062sample = cmplx(getUnifRand(0., 1., ub(nsam)), -getUnifRand(0., 1., ub(nsam)), TKG)
1063sample
1064(+0.241394639E-1, -0.748961091), (+0.253201246, -0.899627328), (+0.212384999, -0.271962345), (+0.300542712E-1, -0.374002814), (+0.996819735, -0.791645885), (+0.634574950, -0.480429113), (+0.174930692, -0.407218218), (+0.213004172, -0.684497714), (+0.827396333, -0.463329673)
1065rweight = getUnifRand(1., 2., size(sample, 1, IK))
1066rweight
1067+1.38830280, +1.45451522, +1.05288303, +1.00300562, +1.94611835, +1.98834896, +1.67692256, +1.29554772, +1.89863777
1068mean(0) = getMean(sample, rweight)
1069mean(0) ! reference
1070(+0.437634945, -0.580478609)
1071var(0) = getVar(sample, rweight)
1072var(0) ! reference
1073+0.159782201
1074do isam = 1, nsam
1075 var(isam) = getVar(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
1076 mean(isam) = getMean(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
1077end do
1078call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1079meanMerged
1080(+0.437634945, -0.580478609)
1081varMerged
1082+0.159782201
1083call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1084mean(2)
1085(+0.437634945, -0.580478609)
1086mean(0) ! reference
1087(+0.437634945, -0.580478609)
1088var(2)
1089+0.159782201
1090var(0) ! reference
1091+0.159782201
1092
1093
1094lb(1) = 1; ub(1) = getUnifRand(2, 7)
1095do isam = 2, nsam
1096 lb(isam) = ub(isam - 1) + 1
1097 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
1098end do
1099lb
1100+1, +3
1101ub
1102+2, +4
1103sample = cmplx(getUnifRand(0., 1., ub(nsam)), -getUnifRand(0., 1., ub(nsam)), TKG)
1104sample
1105(+0.249018967, -0.886792243), (+0.673844218, -0.468544424), (+0.427544892, -0.629629791), (+0.420058727, -0.593061984)
1106rweight = getUnifRand(1., 2., size(sample, 1, IK))
1107rweight
1108+1.14002752, +1.65599191, +1.93492341, +1.00124562
1109mean(0) = getMean(sample, rweight)
1110mean(0) ! reference
1111(+0.461886048, -0.627850950)
1112var(0) = getVar(sample, rweight)
1113var(0) ! reference
1114+0.435736962E-1
1115do isam = 1, nsam
1116 var(isam) = getVar(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
1117 mean(isam) = getMean(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
1118end do
1119call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1120meanMerged
1121(+0.461885989, -0.627850771)
1122varMerged
1123+0.435736999E-1
1124call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1125mean(2)
1126(+0.461885989, -0.627850771)
1127mean(0) ! reference
1128(+0.461886048, -0.627850950)
1129var(2)
1130+0.435736999E-1
1131var(0) ! reference
1132+0.435736962E-1
1133
1134
1135lb(1) = 1; ub(1) = getUnifRand(2, 7)
1136do isam = 2, nsam
1137 lb(isam) = ub(isam - 1) + 1
1138 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
1139end do
1140lb
1141+1, +4
1142ub
1143+3, +5
1144sample = cmplx(getUnifRand(0., 1., ub(nsam)), -getUnifRand(0., 1., ub(nsam)), TKG)
1145sample
1146(+0.250425339, -0.129961252), (+0.458485603, -0.416625142), (+0.632188916E-1, -0.594669700), (+0.932048678, -0.610012352), (+0.471760213, -0.339183271)
1147rweight = getUnifRand(1., 2., size(sample, 1, IK))
1148rweight
1149+1.15344775, +1.08451664, +1.01332998, +1.51756334, +1.98186207
1150mean(0) = getMean(sample, rweight)
1151mean(0) ! reference
1152(+0.473957717, -0.415108919)
1153var(0) = getVar(sample, rweight)
1154var(0) ! reference
1155+0.110039875
1156do isam = 1, nsam
1157 var(isam) = getVar(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
1158 mean(isam) = getMean(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
1159end do
1160call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1161meanMerged
1162(+0.473957747, -0.415108919)
1163varMerged
1164+0.110039860
1165call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1166mean(2)
1167(+0.473957747, -0.415108919)
1168mean(0) ! reference
1169(+0.473957717, -0.415108919)
1170var(2)
1171+0.110039860
1172var(0) ! reference
1173+0.110039875
1174
1175
1176lb(1) = 1; ub(1) = getUnifRand(2, 7)
1177do isam = 2, nsam
1178 lb(isam) = ub(isam - 1) + 1
1179 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
1180end do
1181lb
1182+1, +8
1183ub
1184+7, +11
1185sample = cmplx(getUnifRand(0., 1., ub(nsam)), -getUnifRand(0., 1., ub(nsam)), TKG)
1186sample
1187(+0.696598232, -0.151467144), (+0.351984441, -0.814055145), (+0.195879579, -0.724640489E-1), (+0.489833176, -0.436737955), (+0.415061951, -0.887042761), (+0.775786877, -0.510850668), (+0.603616834E-1, -0.516502917), (+0.781464994, -0.820315003), (+0.767220140, -0.678626120), (+0.124815583, -0.825029254), (+0.707865298, -0.177748680)
1188rweight = getUnifRand(1., 2., size(sample, 1, IK))
1189rweight
1190+1.26175809, +1.50726783, +1.10619044, +1.21604908, +1.07151687, +1.50455964, +1.44589996, +1.75267696, +1.71240234, +1.86201596, +1.35395122
1191mean(0) = getMean(sample, rweight)
1192mean(0) ! reference
1193(+0.493553340, -0.561720431)
1194var(0) = getVar(sample, rweight)
1195var(0) ! reference
1196+0.148701340
1197do isam = 1, nsam
1198 var(isam) = getVar(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
1199 mean(isam) = getMean(sample(lb(isam):ub(isam)), rweight(lb(isam):ub(isam)))
1200end do
1201call setVarMeanMerged(varMerged, meanMerged, var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1202meanMerged
1203(+0.493553370, -0.561720490)
1204varMerged
1205+0.148701355
1206call setVarMeanMerged(var(2), mean(2), var(1), mean(1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1207mean(2)
1208(+0.493553370, -0.561720490)
1209mean(0) ! reference
1210(+0.493553340, -0.561720431)
1211var(2)
1212+0.148701355
1213var(0) ! reference
1214+0.148701340
1215
1216
1217!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1218!Compute the biased merged variance and mean of a multivariate sample.
1219!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1220
1221
1222dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
1223do isam = 2, nsam
1224 lb(isam) = ub(isam - 1) + 1
1225 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
1226end do
1227lb
1228+1, +7
1229ub
1230+6, +12
1231ndim = getUnifRand(1, minval(ub - lb + 1, 1))
1232call setRebound(var, [1_IK, 0_IK], [ndim, nsam])
1233call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
1234call setResized(meanMerged, ndim)
1235call setResized(varMerged, ndim)
1236sample = getUnifRand(-1., +1., ndim, ub(nsam))
1237sample
1238-0.570608616, +0.675416708, -0.1638094