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

Return the merged covariance and mean of a sample resulting from the merger of two separate (potentially weighted) samples \(A\) and \(B\).
More...

Detailed Description

Return the merged covariance and mean of a sample resulting from the merger of two separate (potentially weighted) samples \(A\) and \(B\).

See the documentation of pm_sampleCov for more information and definition online updating of sample covariance.

Note
The input and output variances of this generic interface are all biased variances.
A biased covariance can be readily unbiased by multiplying it with the appropriate bias-correction factors detailed in the documentation of pm_sampleCov.
Parameters
[out]cov: The output object of the same type and kind and rank and shape as covA, containing the biased covariance of the sample resulting form the merger of the two samples.
(optional. If missing, the resulting merged covariance will be written to the argument covB.)
[out]mean: 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]covB: The input or input/output object of the same type and kind and rank and shape as the input argument covA, containing the biased covariance of the second sample that must be merged with the first sample.
If the input argument cov is missing, then covB contains the updated biased covariance of the merged sample on return.
Otherwise, the contents of covB remain intact upon return.
[in]meanB: The input or input/output object of the same type and kind and rank as the input argument covA of size size(covA, 1), containing the mean of the second sample that must be merged with the mean of the first sample meanA.
If the input argument mean is missing, then meanB contains the updated mean of the merged sample on return.
Otherwise, the contents of meanB remain intact upon return.
[in]covA: The input contiguous matrix of shape (1 : ndim, 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 biased covariance of the first sample that must be merged with the second sample.
[in]meanA: The input object of the same type and kind as the input argument covA of size size(covA, 1), containing the mean of the first sample that must be merged with the mean of the second sample meanB.
[in]fracA: The input scalar of type real of the same kind as covA, 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)).
[in]subset: The input scalar constant that can be:
  1. The constant lowDia, implying that only the lower-diagonal subset of the input cov, covB, and covA matrices must be accessed and/or manipulated.
  2. The constant uppDia, implying that only the upper-diagonal subset of the input cov, covB, and covA matrices must be accessed and/or manipulated.
This input argument is merely serves to resolve the different procedures of this generic interface from each other at compile-time.


Possible calling interfaces

call setCovMeanMerged(covB(1:ndim, 1:ndim), meanB(1:ndim), covA(1:ndim, 1:ndim), meanA(1:ndim), fracA, subset)
call setCovMeanMerged(cov(1:ndim, 1:ndim), mean(1:ndim), covB(1:ndim, 1:ndim), meanB(1:ndim), covA(1:ndim, 1:ndim), meanA(1:ndim), fracA, subset)
Return the merged covariance and mean of a sample resulting from the merger of two separate (potentia...
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 all(shape(covB) == shape(covA)) must hold for the corresponding input arguments.
The condition all(size(meanB) == shape(covA)) must hold for the corresponding input arguments.
The condition all(size(meanA) == shape(covA)) must hold for the corresponding input arguments.
The condition all(size(mean) == shape(covA)) must hold for the corresponding input arguments.
The condition all(shape(cov) == shape(covA)) 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
setCovMeanMerged
getVarCorrection
getMeanMerged
setMeanMerged
getVarMerged
setVarMerged


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_sampleCov, only: getCov
6 use pm_sampleMean, only: getMean
7 use pm_sampleCov, only: uppDia, lowDia
10 use pm_arrayResize, only: setResized
11 use pm_distUnif, only: getUnifRand
12 use pm_arrayRange, only: getRange
13 use pm_io, only: display_type
14
15 implicit none
16
17 integer(IK) , parameter :: nsam = 2
18 integer(IK) , allocatable :: iweight(:)
19 integer(IK) :: isam, ndim, lb(nsam), ub(nsam)
20 integer(IK) :: dim, itry, ntry = 10
21 type(display_type) :: disp
22 disp = display_type(file = "main.out.F90")
23
24 call disp%skip()
25 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
26 call disp%show("!Compute the biased merged covariance of a multivariate sample.")
27 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
28 call disp%skip()
29
30 block
31 real(TKG), allocatable :: mean(:,:), cov(:,:,:), meanMerged(:), covMerged(:,:)
32 real(TKG), allocatable :: sample(:,:)
33 do itry = 1, ntry
34 call disp%skip()
35 call disp%show("dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)")
36 dim = 2; 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("ndim = getUnifRand(1, minval(ub - lb + 1, 1))")
50 ndim = getUnifRand(1, minval(ub - lb + 1, 1))
51 call disp%show("call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])")
52 call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
53 call disp%show("call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])")
54 call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
55 call disp%show("call setResized(covMerged, [ndim, ndim])")
56 call setResized(covMerged, [ndim, ndim])
57 call disp%show("call setResized(meanMerged, ndim)")
58 call setResized(meanMerged, ndim)
59 call disp%show("sample = getUnifRand(-1., +1., ndim, ub(nsam))")
60 sample = getUnifRand(-1., +1., ndim, ub(nsam))
61 call disp%show("sample")
62 call disp%show( sample )
63 call disp%show("cov(:,:,0) = getCov(sample, dim)")
64 cov(:,:,0) = getCov(sample, dim)
65 call disp%show("cov(:,:,0) ! reference")
66 call disp%show( cov(:,:,0) )
67 call disp%show("mean(:,0) = getMean(sample, dim)")
68 mean(:,0) = getMean(sample, dim)
69 call disp%show("mean(:,0) ! reference")
70 call disp%show( mean(:,0) )
71 call disp%show("do isam = 1, nsam")
72 call disp%show(" cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)")
73 call disp%show(" mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)")
74 call disp%show("end do")
75 do isam = 1, nsam
76 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
77 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
78 end do
79 call disp%show("call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)")
80 call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
81 call disp%show("covMerged")
82 call disp%show( covMerged )
83 call disp%show("call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), lowDia)")
84 call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), lowDia)
85 call disp%show("covMerged")
86 call disp%show( covMerged )
87 call disp%show("call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)")
88 call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
89 call disp%show("cov(:,:,2)")
90 call disp%show( cov(:,:,2) )
91 call disp%show("cov(:,:,0) ! reference")
92 call disp%show( cov(:,:,0) )
93 call disp%skip()
94 end do
95 end block
96
97 call disp%skip()
98 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
99 call disp%show("!Compute the biased merged covariance of a frequency weighted multivariate sample.")
100 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
101 call disp%skip()
102
103 block
104 real(TKG), allocatable :: mean(:,:), cov(:,:,:), meanMerged(:), covMerged(:,:)
105 real(TKG), allocatable :: sample(:,:)
106 do itry = 1, ntry
107 call disp%skip()
108 call disp%show("dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)")
109 dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
110 call disp%show("do isam = 2, nsam")
111 call disp%show(" lb(isam) = ub(isam - 1) + 1")
112 call disp%show(" ub(isam) = ub(isam - 1) + getUnifRand(2, 7)")
113 call disp%show("end do")
114 do isam = 2, nsam
115 lb(isam) = ub(isam - 1) + 1
116 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
117 end do
118 call disp%show("lb")
119 call disp%show( lb )
120 call disp%show("ub")
121 call disp%show( ub )
122 call disp%show("ndim = getUnifRand(1, minval(ub - lb + 1, 1))")
123 ndim = getUnifRand(1, minval(ub - lb + 1, 1))
124 call disp%show("call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])")
125 call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
126 call disp%show("call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])")
127 call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
128 call disp%show("call setResized(covMerged, [ndim, ndim])")
129 call setResized(covMerged, [ndim, ndim])
130 call disp%show("call setResized(meanMerged, ndim)")
131 call setResized(meanMerged, ndim)
132 call disp%show("sample = getUnifRand(-1., +1., ndim, ub(nsam))")
133 sample = getUnifRand(-1., +1., ndim, ub(nsam))
134 call disp%show("sample")
135 call disp%show( sample )
136 call disp%show("iweight = getUnifRand(1, 10, size(sample, dim, IK))")
137 iweight = getUnifRand(1, 10, size(sample, dim, IK))
138 call disp%show("iweight")
139 call disp%show( iweight )
140 call disp%show("cov(:,:,0) = getCov(sample, dim, iweight)")
141 cov(:,:,0) = getCov(sample, dim, iweight)
142 call disp%show("cov(:,:,0) ! reference")
143 call disp%show( cov(:,:,0) )
144 call disp%show("mean(:,0) = getMean(sample, dim, iweight)")
145 mean(:,0) = getMean(sample, dim, iweight)
146 call disp%show("mean(:,0) ! reference")
147 call disp%show( mean(:,0) )
148 call disp%show("do isam = 1, nsam")
149 call disp%show(" cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim, iweight(lb(isam):ub(isam)))")
150 call disp%show(" mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim, iweight(lb(isam):ub(isam)))")
151 call disp%show("end do")
152 do isam = 1, nsam
153 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim, iweight(lb(isam):ub(isam)))
154 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim, iweight(lb(isam):ub(isam)))
155 end do
156 call disp%show("call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), uppDia)")
157 call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), uppDia)
158 call disp%show("covMerged")
159 call disp%show( covMerged )
160 call disp%show("call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), lowDia)")
161 call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), lowDia)
162 call disp%show("covMerged")
163 call disp%show( covMerged )
164 call disp%show("call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), uppDia)")
165 call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), uppDia)
166 call disp%show("cov(:,:,2)")
167 call disp%show( cov(:,:,2) )
168 call disp%show("cov(:,:,0) ! reference")
169 call disp%show( cov(:,:,0) )
170 call disp%skip()
171 end do
172 end block
173
174 call disp%skip()
175 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
176 call disp%show("!Compute the biased merged covariance of a reliability weighted multivariate sample.")
177 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
178 call disp%skip()
179
180 block
181 real(TKG), allocatable :: mean(:,:), cov(:,:,:), meanMerged(:), covMerged(:,:)
182 real(TKG), allocatable :: sample(:,:)
183 real(TKG), allocatable :: rweight(:)
184 do itry = 1, ntry
185 call disp%skip()
186 call disp%show("dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)")
187 dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
188 call disp%show("do isam = 2, nsam")
189 call disp%show(" lb(isam) = ub(isam - 1) + 1")
190 call disp%show(" ub(isam) = ub(isam - 1) + getUnifRand(2, 7)")
191 call disp%show("end do")
192 do isam = 2, nsam
193 lb(isam) = ub(isam - 1) + 1
194 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
195 end do
196 call disp%show("lb")
197 call disp%show( lb )
198 call disp%show("ub")
199 call disp%show( ub )
200 call disp%show("ndim = getUnifRand(1, minval(ub - lb + 1, 1))")
201 ndim = getUnifRand(1, minval(ub - lb + 1, 1))
202 call disp%show("call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])")
203 call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
204 call disp%show("call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])")
205 call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
206 call disp%show("call setResized(covMerged, [ndim, ndim])")
207 call setResized(covMerged, [ndim, ndim])
208 call disp%show("call setResized(meanMerged, ndim)")
209 call setResized(meanMerged, ndim)
210 call disp%show("sample = getUnifRand(-1., +1., ndim, ub(nsam))")
211 sample = getUnifRand(-1., +1., ndim, ub(nsam))
212 call disp%show("sample")
213 call disp%show( sample )
214 call disp%show("rweight = getUnifRand(1., 2., size(sample, dim, IK))")
215 rweight = getUnifRand(1., 2., size(sample, dim, IK))
216 call disp%show("rweight")
217 call disp%show( rweight )
218 call disp%show("cov(:,:,0) = getCov(sample, 2_IK, rweight)")
219 cov(:,:,0) = getCov(sample, 2_IK, rweight)
220 call disp%show("cov(:,:,0) ! reference")
221 call disp%show( cov(:,:,0) )
222 call disp%show("mean(:,0) = getMean(sample, dim, rweight)")
223 mean(:,0) = getMean(sample, dim, rweight)
224 call disp%show("mean(:,0) ! reference")
225 call disp%show( mean(:,0) )
226 call disp%show("do isam = 1, nsam")
227 call disp%show(" cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))")
228 call disp%show(" mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))")
229 call disp%show("end do")
230 do isam = 1, nsam
231 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
232 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
233 end do
234 call disp%show("call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG), uppDia)")
235 call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG), uppDia)
236 call disp%show("covMerged")
237 call disp%show( covMerged )
238 call disp%show("call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG), lowDia)")
239 call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG), lowDia)
240 call disp%show("covMerged")
241 call disp%show( covMerged )
242 call disp%show("call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG), uppDia)")
243 call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG), uppDia)
244 call disp%show("cov(:,:,2)")
245 call disp%show( cov(:,:,2) )
246 call disp%show("cov(:,:,0) ! reference")
247 call disp%show( cov(:,:,0) )
248 call disp%skip()
249 end do
250 end block
251
252end 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 (optionally unbiased) covariance matrix of a pair of (potentially weighted) t...
Generate and return the (weighted) mean of an input sample of nsam observations with ndim = 1 or 2 at...
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 covariance of a multivariate sample.
4!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5
6
7dim = 2; lb(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, +5
14ub
15+4, +8
16ndim = getUnifRand(1, minval(ub - lb + 1, 1))
17call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
18call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
19call setResized(covMerged, [ndim, ndim])
20call setResized(meanMerged, ndim)
21sample = getUnifRand(-1., +1., ndim, ub(nsam))
22sample
23-0.177876234, -0.361559272, +0.172226548, -0.955668449, +0.982272983, -0.982040763, -0.170473456, -0.640297532
24+0.357866287E-2, -0.398587108, +0.366217256, +0.926423669, +0.744472265, -0.590144515, +0.526790023, -0.606699109
25+0.144594312, -0.452466011E-1, +0.400626540, +0.359095812, +0.708134532, +0.822257519, +0.824316859, -0.178211570
26-0.580209374, +0.362073898, -0.269213438, +0.597606063, +0.927723527, -0.353467464E-2, -0.988077044, -0.305322051
27cov(:,:,0) = getCov(sample, dim)
28cov(:,:,0) ! reference
29+0.363087833, +0.148737967, +0.484566018E-1, +0.705556571E-1
30+0.148737967, +0.322656333, +0.891751274E-1, +0.871994719E-1
31+0.484566018E-1, +0.891751274E-1, +0.131174013, -0.163108110E-3
32+0.705556571E-1, +0.871994719E-1, -0.163108110E-3, +0.352396071
33mean(:,0) = getMean(sample, dim)
34mean(:,0) ! reference
35-0.266677022, +0.121506393, +0.379445910, -0.323691368E-1
36do isam = 1, nsam
37 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
38 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
39end do
40call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
41covMerged
42+0.363087744, +0.148737937, +0.484566130E-1, +0.705556199E-1
43+0.00000000, +0.322656333, +0.891751200E-1, +0.871994719E-1
44+0.00000000, +0.00000000, +0.131174013, -0.163140707E-3
45+0.00000000, +0.00000000, +0.00000000, +0.352396101
46call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), lowDia)
47covMerged
48+0.363087744, +0.148737937, +0.484566130E-1, +0.705556199E-1
49+0.148737937, +0.322656333, +0.891751200E-1, +0.871994719E-1
50+0.484566130E-1, +0.891751200E-1, +0.131174013, -0.163140707E-3
51+0.705556199E-1, +0.871994719E-1, -0.163140707E-3, +0.352396101
52call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
53cov(:,:,2)
54+0.363087744, +0.148737937, +0.484566130E-1, +0.705556199E-1
55+0.406141222, +0.322656333, +0.891751200E-1, +0.871994719E-1
56+0.756773204E-1, +0.135951370, +0.131174013, -0.163140707E-3
57+0.300967932, +0.910872221E-1, +0.237165689E-1, +0.352396101
58cov(:,:,0) ! reference
59+0.363087833, +0.148737967, +0.484566018E-1, +0.705556571E-1
60+0.148737967, +0.322656333, +0.891751274E-1, +0.871994719E-1
61+0.484566018E-1, +0.891751274E-1, +0.131174013, -0.163108110E-3
62+0.705556571E-1, +0.871994719E-1, -0.163108110E-3, +0.352396071
63
64
65dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
66do isam = 2, nsam
67 lb(isam) = ub(isam - 1) + 1
68 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
69end do
70lb
71+1, +4
72ub
73+3, +5
74ndim = getUnifRand(1, minval(ub - lb + 1, 1))
75call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
76call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
77call setResized(covMerged, [ndim, ndim])
78call setResized(meanMerged, ndim)
79sample = getUnifRand(-1., +1., ndim, ub(nsam))
80sample
81-0.933376551, -0.617475152, +0.333265781, +0.424602151, +0.981680274
82+0.284943223, +0.192029476E-1, +0.234178305E-1, +0.255623579, -0.404457927
83cov(:,:,0) = getCov(sample, dim)
84cov(:,:,0) ! reference
85+0.500078976, -0.113053516
86-0.113053516, +0.609301105E-1
87mean(:,0) = getMean(sample, dim)
88mean(:,0) ! reference
89+0.377393030E-1, +0.357459299E-1
90do isam = 1, nsam
91 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
92 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
93end do
94call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
95covMerged
96+0.500079036, -0.113053493
97+0.148737937, +0.609301105E-1
98call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), lowDia)
99covMerged
100+0.500079036, -0.113053493
101-0.113053493, +0.609301105E-1
102call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
103cov(:,:,2)
104+0.500079036, -0.113053493
105-0.919292420E-1, +0.609301105E-1
106cov(:,:,0) ! reference
107+0.500078976, -0.113053516
108-0.113053516, +0.609301105E-1
109
110
111dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
112do isam = 2, nsam
113 lb(isam) = ub(isam - 1) + 1
114 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
115end do
116lb
117+1, +6
118ub
119+5, +8
120ndim = getUnifRand(1, minval(ub - lb + 1, 1))
121call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
122call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
123call setResized(covMerged, [ndim, ndim])
124call setResized(meanMerged, ndim)
125sample = getUnifRand(-1., +1., ndim, ub(nsam))
126sample
127-0.852448106, +0.999969959, +0.409474015, +0.880648136, +0.545521259, +0.311303377, -0.891739368, +0.500106335
128cov(:,:,0) = getCov(sample, dim)
129cov(:,:,0) ! reference
130+0.457128644
131mean(:,0) = getMean(sample, dim)
132mean(:,0) ! reference
133+0.237854451
134do isam = 1, nsam
135 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
136 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
137end do
138call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
139covMerged
140+0.457128614
141call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), lowDia)
142covMerged
143+0.457128614
144call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
145cov(:,:,2)
146+0.457128614
147cov(:,:,0) ! reference
148+0.457128644
149
150
151dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
152do isam = 2, nsam
153 lb(isam) = ub(isam - 1) + 1
154 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
155end do
156lb
157+1, +7
158ub
159+6, +9
160ndim = getUnifRand(1, minval(ub - lb + 1, 1))
161call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
162call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
163call setResized(covMerged, [ndim, ndim])
164call setResized(meanMerged, ndim)
165sample = getUnifRand(-1., +1., ndim, ub(nsam))
166sample
167+0.482845068, -0.122419000, -0.300304055, +0.281539440, -0.153982520, -0.385295630, -0.587049723, -0.145734072, -0.779858232
168-0.695247650, +0.518956661, -0.640314460, -0.472386479, -0.694907904, -0.731938362, +0.158470869, +0.640313983, -0.668274999
169+0.823003411, +0.216121078, +0.913636923, -0.416251779, -0.134503365, +0.778416634, +0.518478274, -0.927660704, +0.608380556
170cov(:,:,0) = getCov(sample, dim)
171cov(:,:,0) ! reference
172+0.137642547, -0.119322138E-1, -0.545865186E-1
173-0.119322138E-1, +0.282612920, -0.173281297
174-0.545865186E-1, -0.173281297, +0.358487576
175mean(:,0) = getMean(sample, dim)
176mean(:,0) ! reference
177-0.190028742, -0.287258714, +0.264402330
178do isam = 1, nsam
179 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
180 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
181end do
182call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
183covMerged
184+0.137642503, -0.119322240E-1, -0.545865148E-1
185+0.00000000, +0.282612920, -0.173281282
186+0.00000000, +0.00000000, +0.358487517
187call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), lowDia)
188covMerged
189+0.137642503, -0.119322240E-1, -0.545865148E-1
190-0.119322240E-1, +0.282612920, -0.173281282
191-0.545865148E-1, -0.173281282, +0.358487517
192call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
193cov(:,:,2)
194+0.137642503, -0.119322240E-1, -0.545865148E-1
195+0.133539617, +0.282612920, -0.173281282
196-0.181064278, -0.309020579, +0.358487517
197cov(:,:,0) ! reference
198+0.137642547, -0.119322138E-1, -0.545865186E-1
199-0.119322138E-1, +0.282612920, -0.173281297
200-0.545865186E-1, -0.173281297, +0.358487576
201
202
203dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
204do isam = 2, nsam
205 lb(isam) = ub(isam - 1) + 1
206 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
207end do
208lb
209+1, +7
210ub
211+6, +12
212ndim = getUnifRand(1, minval(ub - lb + 1, 1))
213call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
214call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
215call setResized(covMerged, [ndim, ndim])
216call setResized(meanMerged, ndim)
217sample = getUnifRand(-1., +1., ndim, ub(nsam))
218sample
219-0.691641569, -0.338720798, -0.409465075, +0.768656611, -0.855988383, +0.684281945, +0.767985821, +0.817631960, +0.542664528E-2, -0.348792195, +0.555361390, -0.222706914
220+0.709180355, +0.275342107, +0.643460631, -0.500606894, +0.326210976, -0.109436512E-1, +0.666172028, +0.327508688, -0.572234869, +0.228335500, -0.421917915, -0.511809230
221-0.694199562, -0.912366152, -0.289777637, +0.371205211, -0.164107680, +0.453360796, -0.230311155, +0.568914771, -0.774578929, -0.422897577, -0.689661264, -0.463103771
222-0.997918129, -0.192276955, +0.413474917, +0.848413825, -0.848082066, -0.267962098, +0.716509938, +0.585188389, +0.645674586, -0.830441952, -0.434357047, -0.787943602
223+0.629280567, -0.815215230, +0.853885293, +0.560186505, -0.386650205, -0.862288237, +0.665596724E-1, -0.299691439, +0.720275640E-1, -0.398051262, +0.938534141, +0.493514180
224cov(:,:,0) = getCov(sample, dim)
225cov(:,:,0) ! reference
226+0.353827566, -0.844269991E-1, +0.166139826, +0.258919656, -0.271550822E-2
227-0.844269991E-1, +0.217387483, +0.390364742E-2, -0.321335420E-1, -0.452198014E-1
228+0.166139826, +0.390364742E-2, +0.227942437, +0.121106312, -0.648786277E-1
229+0.258919656, -0.321335420E-1, +0.121106312, +0.448029518, +0.375481062E-1
230-0.271550822E-2, -0.452198014E-1, -0.648786277E-1, +0.375481062E-1, +0.359859467
231mean(:,0) = getMean(sample, dim)
232mean(:,0) ! reference
233+0.610024557E-1, +0.965581462E-1, -0.270626932, -0.958100185E-1, +0.710076317E-1
234do isam = 1, nsam
235 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
236 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
237end do
238call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
239covMerged
240+0.353827566, -0.844271109E-1, +0.166139841, +0.258919686, -0.271555968E-2
241-0.119322240E-1, +0.217387527, +0.390359573E-2, -0.321335718E-1, -0.452198125E-1
242-0.545865148E-1, -0.173281282, +0.227942482, +0.121106312, -0.648786873E-1
243+0.00000000, +0.00000000, +0.00000000, +0.448029399, +0.375480913E-1
244+0.00000000, +0.00000000, +0.00000000, +0.00000000, +0.359859496
245call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), lowDia)
246covMerged
247+0.353827566, -0.844271109E-1, +0.166139841, +0.258919686, -0.271555968E-2
248-0.844271109E-1, +0.217387527, +0.390359573E-2, -0.321335718E-1, -0.452198125E-1
249+0.166139841, +0.390359573E-2, +0.227942482, +0.121106312, -0.648786873E-1
250+0.258919686, -0.321335718E-1, +0.121106312, +0.448029399, +0.375480913E-1
251-0.271555968E-2, -0.452198125E-1, -0.648786873E-1, +0.375480913E-1, +0.359859496
252call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
253cov(:,:,2)
254+0.353827566, -0.844271109E-1, +0.166139841, +0.258919686, -0.271555968E-2
255+0.108473778, +0.217387527, +0.390359573E-2, -0.321335718E-1, -0.452198125E-1
256+0.113289356, +0.135396361, +0.227942482, +0.121106312, -0.648786873E-1
257+0.213967770, +0.115238190, +0.108016565, +0.448029399, +0.375480913E-1
258+0.212505721E-1, -0.132196307, -0.109407678, -0.886352062E-1, +0.359859496
259cov(:,:,0) ! reference
260+0.353827566, -0.844269991E-1, +0.166139826, +0.258919656, -0.271550822E-2
261-0.844269991E-1, +0.217387483, +0.390364742E-2, -0.321335420E-1, -0.452198014E-1
262+0.166139826, +0.390364742E-2, +0.227942437, +0.121106312, -0.648786277E-1
263+0.258919656, -0.321335420E-1, +0.121106312, +0.448029518, +0.375481062E-1
264-0.271550822E-2, -0.452198014E-1, -0.648786277E-1, +0.375481062E-1, +0.359859467
265
266
267dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
268do isam = 2, nsam
269 lb(isam) = ub(isam - 1) + 1
270 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
271end do
272lb
273+1, +3
274ub
275+2, +7
276ndim = getUnifRand(1, minval(ub - lb + 1, 1))
277call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
278call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
279call setResized(covMerged, [ndim, ndim])
280call setResized(meanMerged, ndim)
281sample = getUnifRand(-1., +1., ndim, ub(nsam))
282sample
283-0.682912946, -0.472841859, +0.986112237, -0.530444503, -0.537260532, +0.549008489, -0.503179908
284+0.701766014E-1, -0.239465237, -0.737786293, +0.463063836, +0.937633038, +0.941482425, -0.950945735
285cov(:,:,0) = getCov(sample, dim)
286cov(:,:,0) ! reference
287+0.369167209, -0.476896502E-1
288-0.476896502E-1, +0.493911564
289mean(:,0) = getMean(sample, dim)
290mean(:,0) ! reference
291-0.170217007, +0.691655204E-1
292do isam = 1, nsam
293 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
294 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
295end do
296call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
297covMerged
298+0.369167328, -0.476896167E-1
299-0.844271109E-1, +0.493911564
300call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), lowDia)
301covMerged
302+0.369167328, -0.476896167E-1
303-0.476896167E-1, +0.493911564
304call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
305cov(:,:,2)
306+0.369167328, -0.476896167E-1
307-0.953740105E-1, +0.493911564
308cov(:,:,0) ! reference
309+0.369167209, -0.476896502E-1
310-0.476896502E-1, +0.493911564
311
312
313dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
314do isam = 2, nsam
315 lb(isam) = ub(isam - 1) + 1
316 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
317end do
318lb
319+1, +4
320ub
321+3, +7
322ndim = getUnifRand(1, minval(ub - lb + 1, 1))
323call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
324call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
325call setResized(covMerged, [ndim, ndim])
326call setResized(meanMerged, ndim)
327sample = getUnifRand(-1., +1., ndim, ub(nsam))
328sample
329-0.561617136, +0.375880361, -0.673499346, +0.408841968, +0.787211657, -0.290076256, +0.898340940
330+0.627154708, +0.172219396, -0.114531636, +0.664874673, +0.453838229, -0.913095474, +0.485044718E-1
331-0.938320637, -0.773239017, -0.515133500, -0.879667282, -0.734491110, -0.872322321E-1, -0.402647376
332cov(:,:,0) = getCov(sample, dim)
333cov(:,:,0) ! reference
334+0.351531297, +0.857736096E-1, -0.151831936E-1
335+0.857736096E-1, +0.256324708, -0.134258971
336-0.151831936E-1, -0.134258971, +0.782019794E-1
337mean(:,0) = getMean(sample, dim)
338mean(:,0) ! reference
339+0.135011747, +0.134137779, -0.618675947
340do isam = 1, nsam
341 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
342 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
343end do
344call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
345covMerged
346+0.351531237, +0.857735798E-1, -0.151831843E-1
347-0.476896167E-1, +0.256324679, -0.134258956
348+0.00000000, +0.363403797, +0.782019943E-1
349call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), lowDia)
350covMerged
351+0.351531237, +0.857735798E-1, -0.151831843E-1
352+0.857735798E-1, +0.256324679, -0.134258956
353-0.151831843E-1, -0.134258956, +0.782019943E-1
354call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
355cov(:,:,2)
356+0.351531237, +0.857735798E-1, -0.151831843E-1
357+0.205726773, +0.256324679, -0.134258956
358-0.812917352E-1, -0.181104228, +0.782019943E-1
359cov(:,:,0) ! reference
360+0.351531297, +0.857736096E-1, -0.151831936E-1
361+0.857736096E-1, +0.256324708, -0.134258971
362-0.151831936E-1, -0.134258971, +0.782019794E-1
363
364
365dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
366do isam = 2, nsam
367 lb(isam) = ub(isam - 1) + 1
368 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
369end do
370lb
371+1, +5
372ub
373+4, +8
374ndim = getUnifRand(1, minval(ub - lb + 1, 1))
375call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
376call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
377call setResized(covMerged, [ndim, ndim])
378call setResized(meanMerged, ndim)
379sample = getUnifRand(-1., +1., ndim, ub(nsam))
380sample
381+0.837372541, +0.629957914, +0.381481886, +0.976212025E-1, +0.485449672, -0.911913514, +0.552992463, -0.239327431
382+0.646268964, -0.182771564, -0.915897250, -0.937613130, -0.254046082, -0.460657716, -0.831046462, +0.540019274E-1
383-0.864213586, +0.658664584, -0.476663947, -0.694015265, -0.893869758, +0.299902797, +0.658563972, -0.110039115
384-0.959608197, +0.243432522, -0.494021058, +0.105207562, +0.330160737, +0.338303566, -0.855590582, +0.200062275
385cov(:,:,0) = getCov(sample, dim)
386cov(:,:,0) ! reference
387+0.282893270, +0.587349534E-1, -0.686714947E-1, -0.155915797
388+0.587349534E-1, +0.262660980, -0.710037947E-1, -0.277611613E-1
389-0.686714947E-1, -0.710037947E-1, +0.371460855, +0.223635435E-1
390-0.155915797, -0.277611613E-1, +0.223635435E-1, +0.260209501
391mean(:,0) = getMean(sample, dim)
392mean(:,0) ! reference
393+0.229204357, -0.360220194, -0.177708790, -0.136506647
394do isam = 1, nsam
395 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
396 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
397end do
398call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
399covMerged
400+0.282893360, +0.587349124E-1, -0.686714947E-1, -0.155915767
401+0.857735798E-1, +0.262660682, -0.710036531E-1, -0.277609397E-1
402-0.151831843E-1, -0.134258956, +0.371460795, +0.223634206E-1
403+0.00000000, -0.205980837, +0.965581462E-1, +0.260209441
404call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), lowDia)
405covMerged
406+0.282893360, +0.587349124E-1, -0.686714947E-1, -0.155915767
407+0.587349124E-1, +0.262660682, -0.710036531E-1, -0.277609397E-1
408-0.686714947E-1, -0.710036531E-1, +0.371460795, +0.223634206E-1
409-0.155915767, -0.277609397E-1, +0.223634206E-1, +0.260209441
410call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
411cov(:,:,2)
412+0.282893360, +0.587349124E-1, -0.686714947E-1, -0.155915767
413-0.544500016E-1, +0.262660682, -0.710036531E-1, -0.277609397E-1
414-0.795448422E-1, -0.120313771, +0.371460795, +0.223634206E-1
415-0.167219460, +0.121736348, -0.194747835, +0.260209441
416cov(:,:,0) ! reference
417+0.282893270, +0.587349534E-1, -0.686714947E-1, -0.155915797
418+0.587349534E-1, +0.262660980, -0.710037947E-1, -0.277611613E-1
419-0.686714947E-1, -0.710037947E-1, +0.371460855, +0.223635435E-1
420-0.155915797, -0.277611613E-1, +0.223635435E-1, +0.260209501
421
422
423dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
424do isam = 2, nsam
425 lb(isam) = ub(isam - 1) + 1
426 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
427end do
428lb
429+1, +7
430ub
431+6, +13
432ndim = getUnifRand(1, minval(ub - lb + 1, 1))
433call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
434call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
435call setResized(covMerged, [ndim, ndim])
436call setResized(meanMerged, ndim)
437sample = getUnifRand(-1., +1., ndim, ub(nsam))
438sample
439-0.482158661E-1, -0.966465235, -0.533014297, -0.916833997, +0.535360336, -0.842154264, -0.492914438, +0.233028293, +0.458183289E-1, +0.916609287, -0.732045770, -0.989500642, -0.186408281
440+0.464743733, -0.117652297, -0.245836973E-1, +0.862036467, -0.534664512, -0.691024423, -0.909916162, +0.657994866, -0.321883798, -0.226676702, +0.196818590, -0.659555197, -0.149192214
441-0.949039340, -0.614194632, -0.374286652, -0.831207991, +0.393341064, +0.843568683, -0.290917039, +0.921784759, +0.683548450, -0.301113963, +0.753409028, -0.180672288, +0.518642426
442-0.276767135, +0.164960146, +0.689949036, +0.365379930, +0.923110843, -0.926342130, +0.915016890, +0.530890107, -0.194544792E-1, +0.302486420E-1, -0.871881485, +0.113889217, -0.338071108
443-0.744399786, +0.378924370, -0.468488932, +0.167960644, -0.965648651, -0.281494617, +0.751441598, -0.564488769, -0.894801378, -0.677835464, -0.420681953, +0.610504508, -0.130862594
444cov(:,:,0) = getCov(sample, dim)
445cov(:,:,0) ! reference
446+0.348438263, +0.621563662E-2, +0.708016306E-1, +0.855041444E-1, -0.226276129
447+0.621563662E-2, +0.268177003, -0.689049885E-1, -0.183181036E-1, -0.742394403E-1
448+0.708016306E-1, -0.689049885E-1, +0.408575147, -0.117561162, -0.123588197
449+0.855041444E-1, -0.183181036E-1, -0.117561162, +0.330864280, +0.435081646E-1
450-0.226276129, -0.742394403E-1, -0.123588197, +0.435081646E-1, +0.296918184
451mean(:,0) = getMean(sample, dim)
452mean(:,0) ! reference
453-0.305902809, -0.111811951, +0.440663397E-1, +0.100071415, -0.249220863
454do isam = 1, nsam
455 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
456 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
457end do
458call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
459covMerged
460+0.348438263, +0.621564221E-2, +0.708016753E-1, +0.855041221E-1, -0.226276144
461+0.587349124E-1, +0.268177003, -0.689050108E-1, -0.183180980E-1, -0.742394626E-1
462-0.686714947E-1, -0.710036531E-1, +0.408574969, -0.117561154, -0.123588204
463-0.155915767, -0.277609397E-1, +0.223634206E-1, +0.330864251, +0.435081869E-1
464-0.271555968E-2, -0.452198125E-1, -0.648786873E-1, +0.375480913E-1, +0.296918303
465call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), lowDia)
466covMerged
467+0.348438263, +0.621564221E-2, +0.708016753E-1, +0.855041221E-1, -0.226276144
468+0.621564128E-2, +0.268177003, -0.689050108E-1, -0.183180980E-1, -0.742394626E-1
469+0.708016753E-1, -0.689050108E-1, +0.408574969, -0.117561154, -0.123588204
470+0.855041221E-1, -0.183180980E-1, -0.117561154, +0.330864251, +0.435081869E-1
471-0.226276144, -0.742394626E-1, -0.123588204, +0.435081832E-1, +0.296918303
472call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
473cov(:,:,2)
474+0.348438263, +0.621564221E-2, +0.708016753E-1, +0.855041221E-1, -0.226276144
475+0.960659012E-1, +0.268177003, -0.689050108E-1, -0.183180980E-1, -0.742394626E-1
476+0.930104987E-3, +0.190601498, +0.408574969, -0.117561154, -0.123588204
477+0.500296392E-1, -0.867676809E-1, -0.108637750, +0.330864251, +0.435081869E-1
478-0.237779185, -0.192448631, -0.177527472, +0.133387432, +0.296918303
479cov(:,:,0) ! reference
480+0.348438263, +0.621563662E-2, +0.708016306E-1, +0.855041444E-1, -0.226276129
481+0.621563662E-2, +0.268177003, -0.689049885E-1, -0.183181036E-1, -0.742394403E-1
482+0.708016306E-1, -0.689049885E-1, +0.408575147, -0.117561162, -0.123588197
483+0.855041444E-1, -0.183181036E-1, -0.117561162, +0.330864280, +0.435081646E-1
484-0.226276129, -0.742394403E-1, -0.123588197, +0.435081646E-1, +0.296918184
485
486
487dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
488do isam = 2, nsam
489 lb(isam) = ub(isam - 1) + 1
490 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
491end do
492lb
493+1, +7
494ub
495+6, +13
496ndim = getUnifRand(1, minval(ub - lb + 1, 1))
497call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
498call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
499call setResized(covMerged, [ndim, ndim])
500call setResized(meanMerged, ndim)
501sample = getUnifRand(-1., +1., ndim, ub(nsam))
502sample
503-0.467836738, +0.213333845, +0.447243452E-1, -0.991155148, -0.337496877, +0.323708296, -0.208257675, +0.483616710, +0.545839548, +0.676100373, -0.464686513, -0.266594291, +0.916165829
504+0.466560125, -0.375170708E-1, +0.534408331, +0.429911017, +0.501823068, +0.877427936, -0.940223098, -0.624384999, +0.793041945, -0.471326470, +0.422169685, +0.705943227, -0.624538064
505+0.371526480E-1, +0.356992364, +0.265710592, -0.813974142E-1, +0.172747254, -0.275851130, +0.238473415, +0.674963951, -0.410033464, -0.745040894, -0.834289193, +0.561887026, +0.715548396
506+0.897610188, -0.556929588, -0.655685663, +0.195357919, -0.982787609, -0.655648708, -0.440299749, -0.218513250, +0.820313454, -0.248515606E-2, +0.950882792, +0.740228295, +0.119511127
507+0.509435296, -0.742669463, -0.847878814, -0.836725354, +0.227827311, +0.130081892, -0.129153728E-1, -0.650998712, +0.465313196E-1, +0.880343914E-1, +0.168287039, +0.649148703, +0.934236646
508+0.886109471, +0.880077958, +0.692146301, +0.364983559, -0.871842861, +0.806062102, +0.542632341E-1, +0.499251008, +0.540310144, +0.405249476, +0.570945382, +0.266824603, -0.482262373E-1
509cov(:,:,0) = getCov(sample, dim)
510cov(:,:,0) ! reference
511+0.277640641, -0.118110351, +0.324673429E-1, -0.574979447E-1, +0.576479100E-1, +0.180420522E-1
512-0.118110351, +0.352673531, -0.901832804E-1, +0.863993540E-1, +0.721931504E-2, +0.555351153E-1
513+0.324673429E-1, -0.901832804E-1, +0.233551517, -0.949527621E-1, -0.128015771E-2, -0.514511541E-1
514-0.574979447E-1, +0.863993540E-1, -0.949527621E-1, +0.412092298, +0.145980760, +0.932936370E-1
515+0.576479100E-1, +0.721931504E-2, -0.128015771E-2, +0.145980760, +0.311272562, -0.844482332E-1
516+0.180420522E-1, +0.555351153E-1, -0.514511541E-1, +0.932936370E-1, -0.844482332E-1, +0.210074365
517mean(:,0) = getMean(sample, dim)
518mean(:,0) ! reference
519+0.359585956E-1, +0.156407356, +0.520664304E-1, +0.162733793E-1, -0.259696264E-1, +0.388165683
520do isam = 1, nsam
521 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
522 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
523end do
524call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
525covMerged
526+0.277640641, -0.118110374, +0.324673392E-1, -0.574979261E-1, +0.576478839E-1, +0.180420578E-1
527+0.621564128E-2, +0.352673501, -0.901832730E-1, +0.863993466E-1, +0.721932575E-2, +0.555351451E-1
528+0.708016753E-1, -0.689050108E-1, +0.233551502, -0.949527696E-1, -0.128013780E-2, -0.514511466E-1
529+0.855041221E-1, -0.183180980E-1, -0.117561154, +0.412092179, +0.145980835, +0.932936817E-1
530-0.226276144, -0.742394626E-1, -0.123588204, +0.435081832E-1, +0.311272591, -0.844481736E-1
531+0.00000000, +0.00000000, +0.00000000, +0.00000000, +0.00000000, +0.210074365
532call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), lowDia)
533covMerged
534+0.277640641, -0.118110374, +0.324673392E-1, -0.574979261E-1, +0.576478839E-1, +0.180420578E-1
535-0.118110366, +0.352673501, -0.901832730E-1, +0.863993466E-1, +0.721932575E-2, +0.555351451E-1
536+0.324673392E-1, -0.901832730E-1, +0.233551502, -0.949527696E-1, -0.128013780E-2, -0.514511466E-1
537-0.574979261E-1, +0.863993391E-1, -0.949527696E-1, +0.412092179, +0.145980835, +0.932936817E-1
538+0.576478802E-1, +0.721932575E-2, -0.128013780E-2, +0.145980820, +0.311272591, -0.844481736E-1
539+0.180420596E-1, +0.555351451E-1, -0.514511466E-1, +0.932936817E-1, -0.844481736E-1, +0.210074365
540call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(ub(1), TKG) / real(ub(2), TKG), uppDia)
541cov(:,:,2)
542+0.277640641, -0.118110374, +0.324673392E-1, -0.574979261E-1, +0.576478839E-1, +0.180420578E-1
543-0.110119313, +0.352673501, -0.901832730E-1, +0.863993466E-1, +0.721932575E-2, +0.555351451E-1
544+0.563211367E-1, -0.142975330, +0.233551502, -0.949527696E-1, -0.128013780E-2, -0.514511466E-1
545-0.815628991E-1, +0.322787285, -0.133651912, +0.412092179, +0.145980835, +0.932936817E-1
546+0.119558666E-1, +0.698521137E-1, +0.472147837E-1, +0.848781988E-1, +0.311272591, -0.844481736E-1
547-0.187932253E-1, +0.822819844E-1, -0.857649818E-1, +0.571310557E-1, -0.628988147E-1, +0.210074365
548cov(:,:,0) ! reference
549+0.277640641, -0.118110351, +0.324673429E-1, -0.574979447E-1, +0.576479100E-1, +0.180420522E-1
550-0.118110351, +0.352673531, -0.901832804E-1, +0.863993540E-1, +0.721931504E-2, +0.555351153E-1
551+0.324673429E-1, -0.901832804E-1, +0.233551517, -0.949527621E-1, -0.128015771E-2, -0.514511541E-1
552-0.574979447E-1, +0.863993540E-1, -0.949527621E-1, +0.412092298, +0.145980760, +0.932936370E-1
553+0.576479100E-1, +0.721931504E-2, -0.128015771E-2, +0.145980760, +0.311272562, -0.844482332E-1
554+0.180420522E-1, +0.555351153E-1, -0.514511541E-1, +0.932936370E-1, -0.844482332E-1, +0.210074365
555
556
557!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
558!Compute the biased merged covariance of a frequency weighted multivariate sample.
559!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
560
561
562dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
563do isam = 2, nsam
564 lb(isam) = ub(isam - 1) + 1
565 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
566end do
567lb
568+1, +3
569ub
570+2, +9
571ndim = getUnifRand(1, minval(ub - lb + 1, 1))
572call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
573call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
574call setResized(covMerged, [ndim, ndim])
575call setResized(meanMerged, ndim)
576sample = getUnifRand(-1., +1., ndim, ub(nsam))
577sample
578+0.143622279, -0.691289425, +0.802574277, -0.318239212, -0.133623123, +0.399448037, -0.936397791, +0.530570269, -0.207484126
579+0.171091318, +0.536007047, +0.340320230, -0.139461756E-1, +0.107171059, +0.376647830, -0.336355686, +0.552503347, -0.994741917E-2
580iweight = getUnifRand(1, 10, size(sample, dim, IK))
581iweight
582+4, +2, +8, +1, +2, +2, +8, +3, +7
583cov(:,:,0) = getCov(sample, dim, iweight)
584cov(:,:,0) ! reference
585+0.398514509, +0.146246314
586+0.146246314, +0.875685662E-1
587mean(:,0) = getMean(sample, dim, iweight)
588mean(:,0) ! reference
589-0.412417613E-1, +0.117017969
590do isam = 1, nsam
591 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim, iweight(lb(isam):ub(isam)))
592 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim, iweight(lb(isam):ub(isam)))
593end do
594call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), uppDia)
595covMerged
596+0.398514599, +0.146246314
597+0.309644922E-40, +0.875685588E-1
598call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), lowDia)
599covMerged
600+0.398514599, +0.146246314
601+0.146246314, +0.875685588E-1
602call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), uppDia)
603cov(:,:,2)
604+0.398514599, +0.146246314
605+0.191449076, +0.875685588E-1
606cov(:,:,0) ! reference
607+0.398514509, +0.146246314
608+0.146246314, +0.875685662E-1
609
610
611dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
612do isam = 2, nsam
613 lb(isam) = ub(isam - 1) + 1
614 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
615end do
616lb
617+1, +5
618ub
619+4, +6
620ndim = getUnifRand(1, minval(ub - lb + 1, 1))
621call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
622call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
623call setResized(covMerged, [ndim, ndim])
624call setResized(meanMerged, ndim)
625sample = getUnifRand(-1., +1., ndim, ub(nsam))
626sample
627-0.795607328, +0.762604833, -0.657132268, +0.611700654, -0.366850853, -0.493130684E-1
628+0.979378343, +0.539112926, -0.265010715, -0.979659200, +0.100330472, -0.852316499
629iweight = getUnifRand(1, 10, size(sample, dim, IK))
630iweight
631+1, +1, +1, +10, +9, +1
632cov(:,:,0) = getCov(sample, dim, iweight)
633cov(:,:,0) ! reference
634+0.278888702, -0.248227328
635-0.248227328, +0.373855591
636mean(:,0) = getMean(sample, dim, iweight)
637mean(:,0) ! reference
638+0.902565494E-1, -0.369237125
639do isam = 1, nsam
640 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim, iweight(lb(isam):ub(isam)))
641 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim, iweight(lb(isam):ub(isam)))
642end do
643call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), uppDia)
644covMerged
645+0.278888702, -0.248227268
646+0.146246314, +0.373855650
647call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), lowDia)
648covMerged
649+0.278888702, -0.248227268
650-0.248227268, +0.373855650
651call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), uppDia)
652cov(:,:,2)
653+0.278888702, -0.248227268
654-0.272251274E-1, +0.373855650
655cov(:,:,0) ! reference
656+0.278888702, -0.248227328
657-0.248227328, +0.373855591
658
659
660dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
661do isam = 2, nsam
662 lb(isam) = ub(isam - 1) + 1
663 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
664end do
665lb
666+1, +3
667ub
668+2, +5
669ndim = getUnifRand(1, minval(ub - lb + 1, 1))
670call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
671call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
672call setResized(covMerged, [ndim, ndim])
673call setResized(meanMerged, ndim)
674sample = getUnifRand(-1., +1., ndim, ub(nsam))
675sample
676-0.483086109, +0.980264068, +0.174478531, -0.691427827, -0.728550553
677+0.455371499, +0.948888183, -0.921891212, -0.882871151E-1, +0.351266980
678iweight = getUnifRand(1, 10, size(sample, dim, IK))
679iweight
680+6, +5, +6, +7, +3
681cov(:,:,0) = getCov(sample, dim, iweight)
682cov(:,:,0) ! reference
683+0.397809237, +0.880000591E-1
684+0.880000591E-1, +0.409635693
685mean(:,0) = getMean(sample, dim, iweight)
686mean(:,0) ! reference
687-0.147258207, +0.881894082E-1
688do isam = 1, nsam
689 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim, iweight(lb(isam):ub(isam)))
690 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim, iweight(lb(isam):ub(isam)))
691end do
692call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), uppDia)
693covMerged
694+0.397809207, +0.880000517E-1
695-0.248227268, +0.409635663
696call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), lowDia)
697covMerged
698+0.397809207, +0.880000517E-1
699+0.880000517E-1, +0.409635663
700call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), uppDia)
701cov(:,:,2)
702+0.397809207, +0.880000517E-1
703-0.200600892, +0.409635663
704cov(:,:,0) ! reference
705+0.397809237, +0.880000591E-1
706+0.880000591E-1, +0.409635693
707
708
709dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
710do isam = 2, nsam
711 lb(isam) = ub(isam - 1) + 1
712 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
713end do
714lb
715+1, +8
716ub
717+7, +12
718ndim = getUnifRand(1, minval(ub - lb + 1, 1))
719call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
720call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
721call setResized(covMerged, [ndim, ndim])
722call setResized(meanMerged, ndim)
723sample = getUnifRand(-1., +1., ndim, ub(nsam))
724sample
725-0.538747907, -0.712080956, +0.641097069, +0.989222407, +0.512566328, +0.289221168, -0.148916245, -0.790004969, -0.199229836, +0.250847101, -0.585680962, -0.437396407
726+0.784807324, -0.101656556, +0.979553580, +0.368613601, +0.489375830, +0.159325361, -0.572312474, -0.205666423, -0.160999656, +0.235195756, -0.196423411, -0.472108722
727-0.609753132, -0.984997511, -0.878700852, +0.623722792, +0.986507773, +0.779661179, -0.562969089, -0.713206530, +0.852186441, -0.232910037, -0.962665558, -0.240844607
728+0.859571934, -0.607070446, -0.583140731, +0.150378585, -0.405737042, +0.489415050, +0.439680099, +0.624104857, -0.637497187, -0.799849272, +0.989638805, -0.120074868
729-0.528232455, +0.616743803, -0.980387688, -0.265039206E-1, +0.144208312, -0.301153898, -0.623649836, -0.359984398, +0.145144463, +0.857237101, +0.825942397, -0.683146834
730iweight = getUnifRand(1, 10, size(sample, dim, IK))
731iweight
732+7, +8, +4, +8, +4, +5, +3, +10, +3, +5, +9, +7
733cov(:,:,0) = getCov(sample, dim, iweight)
734cov(:,:,0) ! reference
735+0.361379951, +0.137051553, +0.292993367, -0.125250757, -0.388979204E-1
736+0.137051553, +0.185666651, +0.600162670E-1, -0.266295653E-1, -0.489308089E-1
737+0.292993367, +0.600162670E-1, +0.478267878, -0.966908187E-1, -0.472666211E-1
738-0.125250757, -0.266295653E-1, -0.966908187E-1, +0.380761862, -0.473377295E-1
739-0.388979204E-1, -0.489308089E-1, -0.472666211E-1, -0.473377295E-1, +0.341630608
740mean(:,0) = getMean(sample, dim, iweight)
741mean(:,0) ! reference
742-0.157760277, +0.842254683E-1, -0.282298654, +0.144789174, -0.263550114E-1
743do isam = 1, nsam
744 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim, iweight(lb(isam):ub(isam)))
745 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim, iweight(lb(isam):ub(isam)))
746end do
747call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), uppDia)
748covMerged
749+0.361379981, +0.137051538, +0.292993367, -0.125250801, -0.388979279E-1
750+0.880000517E-1, +0.185666680, +0.600163043E-1, -0.266295448E-1, -0.489307679E-1
751+0.00000000, -0.689050108E-1, +0.478267878, -0.966908783E-1, -0.472666360E-1
752+0.00000000, -0.183180980E-1, -0.117561154, +0.380761981, -0.473376848E-1
753-0.226276144, -0.742394626E-1, -0.123588204, +0.435081832E-1, +0.341630608
754call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), lowDia)
755covMerged
756+0.361379981, +0.137051538, +0.292993367, -0.125250801, -0.388979279E-1
757+0.137051538, +0.185666680, +0.600163043E-1, -0.266295448E-1, -0.489307679E-1
758+0.292993367, +0.600163043E-1, +0.478267878, -0.966908783E-1, -0.472666360E-1
759-0.125250801, -0.266295448E-1, -0.966908783E-1, +0.380761981, -0.473376848E-1
760-0.388979241E-1, -0.489307642E-1, -0.472666360E-1, -0.473376848E-1, +0.341630608
761call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), uppDia)
762cov(:,:,2)
763+0.361379981, +0.137051538, +0.292993367, -0.125250801, -0.388979279E-1
764+0.455358177E-1, +0.185666680, +0.600163043E-1, -0.266295448E-1, -0.489307679E-1
765+0.962752774E-1, +0.685919914E-2, +0.478267878, -0.966908783E-1, -0.472666360E-1
766-0.192801788, -0.494016409E-1, -0.280830115, +0.380761981, -0.473376848E-1
767+0.970276967E-1, +0.938282534E-1, -0.670118630E-1, +0.307758562E-1, +0.341630608
768cov(:,:,0) ! reference
769+0.361379951, +0.137051553, +0.292993367, -0.125250757, -0.388979204E-1
770+0.137051553, +0.185666651, +0.600162670E-1, -0.266295653E-1, -0.489308089E-1
771+0.292993367, +0.600162670E-1, +0.478267878, -0.966908187E-1, -0.472666211E-1
772-0.125250757, -0.266295653E-1, -0.966908187E-1, +0.380761862, -0.473377295E-1
773-0.388979204E-1, -0.489308089E-1, -0.472666211E-1, -0.473377295E-1, +0.341630608
774
775
776dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
777do isam = 2, nsam
778 lb(isam) = ub(isam - 1) + 1
779 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
780end do
781lb
782+1, +4
783ub
784+3, +7
785ndim = getUnifRand(1, minval(ub - lb + 1, 1))
786call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
787call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
788call setResized(covMerged, [ndim, ndim])
789call setResized(meanMerged, ndim)
790sample = getUnifRand(-1., +1., ndim, ub(nsam))
791sample
792-0.667372823, +0.465199947E-1, +0.396987200, +0.515209436E-1, -0.748082042, +0.230819583, -0.521903515
793iweight = getUnifRand(1, 10, size(sample, dim, IK))
794iweight
795+5, +4, +2, +6, +1, +8, +2
796cov(:,:,0) = getCov(sample, dim, iweight)
797cov(:,:,0) ! reference
798+0.141266629
799mean(:,0) = getMean(sample, dim, iweight)
800mean(:,0) ! reference
801-0.711791515E-1
802do isam = 1, nsam
803 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim, iweight(lb(isam):ub(isam)))
804 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim, iweight(lb(isam):ub(isam)))
805end do
806call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), uppDia)
807covMerged
808+0.141266674
809call setCovMeanMerged(covMerged, meanMerged, cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), lowDia)
810covMerged
811+0.141266674
812call setCovMeanMerged(cov(:,:,2), mean(:,2), cov(:,:,1), mean(:,1), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG), uppDia)
813cov(:,:,2)
814+0.141266674
815cov(:,:,0) ! reference
816+0.141266629
817
818
819dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
820do isam = 2, nsam
821 lb(isam) = ub(isam - 1) + 1
822 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
823end do
824lb
825+1, +6
826ub
827+5, +8
828ndim = getUnifRand(1, minval(ub - lb + 1, 1))
829call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
830call setRebound(mean, [1_IK, 0_IK], [ndim, nsam])
831call setResized(covMerged, [ndim, ndim])
832call setResized(meanMerged, ndim)
833sample = getUnifRand(-1., +1., ndim, ub(nsam))
834sample
835-0.192716241, +0.261526108E-1, +0.804340124, +0.570011139E-1, -0.409588814E-1, -0.442317486, -0.837724209, +0.784672499
836-0.504324317, +0.428298235, +0.339344859, -0.411368489, -0.732769132, -0.272634983, -0.967671752, +0.168741345
837iweight = getUnifRand(1, 10, size(sample, dim, IK))
838iweight
839+6, +8, +9, +10, +3, +8, +2, +1
840cov(:,:,0) = getCov(sample, dim, iweig