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

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

Detailed Description

Generate and return the merged covariance 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
[in]covB: The input 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.
Only the upper-diagonal triangle of covB is referenced.
[in]covA: The input 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.
Only the upper-diagonal triangle of covA is referenced.
[in]meanDiff: The input vector of the same type and kind as the input argument covA of shape (1:ndim), containing the difference of mean of the two samples meanDiff = meanA - meanB.
The subtraction order is immaterial.
[in]fracA: The input scalar of type real of the same kind as covA, containing the sum of the weights of all points in sample \(A\) divided by the sum of the weights of all points in the merged sample.
If the sample is unweighted, then fracA is simply size(sampleA) / (size(sampleA) + size(sampleB)).
Returns
cov : The output object of the same type and kind and rank and shape as meanDiff, containing the full matrix of biased covariance of the sample resulting form the merger of the two samples.


Possible calling interfaces

cov(1:ndim, 1:ndim) = getCovMerged(covB(1:ndim, 1:ndim), covA(1:ndim, 1:ndim), meanDiff(1:ndim), fracA)
Generate and return the merged covariance of a sample resulting from the merger of two separate (pote...
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(shape(covA) == size(meanDiff)) 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
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(:,:,:), 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, 1_IK], [ndim, nsam])")
54 call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
55 call disp%show("call setResized(covMerged, [ndim, ndim])")
56 call setResized(covMerged, [ndim, ndim])
57 call disp%show("sample = getUnifRand(-1., +1., ndim, ub(nsam))")
58 sample = getUnifRand(-1., +1., ndim, ub(nsam))
59 call disp%show("sample")
60 call disp%show( sample )
61 call disp%show("cov(:,:,0) = getCov(sample, dim)")
62 cov(:,:,0) = getCov(sample, dim)
63 call disp%show("cov(:,:,0) ! reference")
64 call disp%show( cov(:,:,0) )
65 call disp%show("do isam = 1, nsam")
66 call disp%show(" cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)")
67 call disp%show(" mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)")
68 call disp%show("end do")
69 do isam = 1, nsam
70 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
71 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
72 end do
73 call disp%show("covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))")
74 covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
75 call disp%show("covMerged")
76 call disp%show( covMerged )
77 call disp%show("covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))")
78 covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
79 call disp%show("covMerged")
80 call disp%show( covMerged )
81 call disp%show("cov(:,:,0) ! reference")
82 call disp%show( cov(:,:,0) )
83 call disp%skip()
84 end do
85 end block
86
87 call disp%skip()
88 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
89 call disp%show("!Compute the biased merged covariance of a frequency weighted multivariate sample.")
90 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
91 call disp%skip()
92
93 block
94 real(TKG), allocatable :: mean(:,:), cov(:,:,:), covMerged(:,:)
95 real(TKG), allocatable :: sample(:,:)
96 do itry = 1, ntry
97 call disp%skip()
98 call disp%show("dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)")
99 dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
100 call disp%show("do isam = 2, nsam")
101 call disp%show(" lb(isam) = ub(isam - 1) + 1")
102 call disp%show(" ub(isam) = ub(isam - 1) + getUnifRand(2, 7)")
103 call disp%show("end do")
104 do isam = 2, nsam
105 lb(isam) = ub(isam - 1) + 1
106 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
107 end do
108 call disp%show("lb")
109 call disp%show( lb )
110 call disp%show("ub")
111 call disp%show( ub )
112 call disp%show("ndim = getUnifRand(1, minval(ub - lb + 1, 1))")
113 ndim = getUnifRand(1, minval(ub - lb + 1, 1))
114 call disp%show("call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])")
115 call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
116 call disp%show("call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])")
117 call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
118 call disp%show("call setResized(covMerged, [ndim, ndim])")
119 call setResized(covMerged, [ndim, ndim])
120 call disp%show("sample = getUnifRand(-1., +1., ndim, ub(nsam))")
121 sample = getUnifRand(-1., +1., ndim, ub(nsam))
122 call disp%show("sample")
123 call disp%show( sample )
124 call disp%show("iweight = getUnifRand(1, 10, size(sample, dim, IK))")
125 iweight = getUnifRand(1, 10, size(sample, dim, IK))
126 call disp%show("iweight")
127 call disp%show( iweight )
128 call disp%show("cov(:,:,0) = getCov(sample, 2_IK, iweight)")
129 cov(:,:,0) = getCov(sample, 2_IK, iweight)
130 call disp%show("cov(:,:,0) ! reference")
131 call disp%show( cov(:,:,0) )
132 call disp%show("do isam = 1, nsam")
133 call disp%show(" cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))")
134 call disp%show(" mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))")
135 call disp%show("end do")
136 do isam = 1, nsam
137 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
138 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
139 end do
140 call disp%show("covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))")
141 covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
142 call disp%show("covMerged")
143 call disp%show( covMerged )
144 call disp%show("covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))")
145 covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
146 call disp%show("covMerged")
147 call disp%show( covMerged )
148 call disp%show("cov(:,:,0) ! reference")
149 call disp%show( cov(:,:,0) )
150 call disp%skip()
151 end do
152 end block
153
154 call disp%skip()
155 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
156 call disp%show("!Compute the biased merged covariance of a reliability weighted multivariate sample.")
157 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
158 call disp%skip()
159
160 block
161 real(TKG), allocatable :: mean(:,:), cov(:,:,:), covMerged(:,:)
162 real(TKG), allocatable :: sample(:,:)
163 real(TKG), allocatable :: rweight(:)
164 do itry = 1, ntry
165 call disp%skip()
166 call disp%show("dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)")
167 dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
168 call disp%show("do isam = 2, nsam")
169 call disp%show(" lb(isam) = ub(isam - 1) + 1")
170 call disp%show(" ub(isam) = ub(isam - 1) + getUnifRand(2, 7)")
171 call disp%show("end do")
172 do isam = 2, nsam
173 lb(isam) = ub(isam - 1) + 1
174 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
175 end do
176 call disp%show("lb")
177 call disp%show( lb )
178 call disp%show("ub")
179 call disp%show( ub )
180 call disp%show("ndim = getUnifRand(1, minval(ub - lb + 1, 1))")
181 ndim = getUnifRand(1, minval(ub - lb + 1, 1))
182 call disp%show("call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])")
183 call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
184 call disp%show("call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])")
185 call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
186 call disp%show("call setResized(covMerged, [ndim, ndim])")
187 call setResized(covMerged, [ndim, ndim])
188 call disp%show("sample = getUnifRand(-1., +1., ndim, ub(nsam))")
189 sample = getUnifRand(-1., +1., ndim, ub(nsam))
190 call disp%show("sample")
191 call disp%show( sample )
192 call disp%show("rweight = getUnifRand(1., 2., size(sample, dim, IK))")
193 rweight = getUnifRand(1., 2., size(sample, dim, IK))
194 call disp%show("rweight")
195 call disp%show( rweight )
196 call disp%show("cov(:,:,0) = getCov(sample, 2_IK, rweight)")
197 cov(:,:,0) = getCov(sample, 2_IK, rweight)
198 call disp%show("cov(:,:,0) ! reference")
199 call disp%show( cov(:,:,0) )
200 call disp%show("do isam = 1, nsam")
201 call disp%show(" cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))")
202 call disp%show(" mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))")
203 call disp%show("end do")
204 do isam = 1, nsam
205 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
206 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
207 end do
208 call disp%show("covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))")
209 covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
210 call disp%show("covMerged")
211 call disp%show( covMerged )
212 call disp%show("covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))")
213 covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
214 call disp%show("covMerged")
215 call disp%show( covMerged )
216 call disp%show("cov(:,:,0) ! reference")
217 call disp%show( cov(:,:,0) )
218 call disp%skip()
219 end do
220 end block
221
222end 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, +6
14ub
15+5, +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, 1_IK], [ndim, nsam])
19call setResized(covMerged, [ndim, ndim])
20sample = getUnifRand(-1., +1., ndim, ub(nsam))
21sample
22+0.429570913, -0.159322143, -0.673265576, +0.350806952, -0.246362686E-1, -0.692471266E-1, +0.143829226, +0.559189320E-1
23cov(:,:,0) = getCov(sample, dim)
24cov(:,:,0) ! reference
25+0.101890326
26do isam = 1, nsam
27 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
28 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
29end do
30covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
31covMerged
32+0.101890355
33covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
34covMerged
35+0.101890355
36cov(:,:,0) ! reference
37+0.101890326
38
39
40dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
41do isam = 2, nsam
42 lb(isam) = ub(isam - 1) + 1
43 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
44end do
45lb
46+1, +3
47ub
48+2, +5
49ndim = getUnifRand(1, minval(ub - lb + 1, 1))
50call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
51call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
52call setResized(covMerged, [ndim, ndim])
53sample = getUnifRand(-1., +1., ndim, ub(nsam))
54sample
55-0.172460914, +0.342112184, -0.984426498, -0.266106129E-1, -0.363797665
56+0.267987251E-1, -0.267163873, -0.124503851, -0.122181296, -0.962075830
57cov(:,:,0) = getCov(sample, dim)
58cov(:,:,0) ! reference
59+0.191688493, +0.610056240E-2
60+0.610056240E-2, +0.121624149
61do isam = 1, nsam
62 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
63 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
64end do
65covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
66covMerged
67+0.191688508, +0.610056520E-2
68+0.610056520E-2, +0.121624164
69covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
70covMerged
71+0.191688508, +0.610056520E-2
72+0.610056520E-2, +0.121624164
73cov(:,:,0) ! reference
74+0.191688493, +0.610056240E-2
75+0.610056240E-2, +0.121624149
76
77
78dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
79do isam = 2, nsam
80 lb(isam) = ub(isam - 1) + 1
81 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
82end do
83lb
84+1, +8
85ub
86+7, +12
87ndim = getUnifRand(1, minval(ub - lb + 1, 1))
88call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
89call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
90call setResized(covMerged, [ndim, ndim])
91sample = getUnifRand(-1., +1., ndim, ub(nsam))
92sample
93-0.680612326E-1, +0.911749601E-1, -0.935483217, -0.693109989, +0.940469503, +0.619779706, +0.568580747, +0.174072504, +0.601971745, +0.719269991, -0.760108232E-1, -0.163936853
94cov(:,:,0) = getCov(sample, dim)
95cov(:,:,0) ! reference
96+0.303282499
97do isam = 1, nsam
98 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
99 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
100end do
101covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
102covMerged
103+0.303282470
104covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
105covMerged
106+0.303282470
107cov(:,:,0) ! reference
108+0.303282499
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, +4
118ub
119+3, +5
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, 1_IK], [ndim, nsam])
123call setResized(covMerged, [ndim, ndim])
124sample = getUnifRand(-1., +1., ndim, ub(nsam))
125sample
126-0.761229992E-1, +0.200882077, -0.695288539, -0.460221052, +0.836894512
127-0.230059862, +0.340726376, +0.244385481, +0.896156788, -0.869790912
128cov(:,:,0) = getCov(sample, dim)
129cov(:,:,0) ! reference
130+0.286850870, -0.241905019
131-0.241905019, +0.351856738
132do isam = 1, nsam
133 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
134 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
135end do
136covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
137covMerged
138+0.286850870, -0.241905034
139-0.241905034, +0.351856679
140covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
141covMerged
142+0.286850870, -0.241905034
143-0.241905034, +0.351856679
144cov(:,:,0) ! reference
145+0.286850870, -0.241905019
146-0.241905019, +0.351856738
147
148
149dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
150do isam = 2, nsam
151 lb(isam) = ub(isam - 1) + 1
152 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
153end do
154lb
155+1, +5
156ub
157+4, +7
158ndim = getUnifRand(1, minval(ub - lb + 1, 1))
159call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
160call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
161call setResized(covMerged, [ndim, ndim])
162sample = getUnifRand(-1., +1., ndim, ub(nsam))
163sample
164+0.766032696, -0.823078156, +0.385583520, +0.907726169, +0.997477889, -0.319957137, -0.855871081
165cov(:,:,0) = getCov(sample, dim)
166cov(:,:,0) ! reference
167+0.558124542
168do isam = 1, nsam
169 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
170 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
171end do
172covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
173covMerged
174+0.558124542
175covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
176covMerged
177+0.558124542
178cov(:,:,0) ! reference
179+0.558124542
180
181
182dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
183do isam = 2, nsam
184 lb(isam) = ub(isam - 1) + 1
185 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
186end do
187lb
188+1, +8
189ub
190+7, +9
191ndim = getUnifRand(1, minval(ub - lb + 1, 1))
192call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
193call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
194call setResized(covMerged, [ndim, ndim])
195sample = getUnifRand(-1., +1., ndim, ub(nsam))
196sample
197+0.516609550, +0.829818249E-1, -0.110439062, +0.100255013, -0.647843599, +0.318053246, -0.788073540E-1, -0.126292348, +0.550480366
198cov(:,:,0) = getCov(sample, dim)
199cov(:,:,0) ! reference
200+0.122377582
201do isam = 1, nsam
202 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
203 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
204end do
205covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
206covMerged
207+0.122377567
208covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
209covMerged
210+0.122377567
211cov(:,:,0) ! reference
212+0.122377582
213
214
215dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
216do isam = 2, nsam
217 lb(isam) = ub(isam - 1) + 1
218 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
219end do
220lb
221+1, +5
222ub
223+4, +11
224ndim = getUnifRand(1, minval(ub - lb + 1, 1))
225call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
226call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
227call setResized(covMerged, [ndim, ndim])
228sample = getUnifRand(-1., +1., ndim, ub(nsam))
229sample
230+0.251966715E-1, -0.519264221, +0.306243896, +0.553442836, -0.814499974, -0.198294282, +0.594271898, -0.779034972, +0.207129240, -0.156142950, +0.827567577E-1
231-0.795048118, +0.229652524, -0.359532952, -0.591746092, -0.847897649, +0.998247743, +0.936077952, +0.772621632E-1, -0.805044174E-1, -0.603001118, -0.183853269
232-0.993852258, +0.628826618E-1, -0.203975439E-1, +0.224386930, -0.333478451E-1, -0.557775497E-1, +0.560260892, -0.405787706, -0.456952572, +0.975878835, +0.803460121
233cov(:,:,0) = getCov(sample, dim)
234cov(:,:,0) ! reference
235+0.214814156, +0.360619873E-1, +0.553584658E-1
236+0.360619873E-1, +0.366401672, +0.471603237E-1
237+0.553584658E-1, +0.471603237E-1, +0.299294829
238do isam = 1, nsam
239 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
240 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
241end do
242covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
243covMerged
244+0.214814126, +0.360619090E-1, +0.553584583E-1
245+0.360619090E-1, +0.366401672, +0.471602529E-1
246+0.553584583E-1, +0.471602529E-1, +0.299294949
247covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
248covMerged
249+0.214814126, +0.360619090E-1, +0.553584583E-1
250+0.360619090E-1, +0.366401672, +0.471602529E-1
251+0.553584583E-1, +0.471602529E-1, +0.299294949
252cov(:,:,0) ! reference
253+0.214814156, +0.360619873E-1, +0.553584658E-1
254+0.360619873E-1, +0.366401672, +0.471603237E-1
255+0.553584658E-1, +0.471603237E-1, +0.299294829
256
257
258dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
259do isam = 2, nsam
260 lb(isam) = ub(isam - 1) + 1
261 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
262end do
263lb
264+1, +7
265ub
266+6, +9
267ndim = getUnifRand(1, minval(ub - lb + 1, 1))
268call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
269call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
270call setResized(covMerged, [ndim, ndim])
271sample = getUnifRand(-1., +1., ndim, ub(nsam))
272sample
273+0.137661695, +0.320715547, -0.103584886, -0.911270022, -0.738807917E-1, -0.510661364, -0.203518867, -0.668150067, -0.759877086
274+0.463018537, -0.760295987, -0.493802071, +0.898446441, +0.171767473E-1, +0.173208714, +0.518211365, -0.389319539, +0.940451860
275-0.162234664, -0.289150119, +0.342025518, -0.514113903E-2, +0.243459225, +0.907274246, +0.344280124, +0.971591234, +0.542679787
276cov(:,:,0) = getCov(sample, dim)
277cov(:,:,0) ! reference
278+0.160035416, -0.130690426, -0.963266268E-1
279-0.130690426, +0.330075532, +0.370899827E-3
280-0.963266268E-1, +0.370899827E-3, +0.170587540
281do isam = 1, nsam
282 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
283 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
284end do
285covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
286covMerged
287+0.160035387, -0.130690470, -0.963266119E-1
288-0.130690470, +0.330075502, +0.370886177E-3
289-0.963266119E-1, +0.370886177E-3, +0.170587584
290covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
291covMerged
292+0.160035387, -0.130690470, -0.963266119E-1
293-0.130690470, +0.330075502, +0.370886177E-3
294-0.963266119E-1, +0.370886177E-3, +0.170587584
295cov(:,:,0) ! reference
296+0.160035416, -0.130690426, -0.963266268E-1
297-0.130690426, +0.330075532, +0.370899827E-3
298-0.963266268E-1, +0.370899827E-3, +0.170587540
299
300
301dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
302do isam = 2, nsam
303 lb(isam) = ub(isam - 1) + 1
304 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
305end do
306lb
307+1, +3
308ub
309+2, +7
310ndim = getUnifRand(1, minval(ub - lb + 1, 1))
311call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
312call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
313call setResized(covMerged, [ndim, ndim])
314sample = getUnifRand(-1., +1., ndim, ub(nsam))
315sample
316-0.697200179, -0.294422269, +0.778034091, -0.289398074, -0.969760418E-1, -0.820723534, -0.108875394
317cov(:,:,0) = getCov(sample, dim)
318cov(:,:,0) ! reference
319+0.231783420
320do isam = 1, nsam
321 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
322 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
323end do
324covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
325covMerged
326+0.231783375
327covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
328covMerged
329+0.231783375
330cov(:,:,0) ! reference
331+0.231783420
332
333
334dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
335do isam = 2, nsam
336 lb(isam) = ub(isam - 1) + 1
337 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
338end do
339lb
340+1, +8
341ub
342+7, +14
343ndim = getUnifRand(1, minval(ub - lb + 1, 1))
344call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
345call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
346call setResized(covMerged, [ndim, ndim])
347sample = getUnifRand(-1., +1., ndim, ub(nsam))
348sample
349-0.797141671, -0.981831193, -0.581664443, -0.587863326, -0.868144035E-1, +0.720070839, +0.132368803E-1, +0.860019684, -0.581309795, -0.676297426, +0.936826587, -0.832765698, +0.141550064, -0.560091496
350-0.403037786, +0.883886814, -0.743238926, -0.635479450, +0.279856086, +0.675266981, +0.889831543, -0.334007502, -0.570760489, +0.388154984E-1, +0.430730104, -0.682452321, -0.918160200, +0.708928823
351+0.388855457, +0.198159218, +0.570191741, +0.955034375, -0.908989072, +0.596375704, +0.665536761, +0.682703257E-1, -0.652592897, +0.290688872, +0.389454246, -0.179118037, +0.960478902, +0.252445936E-1
352-0.415153861, +0.148161411, +0.357922196, +0.202035904, +0.755900264, +0.937966824, -0.993079305, -0.617858887, -0.393603444, -0.286325693, -0.951842666, -0.320720673, -0.833170295, -0.608834982
353cov(:,:,0) = getCov(sample, dim)
354cov(:,:,0) ! reference
355+0.400033444, +0.795991793E-1, +0.515612811E-1, -0.503728576E-1
356+0.795991793E-1, +0.403674096, -0.280995890E-1, +0.246702526E-1
357+0.515612811E-1, -0.280995890E-1, +0.276032507, -0.567863286E-1
358-0.503728576E-1, +0.246702526E-1, -0.567863286E-1, +0.345866084
359do isam = 1, nsam
360 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), dim)
361 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), dim)
362end do
363covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
364covMerged
365+0.400033563, +0.795992017E-1, +0.515612699E-1, -0.503728539E-1
366+0.795992017E-1, +0.403674096, -0.280995965E-1, +0.246702470E-1
367+0.515612699E-1, -0.280995965E-1, +0.276032537, -0.567863248E-1
368-0.503728539E-1, +0.246702470E-1, -0.567863248E-1, +0.345866054
369covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(ub(1), TKG) / real(ub(2), TKG))
370covMerged
371+0.400033563, +0.795992017E-1, +0.515612699E-1, -0.503728539E-1
372+0.795992017E-1, +0.403674096, -0.280995965E-1, +0.246702470E-1
373+0.515612699E-1, -0.280995965E-1, +0.276032537, -0.567863248E-1
374-0.503728539E-1, +0.246702470E-1, -0.567863248E-1, +0.345866054
375cov(:,:,0) ! reference
376+0.400033444, +0.795991793E-1, +0.515612811E-1, -0.503728576E-1
377+0.795991793E-1, +0.403674096, -0.280995890E-1, +0.246702526E-1
378+0.515612811E-1, -0.280995890E-1, +0.276032507, -0.567863286E-1
379-0.503728576E-1, +0.246702526E-1, -0.567863286E-1, +0.345866084
380
381
382!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
383!Compute the biased merged covariance of a frequency weighted multivariate sample.
384!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
385
386
387dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
388do isam = 2, nsam
389 lb(isam) = ub(isam - 1) + 1
390 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
391end do
392lb
393+1, +4
394ub
395+3, +9
396ndim = getUnifRand(1, minval(ub - lb + 1, 1))
397call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
398call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
399call setResized(covMerged, [ndim, ndim])
400sample = getUnifRand(-1., +1., ndim, ub(nsam))
401sample
402-0.786315203E-1, -0.660466313, +0.113835216, -0.957939506, +0.466080904, +0.700660348, +0.733674765E-1, +0.119440079, +0.156006217
403+0.234601855, +0.432728529E-1, +0.466349483, +0.187891364, +0.680170178, -0.253057003, -0.844980359, +0.473610640, -0.781308889
404-0.573950410, +0.318583846, +0.773448944, -0.448424220, +0.538359880, -0.863941669, +0.574921370E-1, -0.683867216, +0.209436297
405iweight = getUnifRand(1, 10, size(sample, dim, IK))
406iweight
407+6, +9, +5, +3, +3, +1, +4, +8, +2
408cov(:,:,0) = getCov(sample, 2_IK, iweight)
409cov(:,:,0) ! reference
410+0.182513982, +0.182811283E-1, -0.141505562E-1
411+0.182811283E-1, +0.199309945, -0.159150101E-1
412-0.141505562E-1, -0.159150101E-1, +0.288595021
413do isam = 1, nsam
414 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
415 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
416end do
417covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
418covMerged
419+0.182513922, +0.182811376E-1, -0.141505487E-1
420+0.182811376E-1, +0.199309930, -0.159149971E-1
421-0.141505487E-1, -0.159149971E-1, +0.288595021
422covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
423covMerged
424+0.182513922, +0.182811376E-1, -0.141505487E-1
425+0.182811376E-1, +0.199309930, -0.159149971E-1
426-0.141505487E-1, -0.159149971E-1, +0.288595021
427cov(:,:,0) ! reference
428+0.182513982, +0.182811283E-1, -0.141505562E-1
429+0.182811283E-1, +0.199309945, -0.159150101E-1
430-0.141505562E-1, -0.159150101E-1, +0.288595021
431
432
433dim = 2; lb(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, +5
440ub
441+4, +10
442ndim = getUnifRand(1, minval(ub - lb + 1, 1))
443call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
444call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
445call setResized(covMerged, [ndim, ndim])
446sample = getUnifRand(-1., +1., ndim, ub(nsam))
447sample
448-0.436291695E-1, -0.862627149, -0.475697756, +0.968301296E-1, -0.518946767, +0.232646346, +0.908496022, -0.263181806, -0.293411970, -0.305140853
449+0.336656570, +0.628692269, +0.103240490, +0.122429371, -0.135803461, +0.474968314, +0.100804567E-1, +0.716149092, -0.974476337E-1, -0.383346200
450iweight = getUnifRand(1, 10, size(sample, dim, IK))
451iweight
452+4, +6, +4, +8, +6, +8, +7, +8, +1, +5
453cov(:,:,0) = getCov(sample, 2_IK, iweight)
454cov(:,:,0) ! reference
455+0.243729934, -0.298891664E-1
456-0.298891664E-1, +0.116771571
457do isam = 1, nsam
458 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
459 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
460end do
461covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
462covMerged
463+0.243729964, -0.298891626E-1
464-0.298891626E-1, +0.116771594
465covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
466covMerged
467+0.243729964, -0.298891626E-1
468-0.298891626E-1, +0.116771594
469cov(:,:,0) ! reference
470+0.243729934, -0.298891664E-1
471-0.298891664E-1, +0.116771571
472
473
474dim = 2; lb(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, +5
483ndim = getUnifRand(1, minval(ub - lb + 1, 1))
484call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
485call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
486call setResized(covMerged, [ndim, ndim])
487sample = getUnifRand(-1., +1., ndim, ub(nsam))
488sample
489-0.678604960, -0.678777695, -0.618703842, -0.567588687, +0.346815586E-1
490+0.898934364, +0.156200647, -0.359558702, -0.108129144, -0.988118172
491iweight = getUnifRand(1, 10, size(sample, dim, IK))
492iweight
493+1, +5, +5, +3, +4
494cov(:,:,0) = getCov(sample, 2_IK, iweight)
495cov(:,:,0) ! reference
496+0.786307752E-1, -0.117347583
497-0.117347583, +0.246894628
498do isam = 1, nsam
499 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
500 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
501end do
502covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
503covMerged
504+0.786307603E-1, -0.117347583
505-0.117347583, +0.246894479
506covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
507covMerged
508+0.786307603E-1, -0.117347583
509-0.117347583, +0.246894479
510cov(:,:,0) ! reference
511+0.786307752E-1, -0.117347583
512-0.117347583, +0.246894628
513
514
515dim = 2; lb(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, +8
522ub
523+7, +12
524ndim = getUnifRand(1, minval(ub - lb + 1, 1))
525call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
526call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
527call setResized(covMerged, [ndim, ndim])
528sample = getUnifRand(-1., +1., ndim, ub(nsam))
529sample
530-0.208982348, +0.713083982, -0.637923479, +0.346663117, +0.243395329, +0.582505584, -0.843858838, -0.910199404, +0.240903974, +0.809711456, +0.461684346, +0.713166475
531-0.730901957E-1, -0.341346979, +0.938420415, +0.772752404, -0.165072918, -0.683880091, -0.684969902, -0.791583896, -0.707930565, +0.788378835, +0.257578850, +0.290514708
532iweight = getUnifRand(1, 10, size(sample, dim, IK))
533iweight
534+2, +7, +2, +2, +8, +2, +2, +6, +8, +1, +4, +4
535cov(:,:,0) = getCov(sample, 2_IK, iweight)
536cov(:,:,0) ! reference
537+0.314948261, +0.882745683E-1
538+0.882745683E-1, +0.260929316
539do isam = 1, nsam
540 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
541 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
542end do
543covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
544covMerged
545+0.314948231, +0.882745758E-1
546+0.882745758E-1, +0.260929257
547covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
548covMerged
549+0.314948231, +0.882745758E-1
550+0.882745758E-1, +0.260929257
551cov(:,:,0) ! reference
552+0.314948261, +0.882745683E-1
553+0.882745683E-1, +0.260929316
554
555
556dim = 2; lb(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, +3
563ub
564+2, +7
565ndim = getUnifRand(1, minval(ub - lb + 1, 1))
566call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
567call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
568call setResized(covMerged, [ndim, ndim])
569sample = getUnifRand(-1., +1., ndim, ub(nsam))
570sample
571+0.876070619, -0.514825821, -0.328470469E-1, -0.727837563, +0.377502918, -0.280457258, -0.783266783
572iweight = getUnifRand(1, 10, size(sample, dim, IK))
573iweight
574+10, +10, +1, +1, +1, +4, +7
575cov(:,:,0) = getCov(sample, 2_IK, iweight)
576cov(:,:,0) ! reference
577+0.449201703
578do isam = 1, nsam
579 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
580 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
581end do
582covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
583covMerged
584+0.449201643
585covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
586covMerged
587+0.449201643
588cov(:,:,0) ! reference
589+0.449201703
590
591
592dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
593do isam = 2, nsam
594 lb(isam) = ub(isam - 1) + 1
595 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
596end do
597lb
598+1, +8
599ub
600+7, +11
601ndim = getUnifRand(1, minval(ub - lb + 1, 1))
602call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
603call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
604call setResized(covMerged, [ndim, ndim])
605sample = getUnifRand(-1., +1., ndim, ub(nsam))
606sample
607+0.171964884, -0.190007210, -0.104264140, +0.731477380, -0.926714540, +0.732975006, +0.954771399, +0.760789633, -0.161316752, -0.556988358, +0.862578750
608iweight = getUnifRand(1, 10, size(sample, dim, IK))
609iweight
610+8, +2, +8, +4, +7, +9, +10, +9, +5, +6, +6
611cov(:,:,0) = getCov(sample, 2_IK, iweight)
612cov(:,:,0) ! reference
613+0.384034127
614do isam = 1, nsam
615 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
616 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
617end do
618covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
619covMerged
620+0.384034097
621covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
622covMerged
623+0.384034097
624cov(:,:,0) ! reference
625+0.384034127
626
627
628dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
629do isam = 2, nsam
630 lb(isam) = ub(isam - 1) + 1
631 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
632end do
633lb
634+1, +5
635ub
636+4, +8
637ndim = getUnifRand(1, minval(ub - lb + 1, 1))
638call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
639call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
640call setResized(covMerged, [ndim, ndim])
641sample = getUnifRand(-1., +1., ndim, ub(nsam))
642sample
643+0.567906260, -0.900461793, +0.211406469, +0.509926558, +0.198761344, -0.159141064, -0.355449796, -0.628385425
644-0.264134526, -0.725650787E-1, +0.850877762E-1, -0.408719063, +0.313229561E-1, -0.273550749, -0.736196041, +0.504519701
645iweight = getUnifRand(1, 10, size(sample, dim, IK))
646iweight
647+7, +4, +1, +6, +8, +3, +3, +9
648cov(:,:,0) = getCov(sample, 2_IK, iweight)
649cov(:,:,0) ! reference
650+0.276500612, -0.985494331E-1
651-0.985494331E-1, +0.133766621
652do isam = 1, nsam
653 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
654 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
655end do
656covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
657covMerged
658+0.276500493, -0.985494331E-1
659-0.985494331E-1, +0.133766621
660covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
661covMerged
662+0.276500493, -0.985494331E-1
663-0.985494331E-1, +0.133766621
664cov(:,:,0) ! reference
665+0.276500612, -0.985494331E-1
666-0.985494331E-1, +0.133766621
667
668
669dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
670do isam = 2, nsam
671 lb(isam) = ub(isam - 1) + 1
672 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
673end do
674lb
675+1, +3
676ub
677+2, +5
678ndim = getUnifRand(1, minval(ub - lb + 1, 1))
679call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
680call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
681call setResized(covMerged, [ndim, ndim])
682sample = getUnifRand(-1., +1., ndim, ub(nsam))
683sample
684-0.656473756, +0.239127874, -0.365923285, +0.198137760E-2, -0.394525647
685iweight = getUnifRand(1, 10, size(sample, dim, IK))
686iweight
687+3, +5, +9, +9, +2
688cov(:,:,0) = getCov(sample, 2_IK, iweight)
689cov(:,:,0) ! reference
690+0.806847811E-1
691do isam = 1, nsam
692 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
693 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
694end do
695covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
696covMerged
697+0.806847960E-1
698covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
699covMerged
700+0.806847960E-1
701cov(:,:,0) ! reference
702+0.806847811E-1
703
704
705dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
706do isam = 2, nsam
707 lb(isam) = ub(isam - 1) + 1
708 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
709end do
710lb
711+1, +3
712ub
713+2, +7
714ndim = getUnifRand(1, minval(ub - lb + 1, 1))
715call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
716call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
717call setResized(covMerged, [ndim, ndim])
718sample = getUnifRand(-1., +1., ndim, ub(nsam))
719sample
720+0.394487262, -0.965412140, +0.751704454, +0.306246042, -0.728279352E-1, +0.792823792, +0.833100796
721-0.365658164, +0.628178120, +0.505236030, -0.179755926, -0.887561917, -0.142711043, -0.140661001E-1
722iweight = getUnifRand(1, 10, size(sample, dim, IK))
723iweight
724+5, +7, +2, +1, +10, +2, +1
725cov(:,:,0) = getCov(sample, 2_IK, iweight)
726cov(:,:,0) ! reference
727+0.373978019, -0.147092819
728-0.147092819, +0.382176489
729do isam = 1, nsam
730 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
731 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
732end do
733covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
734covMerged
735+0.373978019, -0.147092849
736-0.147092849, +0.382176459
737covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
738covMerged
739+0.373978019, -0.147092849
740-0.147092849, +0.382176459
741cov(:,:,0) ! reference
742+0.373978019, -0.147092819
743-0.147092819, +0.382176489
744
745
746dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
747do isam = 2, nsam
748 lb(isam) = ub(isam - 1) + 1
749 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
750end do
751lb
752+1, +5
753ub
754+4, +6
755ndim = getUnifRand(1, minval(ub - lb + 1, 1))
756call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
757call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
758call setResized(covMerged, [ndim, ndim])
759sample = getUnifRand(-1., +1., ndim, ub(nsam))
760sample
761-0.415363431, +0.101410031, +0.386214375, +0.950505257, +0.955744982, +0.482717872
762iweight = getUnifRand(1, 10, size(sample, dim, IK))
763iweight
764+4, +7, +4, +8, +9, +1
765cov(:,:,0) = getCov(sample, 2_IK, iweight)
766cov(:,:,0) ! reference
767+0.242127746
768do isam = 1, nsam
769 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
770 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, iweight(lb(isam):ub(isam)))
771end do
772covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
773covMerged
774+0.242127746
775covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(iweight(:ub(1))), TKG) / real(sum(iweight), TKG))
776covMerged
777+0.242127746
778cov(:,:,0) ! reference
779+0.242127746
780
781
782!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
783!Compute the biased merged covariance of a reliability weighted multivariate sample.
784!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
785
786
787dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
788do isam = 2, nsam
789 lb(isam) = ub(isam - 1) + 1
790 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
791end do
792lb
793+1, +5
794ub
795+4, +11
796ndim = getUnifRand(1, minval(ub - lb + 1, 1))
797call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
798call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
799call setResized(covMerged, [ndim, ndim])
800sample = getUnifRand(-1., +1., ndim, ub(nsam))
801sample
802+0.965116143, -0.618989110, +0.517084599, +0.533307791, +0.235189795, -0.246401548, -0.655967474, -0.207663298, +0.448436499, -0.296983719E-1, +0.851701379
803-0.518522739, +0.677602768, -0.352034092, +0.431160808, +0.512614727, -0.993810892, +0.201565027, -0.960318923, +0.986458898, -0.322721601, +0.658695340
804rweight = getUnifRand(1., 2., size(sample, dim, IK))
805rweight
806+1.62279177, +1.45496058, +1.85364246, +1.68701625, +1.13603568, +1.71637034, +1.83497071, +1.39044881, +1.83572638, +1.85137069, +1.91283512
807cov(:,:,0) = getCov(sample, 2_IK, rweight)
808cov(:,:,0) ! reference
809+0.286064208, +0.554748848E-1
810+0.554748848E-1, +0.425631016
811do isam = 1, nsam
812 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
813 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
814end do
815covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
816covMerged
817+0.286064148, +0.554749183E-1
818+0.554749183E-1, +0.425630957
819covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
820covMerged
821+0.286064148, +0.554749183E-1
822+0.554749183E-1, +0.425630957
823cov(:,:,0) ! reference
824+0.286064208, +0.554748848E-1
825+0.554748848E-1, +0.425631016
826
827
828dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
829do isam = 2, nsam
830 lb(isam) = ub(isam - 1) + 1
831 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
832end do
833lb
834+1, +7
835ub
836+6, +13
837ndim = getUnifRand(1, minval(ub - lb + 1, 1))
838call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
839call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
840call setResized(covMerged, [ndim, ndim])
841sample = getUnifRand(-1., +1., ndim, ub(nsam))
842sample
843-0.602904558, -0.532554150, -0.963921189, -0.780987501, -0.820935965, -0.814537048, -0.657245874, +0.185071230E-1, -0.798622370E-1, +0.179597139E-1, -0.807210565, -0.772594571, +0.518379331
844+0.846610069E-1, -0.255014420, -0.392428041, -0.575119019, +0.798771977, +0.171770811, -0.466423631, +0.562086225, -0.108284473, -0.487058997, +0.300368309, +0.147302389, -0.860340238
845-0.307022095, +0.519592166, -0.379466414, -0.106634140, +0.195981503, -0.162214279, -0.180228829, -0.903487682, -0.220365047, -0.111602545, +0.742571354, -0.517276168, +0.754002333
846rweight = getUnifRand(1., 2., size(sample, dim, IK))
847rweight
848+1.80745482, +1.91838062, +1.82210445, +1.68124461, +1.32249761, +1.15718389, +1.12939501, +1.50313473, +1.35109568, +1.92897141, +1.57261562, +1.96905887, +1.38279319
849cov(:,:,0) = getCov(sample, 2_IK, rweight)
850cov(:,:,0) ! reference
851+0.180651352, -0.604294166E-1, +0.221847203E-1
852-0.604294166E-1, +0.197992459, -0.534281135E-1
853+0.221847203E-1, -0.534281135E-1, +0.219491750
854do isam = 1, nsam
855 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
856 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
857end do
858covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
859covMerged
860+0.180651382, -0.604294389E-1, +0.221847221E-1
861-0.604294389E-1, +0.197992489, -0.534281135E-1
862+0.221847221E-1, -0.534281135E-1, +0.219491780
863covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
864covMerged
865+0.180651382, -0.604294389E-1, +0.221847221E-1
866-0.604294389E-1, +0.197992489, -0.534281135E-1
867+0.221847221E-1, -0.534281135E-1, +0.219491780
868cov(:,:,0) ! reference
869+0.180651352, -0.604294166E-1, +0.221847203E-1
870-0.604294166E-1, +0.197992459, -0.534281135E-1
871+0.221847203E-1, -0.534281135E-1, +0.219491750
872
873
874dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
875do isam = 2, nsam
876 lb(isam) = ub(isam - 1) + 1
877 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
878end do
879lb
880+1, +7
881ub
882+6, +11
883ndim = getUnifRand(1, minval(ub - lb + 1, 1))
884call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
885call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
886call setResized(covMerged, [ndim, ndim])
887sample = getUnifRand(-1., +1., ndim, ub(nsam))
888sample
889+0.576702476, -0.762822986, +0.389814377, +0.770179510, +0.452009916, +0.118771076, -0.853648186E-1, +0.293818712, +0.210033894, +0.129863620, -0.523804188
890+0.178259015, -0.743267179, -0.820138693, -0.249087453, -0.625983477, +0.754475594E-1, -0.655026078, -0.559344172, -0.818276405E-2, -0.799232483, -0.166229606
891+0.540852547E-2, +0.872837186, -0.266216040, -0.456626773, +0.590732336, +0.104536295, -0.715731859, +0.739233494, +0.869563103, +0.211425662, -0.536368966
892-0.444209456, +0.577436805, +0.176127315, -0.746196270, -0.740318060, -0.311098456, -0.268173814, -0.630037785, -0.517294765, +0.929075360, -0.184486032
893rweight = getUnifRand(1., 2., size(sample, dim, IK))
894rweight
895+1.03852189, +1.64095497, +1.43411195, +1.25756931, +1.88297462, +1.09481430, +1.95359170, +1.27446771, +1.34226561, +1.21631432, +1.95789671
896cov(:,:,0) = getCov(sample, 2_IK, rweight)
897cov(:,:,0) ! reference
898+0.203173012, +0.243414305E-1, -0.550830318E-2, -0.123785205
899+0.243414305E-1, +0.112955928, -0.153537886E-1, -0.825521871E-1
900-0.550830318E-2, -0.153537886E-1, +0.338550955, +0.160998143E-1
901-0.123785205, -0.825521871E-1, +0.160998143E-1, +0.256371975
902do isam = 1, nsam
903 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
904 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
905end do
906covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
907covMerged
908+0.203173012, +0.243414249E-1, -0.550830830E-2, -0.123785213
909+0.243414249E-1, +0.112955935, -0.153537774E-1, -0.825521871E-1
910-0.550830830E-2, -0.153537774E-1, +0.338550925, +0.160997994E-1
911-0.123785213, -0.825521871E-1, +0.160997994E-1, +0.256371915
912covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
913covMerged
914+0.203173012, +0.243414249E-1, -0.550830830E-2, -0.123785213
915+0.243414249E-1, +0.112955935, -0.153537774E-1, -0.825521871E-1
916-0.550830830E-2, -0.153537774E-1, +0.338550925, +0.160997994E-1
917-0.123785213, -0.825521871E-1, +0.160997994E-1, +0.256371915
918cov(:,:,0) ! reference
919+0.203173012, +0.243414305E-1, -0.550830318E-2, -0.123785205
920+0.243414305E-1, +0.112955928, -0.153537886E-1, -0.825521871E-1
921-0.550830318E-2, -0.153537886E-1, +0.338550955, +0.160998143E-1
922-0.123785205, -0.825521871E-1, +0.160998143E-1, +0.256371975
923
924
925dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
926do isam = 2, nsam
927 lb(isam) = ub(isam - 1) + 1
928 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
929end do
930lb
931+1, +7
932ub
933+6, +10
934ndim = getUnifRand(1, minval(ub - lb + 1, 1))
935call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
936call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
937call setResized(covMerged, [ndim, ndim])
938sample = getUnifRand(-1., +1., ndim, ub(nsam))
939sample
940-0.867113709, +0.875582457, +0.714429855, -0.478593707, -0.264592767, -0.107765079, +0.461809874, -0.890212059, -0.119295239, +0.447449088
941rweight = getUnifRand(1., 2., size(sample, dim, IK))
942rweight
943+1.85097837, +1.69955719, +1.77846563, +1.07871544, +1.23177576, +1.64282238, +1.80511332, +1.86316013, +1.53632379, +1.67458916
944cov(:,:,0) = getCov(sample, 2_IK, rweight)
945cov(:,:,0) ! reference
946+0.381925315
947do isam = 1, nsam
948 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
949 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
950end do
951covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
952covMerged
953+0.381925255
954covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
955covMerged
956+0.381925255
957cov(:,:,0) ! reference
958+0.381925315
959
960
961dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
962do isam = 2, nsam
963 lb(isam) = ub(isam - 1) + 1
964 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
965end do
966lb
967+1, +3
968ub
969+2, +7
970ndim = getUnifRand(1, minval(ub - lb + 1, 1))
971call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
972call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
973call setResized(covMerged, [ndim, ndim])
974sample = getUnifRand(-1., +1., ndim, ub(nsam))
975sample
976+0.884284377, +0.678309560, -0.606845975, -0.336640596, -0.640532970E-1, +0.143713951E-1, -0.395531893
977rweight = getUnifRand(1., 2., size(sample, dim, IK))
978rweight
979+1.41228771, +1.79871047, +1.54664350, +1.43365741, +1.96230829, +1.45303416, +1.72735882
980cov(:,:,0) = getCov(sample, 2_IK, rweight)
981cov(:,:,0) ! reference
982+0.259098679
983do isam = 1, nsam
984 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
985 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
986end do
987covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
988covMerged
989+0.259098649
990covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
991covMerged
992+0.259098649
993cov(:,:,0) ! reference
994+0.259098679
995
996
997dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
998do isam = 2, nsam
999 lb(isam) = ub(isam - 1) + 1
1000 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
1001end do
1002lb
1003+1, +8
1004ub
1005+7, +12
1006ndim = getUnifRand(1, minval(ub - lb + 1, 1))
1007call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
1008call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
1009call setResized(covMerged, [ndim, ndim])
1010sample = getUnifRand(-1., +1., ndim, ub(nsam))
1011sample
1012+0.348718166E-1, +0.219659209, -0.696394563, +0.945866704, +0.103371501, +0.342993736, +0.970470428, -0.726941705, +0.987814069, -0.382116437, -0.573701620, -0.475348115
1013-0.409633875, -0.563575387, +0.470449448, -0.748633027, +0.133914113, -0.955760479, -0.441940427, -0.422046661, -0.425314188, -0.960405111, -0.703205705, -0.357921720
1014rweight = getUnifRand(1., 2., size(sample, dim, IK))
1015rweight
1016+1.83318257, +1.93664861, +1.21398473, +1.78320706, +1.42964256, +1.43478048, +1.67184234, +1.31710660, +1.40100145, +1.00328112, +1.90554750, +1.70928192
1017cov(:,:,0) = getCov(sample, 2_IK, rweight)
1018cov(:,:,0) ! reference
1019+0.380952179, -0.564976335E-1
1020-0.564976335E-1, +0.132393822
1021do isam = 1, nsam
1022 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
1023 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
1024end do
1025covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1026covMerged
1027+0.380952150, -0.564976335E-1
1028-0.564976335E-1, +0.132393822
1029covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1030covMerged
1031+0.380952150, -0.564976335E-1
1032-0.564976335E-1, +0.132393822
1033cov(:,:,0) ! reference
1034+0.380952179, -0.564976335E-1
1035-0.564976335E-1, +0.132393822
1036
1037
1038dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
1039do isam = 2, nsam
1040 lb(isam) = ub(isam - 1) + 1
1041 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
1042end do
1043lb
1044+1, +6
1045ub
1046+5, +9
1047ndim = getUnifRand(1, minval(ub - lb + 1, 1))
1048call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
1049call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
1050call setResized(covMerged, [ndim, ndim])
1051sample = getUnifRand(-1., +1., ndim, ub(nsam))
1052sample
1053-0.274046898, +0.655738592, +0.187955856, -0.366309762, -0.165457129, +0.618002176, -0.225349426, -0.304577231, -0.410097718
1054+0.855230808, -0.952419758, -0.343585491, -0.417371511, +0.961327553E-1, -0.126777411, -0.337906480, -0.338787913, -0.250286698
1055-0.848578334, -0.919703484, -0.416906595, -0.990087628, -0.905810952, -0.911566496, +0.966155767, +0.721211672, -0.149915814
1056+0.300648928, +0.728748560, -0.566886544, +0.668498516, -0.354220629, -0.876458168, +0.588328362, +0.601305962E-1, -0.181135297
1057rweight = getUnifRand(1., 2., size(sample, dim, IK))
1058rweight
1059+1.82362103, +1.88780189, +1.11392283, +1.71022975, +1.13418067, +1.10960150, +1.20596910, +1.72738600, +1.67118287
1060cov(:,:,0) = getCov(sample, 2_IK, rweight)
1061cov(:,:,0) ! reference
1062+0.160040319, -0.910098553E-1, -0.107576609, -0.231270343E-1
1063-0.910098553E-1, +0.251663506, -0.471586846E-1, -0.664836764E-1
1064-0.107576609, -0.471586846E-1, +0.491633534, +0.612105802E-2
1065-0.231270343E-1, -0.664836764E-1, +0.612105802E-2, +0.267347187
1066do isam = 1, nsam
1067 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
1068 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
1069end do
1070covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1071covMerged
1072+0.160040304, -0.910098702E-1, -0.107576579, -0.231270045E-1
1073-0.910098702E-1, +0.251663476, -0.471586734E-1, -0.664837062E-1
1074-0.107576579, -0.471586734E-1, +0.491633505, +0.612097979E-2
1075-0.231270045E-1, -0.664837062E-1, +0.612097979E-2, +0.267347157
1076covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1077covMerged
1078+0.160040304, -0.910098702E-1, -0.107576579, -0.231270045E-1
1079-0.910098702E-1, +0.251663476, -0.471586734E-1, -0.664837062E-1
1080-0.107576579, -0.471586734E-1, +0.491633505, +0.612097979E-2
1081-0.231270045E-1, -0.664837062E-1, +0.612097979E-2, +0.267347157
1082cov(:,:,0) ! reference
1083+0.160040319, -0.910098553E-1, -0.107576609, -0.231270343E-1
1084-0.910098553E-1, +0.251663506, -0.471586846E-1, -0.664836764E-1
1085-0.107576609, -0.471586846E-1, +0.491633534, +0.612105802E-2
1086-0.231270343E-1, -0.664836764E-1, +0.612105802E-2, +0.267347187
1087
1088
1089dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
1090do isam = 2, nsam
1091 lb(isam) = ub(isam - 1) + 1
1092 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
1093end do
1094lb
1095+1, +6
1096ub
1097+5, +8
1098ndim = getUnifRand(1, minval(ub - lb + 1, 1))
1099call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
1100call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
1101call setResized(covMerged, [ndim, ndim])
1102sample = getUnifRand(-1., +1., ndim, ub(nsam))
1103sample
1104+0.502205133, -0.624492288, -0.181123853, -0.291036606, +0.215662956, +0.998010993, +0.573534012, +0.425442457E-1
1105-0.205318332, -0.821135521, +0.286768079, +0.409845591, -0.612577915, -0.728007674, +0.232372284, +0.554700732
1106-0.285521865, +0.288413286, -0.445552826, -0.157199502, -0.174708486, -0.551939011E-2, -0.144386888, -0.283074617
1107rweight = getUnifRand(1., 2., size(sample, dim, IK))
1108rweight
1109+1.22570467, +1.50353479, +1.15076637, +1.57052779, +1.14627099, +1.46008205, +1.82207084, +1.41990399
1110cov(:,:,0) = getCov(sample, 2_IK, rweight)
1111cov(:,:,0) ! reference
1112+0.255100071, -0.324375667E-1, -0.222480558E-1
1113-0.324375667E-1, +0.271039933, -0.738349557E-1
1114-0.222480558E-1, -0.738349557E-1, +0.412969738E-1
1115do isam = 1, nsam
1116 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
1117 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
1118end do
1119covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1120covMerged
1121+0.255100012, -0.324375518E-1, -0.222480502E-1
1122-0.324375518E-1, +0.271039903, -0.738349557E-1
1123-0.222480502E-1, -0.738349557E-1, +0.412969664E-1
1124covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1125covMerged
1126+0.255100012, -0.324375518E-1, -0.222480502E-1
1127-0.324375518E-1, +0.271039903, -0.738349557E-1
1128-0.222480502E-1, -0.738349557E-1, +0.412969664E-1
1129cov(:,:,0) ! reference
1130+0.255100071, -0.324375667E-1, -0.222480558E-1
1131-0.324375667E-1, +0.271039933, -0.738349557E-1
1132-0.222480558E-1, -0.738349557E-1, +0.412969738E-1
1133
1134
1135dim = 2; lb(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, +8
1142ub
1143+7, +14
1144ndim = getUnifRand(1, minval(ub - lb + 1, 1))
1145call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
1146call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
1147call setResized(covMerged, [ndim, ndim])
1148sample = getUnifRand(-1., +1., ndim, ub(nsam))
1149sample
1150+0.409439802E-1, -0.682392836, +0.160023689, -0.141605854, -0.118803620, +0.534470201, -0.731879950, +0.374064326, -0.250223994, -0.825326443E-1, +0.818930268, -0.606652260, -0.265372872, -0.122818232
1151+0.808146834, -0.110239148, -0.658100367, +0.452698112, +0.257357001, +0.186050653, +0.366983891, +0.927285314, -0.811716318, -0.943885684, +0.648437500, -0.278840303, +0.202040792, +0.771842003
1152-0.767813921, -0.903244734, -0.442932248, -0.201163411, +0.850278139, -0.955864906, -0.306515932, -0.374953032, -0.757415175, -0.376701951, +0.536779642, +0.228045702, +0.252909660E-1, +0.225044608
1153+0.303477883, -0.704177737, -0.835227132, +0.977988362, +0.386534691, +0.351224065, +0.718926191E-1, -0.888808966, -0.297550678, -0.967229724, +0.548205376, -0.243800402, +0.732949972, -0.899286985
1154-0.460997939, -0.987386942, -0.326171517, -0.634609818, +0.158227205, +0.136659622, +0.283920527, -0.172958970, -0.786032438, -0.911721468, +0.186083317, -0.177505255, +0.358197927, -0.245128870E-1
1155rweight = getUnifRand(1., 2., size(sample, dim, IK))
1156rweight
1157+1.99738526, +1.31132257, +1.07123506, +1.98736858, +1.64034486, +1.42187595, +1.01496410, +1.83629704, +1.21254778, +1.31585312, +1.90962315, +1.97294784, +1.29707718, +1.18904340
1158cov(:,:,0) = getCov(sample, 2_IK, rweight)
1159cov(:,:,0) ! reference
1160+0.192162171, +0.980625227E-1, +0.194441807E-1, +0.447740555E-1, +0.568457991E-1
1161+0.980625227E-1, +0.329243243, +0.541818067E-1, +0.126205355, +0.106694907
1162+0.194441807E-1, +0.541818067E-1, +0.290008962, +0.868502706E-1, +0.124071278
1163+0.447740555E-1, +0.126205355, +0.868502706E-1, +0.425447017, +0.963561386E-1
1164+0.568457991E-1, +0.106694907, +0.124071278, +0.963561386E-1, +0.175897107
1165do isam = 1, nsam
1166 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
1167 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
1168end do
1169covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1170covMerged
1171+0.192162201, +0.980625153E-1, +0.194442067E-1, +0.447740816E-1, +0.568457954E-1
1172+0.980625153E-1, +0.329243302, +0.541818738E-1, +0.126205415, +0.106694959
1173+0.194442067E-1, +0.541818738E-1, +0.290008932, +0.868503004E-1, +0.124071270
1174+0.447740816E-1, +0.126205415, +0.868503004E-1, +0.425447047, +0.963561758E-1
1175+0.568457954E-1, +0.106694959, +0.124071270, +0.963561758E-1, +0.175897107
1176covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1177covMerged
1178+0.192162201, +0.980625153E-1, +0.194442067E-1, +0.447740816E-1, +0.568457954E-1
1179+0.980625153E-1, +0.329243302, +0.541818738E-1, +0.126205415, +0.106694959
1180+0.194442067E-1, +0.541818738E-1, +0.290008932, +0.868503004E-1, +0.124071270
1181+0.447740816E-1, +0.126205415, +0.868503004E-1, +0.425447047, +0.963561758E-1
1182+0.568457954E-1, +0.106694959, +0.124071270, +0.963561758E-1, +0.175897107
1183cov(:,:,0) ! reference
1184+0.192162171, +0.980625227E-1, +0.194441807E-1, +0.447740555E-1, +0.568457991E-1
1185+0.980625227E-1, +0.329243243, +0.541818067E-1, +0.126205355, +0.106694907
1186+0.194441807E-1, +0.541818067E-1, +0.290008962, +0.868502706E-1, +0.124071278
1187+0.447740555E-1, +0.126205355, +0.868502706E-1, +0.425447017, +0.963561386E-1
1188+0.568457991E-1, +0.106694907, +0.124071278, +0.963561386E-1, +0.175897107
1189
1190
1191dim = 2; lb(1) = 1; ub(1) = getUnifRand(2, 7)
1192do isam = 2, nsam
1193 lb(isam) = ub(isam - 1) + 1
1194 ub(isam) = ub(isam - 1) + getUnifRand(2, 7)
1195end do
1196lb
1197+1, +6
1198ub
1199+5, +7
1200ndim = getUnifRand(1, minval(ub - lb + 1, 1))
1201call setRebound(cov, [1_IK, 1_IK, 0_IK], [ndim, ndim, nsam])
1202call setRebound(mean, [1_IK, 1_IK], [ndim, nsam])
1203call setResized(covMerged, [ndim, ndim])
1204sample = getUnifRand(-1., +1., ndim, ub(nsam))
1205sample
1206-0.916800857, -0.870506406, -0.509163141, -0.690467715, +0.374779582, -0.502488613, -0.613355398
1207rweight = getUnifRand(1., 2., size(sample, dim, IK))
1208rweight
1209+1.93754172, +1.73591626, +1.46981335, +1.31743741, +1.58394098, +1.54039943, +1.40280652
1210cov(:,:,0) = getCov(sample, 2_IK, rweight)
1211cov(:,:,0) ! reference
1212+0.166627124
1213do isam = 1, nsam
1214 cov(:,:,isam) = getCov(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
1215 mean(:,isam) = getMean(sample(:,lb(isam):ub(isam)), 2_IK, rweight(lb(isam):ub(isam)))
1216end do
1217covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1218covMerged
1219+0.166627139
1220covMerged = getCovMerged(cov(:,:,2), cov(:,:,1), mean(:,1) - mean(:,2), real(sum(rweight(:ub(1))), TKG) / real(sum(rweight), TKG))
1221covMerged
1222+0.166627139
1223cov(:,:,0) ! reference
1224+0.166627124
1225
1226
Test:
test_pm_sampleCov


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, April 21, 2017, 1:54 AM, Institute for Computational Engineering and Sciences (ICES), The University of Texas Austin

Definition at line 6975 of file pm_sampleCov.F90.


The documentation for this interface was generated from the following file: