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

Return the covAariance resulting from the merger of two separate (potentially weighted) non-singular and singular samples \(A\) and \(B\).
More...

Detailed Description

Return the covAariance resulting from the merger of two separate (potentially weighted) non-singular and singular samples \(A\) and \(B\).

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

Note
The input and output variances of this generic interface are all biased variances.
A biased covAariance can be readily unbiased by multiplying it with the appropriate bias-correction factors detailed in the documentation of pm_sampleCov.
Parameters
[in]covA: The input/output 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),

On input, it must contain the biased covAariance of the initial non-singular sample \(A\) that must be merged with the second singular sample \(B\).

Parameters
[in]meanDiff: The input object of the same type and kind as the input argument covA of size size(covA, 1), containing the difference of mean of the two non-singular and singular 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 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 covA, and covA matrices must be accessed and/or manipulated.
  2. The constant uppDia, implying that only the upper-diagonal subset of the input covA, 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 setCovUpdated(covA(1:ndim, 1:ndim), meanDiff(1:ndim), fracA, subset)
Return the covAariance resulting from the merger of two separate (potentially weighted) non-singular ...
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(size(meanDiff) == 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
setCovUpdated
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) :: isam, ndim
18 integer(IK) , allocatable :: iweight(:)
19 integer(IK) :: dim, idim, nsamA, nsamB, itry, ntry = 10
20 type(display_type) :: disp
21 disp = display_type(file = "main.out.F90")
22
23 call disp%skip()
24 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
25 call disp%show("!Compute the biased merged covariance of a multivariate sample.")
26 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
27 call disp%skip()
28
29 block
30 real(TKG), allocatable :: cov(:,:), covA(:,:)
31 real(TKG), allocatable :: mean(:), meanA(:), meanB(:)
32 real(TKG), allocatable :: sample(:,:), sampleA(:,:), sampleB(:,:)
33 do itry = 1, ntry
34 call disp%skip()
35 call disp%show("dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)")
36 dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
37 call disp%show("[ndim, nsamA]")
38 call disp%show( [ndim, nsamA] )
39 call disp%show("sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.")
40 sampleA = getUnifRand(-1., +1., ndim, nsamA)
41 call disp%show("sampleA")
42 call disp%show( sampleA )
43 call disp%show("covA = getCov(sampleA, dim)")
44 covA = getCov(sampleA, dim)
45 call disp%show("covA")
46 call disp%show( covA )
47 call disp%show("meanA = getMean(sampleA, dim)")
48 meanA = getMean(sampleA, dim)
49 call disp%show("meanA")
50 call disp%show( meanA )
51 call disp%show("sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.")
52 sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB)
53 call disp%show("sampleB")
54 call disp%show( sampleB )
55 call disp%show("meanB = getMean(sampleB, dim)")
56 meanB = getMean(sampleB, dim)
57 call disp%show("meanB")
58 call disp%show( meanB )
59 call disp%show("sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])")
60 sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
61 call disp%show("sample")
62 call disp%show( sample )
63 call disp%show("cov = getCov(sample, dim)")
64 cov = getCov(sample, dim)
65 call disp%show("cov")
66 call disp%show( cov )
67 call disp%show("mean = getMean(sample, dim)")
68 mean = getMean(sample, dim)
69 call disp%show("mean")
70 call disp%show( mean )
71 call disp%show("call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)")
72 call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
73 call disp%show("covA")
74 call disp%show( covA )
75 call disp%show("cov ! reference")
76 call disp%show( cov )
77 call disp%skip()
78 end do
79 end block
80
81end 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; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
8[ndim, nsamA]
9+5, +6
10sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
11sampleA
12+0.227079630, -0.358364940, +0.789673924, +0.797860861, +0.388282537, +0.301279783
13-0.750372410E-1, +0.538735032, +0.316716909, -0.273296356, +0.489778996, +0.966706753
14-0.936355352, +0.597420931E-1, -0.788232565, -0.860334039, -0.197447538E-1, -0.193882942
15-0.278710365, -0.743827224, +0.195447206, -0.794361830, -0.711205482, -0.751644015
16-0.618216872, -0.917478800, -0.903860807, +0.219692230, +0.309239864, +0.118686557
17covA = getCov(sampleA, dim)
18covA
19+0.152378723, -0.664808154E-1, -0.104915939, +0.540454686E-1, +0.744377971E-1
20-0.664808154E-1, +0.167108089, +0.131191656, -0.277293436E-1, +0.973986648E-2
21-0.104915939, +0.131191656, +0.171603024, -0.837030634E-1, +0.334038362E-1
22+0.540454686E-1, -0.277293436E-1, -0.837030634E-1, +0.130910754, -0.121118724
23+0.744377971E-1, +0.973986648E-2, +0.334038362E-1, -0.121118724, +0.277288437
24meanA = getMean(sampleA, dim)
25meanA
26+0.357635319, +0.327267349, -0.456467956, -0.514050364, -0.298656344
27sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
28sampleB
29+1.00000000, +1.00000000
30+2.00000000, +2.00000000
31+3.00000000, +3.00000000
32+4.00000000, +4.00000000
33+5.00000000, +5.00000000
34meanB = getMean(sampleB, dim)
35meanB
36+1.00000000, +2.00000000, +3.00000000, +4.00000000, +5.00000000
37sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
38sample
39+0.227079630, -0.358364940, +0.789673924, +0.797860861, +0.388282537, +0.301279783, +1.00000000, +1.00000000
40-0.750372410E-1, +0.538735032, +0.316716909, -0.273296356, +0.489778996, +0.966706753, +2.00000000, +2.00000000
41-0.936355352, +0.597420931E-1, -0.788232565, -0.860334039, -0.197447538E-1, -0.193882942, +3.00000000, +3.00000000
42-0.278710365, -0.743827224, +0.195447206, -0.794361830, -0.711205482, -0.751644015, +4.00000000, +4.00000000
43-0.618216872, -0.917478800, -0.903860807, +0.219692230, +0.309239864, +0.118686557, +5.00000000, +5.00000000
44cov = getCov(sample, dim)
45cov
46+0.191652626, +0.151608974, +0.337621748, +0.584221601, +0.694016516
47+0.151608974, +0.649962544, +1.18247151, +1.39497805, +1.66916168
48+0.337621748, +1.18247151, +2.36879683, +2.86272335, +3.45904779
49+0.584221601, +1.39497805, +2.86272335, +3.91880488, +4.39386129
50+0.694016516, +1.66916168, +3.45904779, +4.39386129, +5.47217083
51mean = getMean(sample, dim)
52mean
53+0.518226504, +0.745450497, +0.407649040, +0.614462256, +1.02600777
54call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
55covA
56+0.191652611, +0.151608959, +0.337621689, +0.584221542, +0.694016457
57-0.664808154E-1, +0.649962544, +1.18247128, +1.39497781, +1.66916156
58-0.104915939, +0.131191656, +2.36879659, +2.86272359, +3.45904708
59+0.540454686E-1, -0.277293436E-1, -0.837030634E-1, +3.91880536, +4.39386177
60+0.744377971E-1, +0.973986648E-2, +0.334038362E-1, -0.121118724, +5.47217131
61cov ! reference
62+0.191652626, +0.151608974, +0.337621748, +0.584221601, +0.694016516
63+0.151608974, +0.649962544, +1.18247151, +1.39497805, +1.66916168
64+0.337621748, +1.18247151, +2.36879683, +2.86272335, +3.45904779
65+0.584221601, +1.39497805, +2.86272335, +3.91880488, +4.39386129
66+0.694016516, +1.66916168, +3.45904779, +4.39386129, +5.47217083
67
68
69dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
70[ndim, nsamA]
71+4, +8
72sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
73sampleA
74-0.551310301, -0.157277822, +0.971014261, -0.359738827, -0.760928988, +0.714867830, +0.142235994, -0.425757647
75+0.422372818, +0.403740168, -0.962555528, +0.580954790, +0.990534782, -0.869223356, +0.600096345, -0.418910384
76+0.248300433, +0.688983202E-1, +0.905438781, +0.222827792, +0.267294407, +0.703831315, -0.539461970, +0.679833889E-1
77+0.317070603, +0.545669913, -0.792849898, +0.106190443, +0.837319851, -0.982849717, +0.589144230E-1, -0.542137980
78covA = getCov(sampleA, dim)
79covA
80+0.333716184, -0.313942522, +0.118647680, -0.274175018
81-0.313942522, +0.475997984, -0.186280936, +0.395940721
82+0.118647680, -0.186280936, +0.165675566, -0.125552014
83-0.274175018, +0.395940721, -0.125552014, +0.372130692
84meanA = getMean(sampleA, dim)
85meanA
86-0.533619374E-1, +0.933762044E-1, +0.243139073, -0.565840453E-1
87sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
88sampleB
89+1.00000000, +1.00000000
90+2.00000000, +2.00000000
91+3.00000000, +3.00000000
92+4.00000000, +4.00000000
93meanB = getMean(sampleB, dim)
94meanB
95+1.00000000, +2.00000000, +3.00000000, +4.00000000
96sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
97sample
98-0.551310301, -0.157277822, +0.971014261, -0.359738827, -0.760928988, +0.714867830, +0.142235994, -0.425757647, +1.00000000, +1.00000000
99+0.422372818, +0.403740168, -0.962555528, +0.580954790, +0.990534782, -0.869223356, +0.600096345, -0.418910384, +2.00000000, +2.00000000
100+0.248300433, +0.688983202E-1, +0.905438781, +0.222827792, +0.267294407, +0.703831315, -0.539461970, +0.679833889E-1, +3.00000000, +3.00000000
101+0.317070603, +0.545669913, -0.792849898, +0.106190443, +0.837319851, -0.982849717, +0.589144230E-1, -0.542137980, +4.00000000, +4.00000000
102cov = getCov(sample, dim)
103cov
104+0.444504410, +0.701843947E-1, +0.559553802, +0.464348227
105+0.701843947E-1, +0.962432802, +0.691982746, +1.55425346
106+0.559553802, +0.691982746, +1.34858572, +1.68890858
107+0.464348227, +1.55425346, +1.68890858, +2.93064475
108mean = getMean(sample, dim)
109mean
110+0.157310456, +0.474700987, +0.794511259, +0.754732788
111call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
112covA
113+0.444504350, +0.701843500E-1, +0.559553742, +0.464348078
114-0.313942522, +0.962432742, +0.691982746, +1.55425334
115+0.118647680, -0.186280936, +1.34858561, +1.68890834
116-0.274175018, +0.395940721, -0.125552014, +2.93064427
117cov ! reference
118+0.444504410, +0.701843947E-1, +0.559553802, +0.464348227
119+0.701843947E-1, +0.962432802, +0.691982746, +1.55425346
120+0.559553802, +0.691982746, +1.34858572, +1.68890858
121+0.464348227, +1.55425346, +1.68890858, +2.93064475
122
123
124dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
125[ndim, nsamA]
126+3, +6
127sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
128sampleA
129+0.424278975, +0.693579197, -0.698462248, +0.275450349, -0.436026931, -0.519645572
130-0.736969709E-1, -0.282396674, +0.293629289, +0.707378626, -0.465216875, -0.768611312
131-0.575455427, -0.202430487, -0.670269847, -0.527434707, -0.659009218, -0.370522380
132covA = getCov(sampleA, dim)
133covA
134+0.278933316, +0.565463416E-1, +0.479285382E-1
135+0.565463416E-1, +0.236861438, -0.289869495E-1
136+0.479285382E-1, -0.289869495E-1, +0.276716053E-1
137meanA = getMean(sampleA, dim)
138meanA
139-0.434710383E-1, -0.981523246E-1, -0.500853717
140sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
141sampleB
142+1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
143+2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
144+3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
145meanB = getMean(sampleB, dim)
146meanB
147+1.00000000, +2.00000000, +3.00000000
148sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
149sample
150+0.424278975, +0.693579197, -0.698462248, +0.275450349, -0.436026931, -0.519645572, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
151-0.736969709E-1, -0.282396674, +0.293629289, +0.707378626, -0.465216875, -0.768611312, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
152-0.575455427, -0.202430487, -0.670269847, -0.527434707, -0.659009218, -0.370522380, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
153cov = getCov(sample, dim)
154cov
155+0.422103763, +0.573660374, +0.931855083
156+0.573660374, +1.22066236, +1.80534399
157+0.931855083, +1.80534399, +3.05376482
158mean = getMean(sample, dim)
159mean
160+0.430833995, +0.855553329, +1.09044349
161call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
162covA
163+0.422103763, +0.573660314, +0.931855142
164+0.565463416E-1, +1.22066247, +1.80534375
165+0.479285382E-1, -0.289869495E-1, +3.05376554
166cov ! reference
167+0.422103763, +0.573660374, +0.931855083
168+0.573660374, +1.22066236, +1.80534399
169+0.931855083, +1.80534399, +3.05376482
170
171
172dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
173[ndim, nsamA]
174+3, +5
175sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
176sampleA
177-0.218133211, +0.466121435, +0.564431906, +0.246266127E-1, +0.267198682
178-0.586136103, -0.261651635, -0.317171335, -0.344371319, +0.193525434
179-0.834189653, +0.647089720, -0.540572762, +0.988125563, +0.634246111
180covA = getCov(sampleA, dim)
181covA
182+0.823129192E-1, +0.321392082E-1, +0.349361412E-1
183+0.321392082E-1, +0.644779801E-1, +0.101800203
184+0.349361412E-1, +0.101800203, +0.525075912
185meanA = getMean(sampleA, dim)
186meanA
187+0.220849082, -0.263161004, +0.178939804
188sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
189sampleB
190+1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
191+2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
192+3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
193meanB = getMean(sampleB, dim)
194meanB
195+1.00000000, +2.00000000, +3.00000000
196sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
197sample
198-0.218133211, +0.466121435, +0.564431906, +0.246266127E-1, +0.267198682, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
199-0.586136103, -0.261651635, -0.317171335, -0.344371319, +0.193525434, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
200-0.834189653, +0.647089720, -0.540572762, +0.988125563, +0.634246111, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
201cov = getCov(sample, dim)
202cov
203+0.192925647, +0.456905842, +0.566975594
204+0.456905842, +1.31271327, +1.64702833
205+0.566975594, +1.64702833, +2.25213218
206mean = getMean(sample, dim)
207mean
208+0.610424519, +0.868419468, +1.58946991
209call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
210covA
211+0.192925483, +0.456905574, +0.566976011
212+0.321392082E-1, +1.31271327, +1.64702845
213+0.349361412E-1, +0.101800203, +2.25213313
214cov ! reference
215+0.192925647, +0.456905842, +0.566975594
216+0.456905842, +1.31271327, +1.64702833
217+0.566975594, +1.64702833, +2.25213218
218
219
220dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
221[ndim, nsamA]
222+2, +4
223sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
224sampleA
225+0.888277292, -0.361251354, -0.188400030, -0.375225544
226+0.958487272, +0.275824308, +0.871028781, +0.552324891
227covA = getCov(sampleA, dim)
228covA
229+0.273873210, +0.101182431
230+0.101182431, +0.731836706E-1
231meanA = getMean(sampleA, dim)
232meanA
233-0.914990902E-2, +0.664416313
234sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
235sampleB
236+1.00000000, +1.00000000
237+2.00000000, +2.00000000
238meanB = getMean(sampleB, dim)
239meanB
240+1.00000000, +2.00000000
241sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
242sample
243+0.888277292, -0.361251354, -0.188400030, -0.375225544, +1.00000000, +1.00000000
244+0.958487272, +0.275824308, +0.871028781, +0.552324891, +2.00000000, +2.00000000
245cov = getCov(sample, dim)
246cov
247+0.408889621, +0.366967022
248+0.366967022, +0.445185512
249mean = getMean(sample, dim)
250mean
251+0.327233404, +1.10961092
252call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
253covA
254+0.408889592, +0.366966993
255+0.101182431, +0.445185483
256cov ! reference
257+0.408889621, +0.366967022
258+0.366967022, +0.445185512
259
260
261dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
262[ndim, nsamA]
263+3, +4
264sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
265sampleA
266-0.408805728, +0.775907993, -0.636894703, +0.961431861
267-0.776486754, -0.453179479, +0.420433640, -0.506294012
268+0.529035807, -0.821887493, -0.978537679, +0.838428497
269covA = getCov(sampleA, dim)
270covA
271+0.494887531, -0.140316248, +0.162549645
272-0.140316248, +0.202187195, -0.254155278
273+0.162549645, -0.254155278, +0.642253160
274meanA = getMean(sampleA, dim)
275meanA
276+0.172909856, -0.328881651, -0.108240217
277sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
278sampleB
279+1.00000000, +1.00000000
280+2.00000000, +2.00000000
281+3.00000000, +3.00000000
282meanB = getMean(sampleB, dim)
283meanB
284+1.00000000, +2.00000000, +3.00000000
285sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
286sample
287-0.408805728, +0.775907993, -0.636894703, +0.961431861, +1.00000000, +1.00000000
288-0.776486754, -0.453179479, +0.420433640, -0.506294012, +2.00000000, +2.00000000
289+0.529035807, -0.821887493, -0.978537679, +0.838428497, +3.00000000, +3.00000000
290cov = getCov(sample, dim)
291cov
292+0.481942356, +0.334498972, +0.679654121
293+0.334498972, +1.34005570, +1.43916845
294+0.679654121, +1.43916845, +2.57509255
295mean = getMean(sample, dim)
296mean
297+0.448606580, +0.447412252, +0.927839875
298call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
299covA
300+0.481942356, +0.334499180, +0.679654121
301-0.140316248, +1.34005594, +1.43916833
302+0.162549645, -0.254155278, +2.57509232
303cov ! reference
304+0.481942356, +0.334498972, +0.679654121
305+0.334498972, +1.34005570, +1.43916845
306+0.679654121, +1.43916845, +2.57509255
307
308
309dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
310[ndim, nsamA]
311+3, +5
312sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
313sampleA
314-0.569231153, -0.451639652, +0.982924342, +0.521308780, -0.397634029
315-0.688037276, -0.937248707, -0.525768638, +0.735185862, +0.772388220
316-0.726474762, -0.429679394, -0.178660154E-1, +0.574117064, -0.804270387
317covA = getCov(sampleA, dim)
318covA
319+0.384509772, +0.770648494E-1, +0.246640906
320+0.770648494E-1, +0.536506355, +0.106422737
321+0.246640906, +0.106422737, +0.258965939
322meanA = getMean(sampleA, dim)
323meanA
324+0.171456579E-1, -0.128696114, -0.280834705
325sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
326sampleB
327+1.00000000, +1.00000000, +1.00000000
328+2.00000000, +2.00000000, +2.00000000
329+3.00000000, +3.00000000, +3.00000000
330meanB = getMean(sampleB, dim)
331meanB
332+1.00000000, +2.00000000, +3.00000000
333sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
334sample
335-0.569231153, -0.451639652, +0.982924342, +0.521308780, -0.397634029, +1.00000000, +1.00000000, +1.00000000
336-0.688037276, -0.937248707, -0.525768638, +0.735185862, +0.772388220, +2.00000000, +2.00000000, +2.00000000
337-0.726474762, -0.429679394, -0.178660154E-1, +0.574117064, -0.804270387, +3.00000000, +3.00000000, +3.00000000
338cov = getCov(sample, dim)
339cov
340+0.466725588, +0.538524508, +0.909912229
341+0.538524508, +1.39735043, +1.70336556
342+0.909912229, +1.70336556, +2.68463683
343mean = getMean(sample, dim)
344mean
345+0.385716021, +0.669564962, +0.949478328
346call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
347covA
348+0.466725498, +0.538524508, +0.909912109
349+0.770648494E-1, +1.39735103, +1.70336592
350+0.246640906, +0.106422737, +2.68463731
351cov ! reference
352+0.466725588, +0.538524508, +0.909912229
353+0.538524508, +1.39735043, +1.70336556
354+0.909912229, +1.70336556, +2.68463683
355
356
357dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
358[ndim, nsamA]
359+3, +6
360sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
361sampleA
362-0.798716068, +0.687268138, +0.721641660, +0.103300452, +0.665781736, -0.926086307
363-0.204496264, -0.612563252, +0.985654831, +0.551976085, -0.908548117, -0.813949108
364-0.478522778, +0.620089173, +0.222396135, +0.836520076, -0.194923520, -0.198452473
365covA = getCov(sampleA, dim)
366covA
367+0.484732240, +0.122536272, +0.174719974
368+0.122536272, +0.502318203, +0.145393625
369+0.174719974, +0.145393625, +0.221921489
370meanA = getMean(sampleA, dim)
371meanA
372+0.755316019E-1, -0.166987643, +0.134517774
373sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
374sampleB
375+1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
376+2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
377+3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
378meanB = getMean(sampleB, dim)
379meanB
380+1.00000000, +2.00000000, +3.00000000
381sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
382sample
383-0.798716068, +0.687268138, +0.721641660, +0.103300452, +0.665781736, -0.926086307, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
384-0.204496264, -0.612563252, +0.985654831, +0.551976085, -0.908548117, -0.813949108, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
385-0.478522778, +0.620089173, +0.222396135, +0.836520076, -0.194923520, -0.198452473, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
386cov = getCov(sample, dim)
387cov
388+0.476294279, +0.563526750, +0.752090454
389+0.563526750, +1.43824840, +1.61884189
390+0.752090454, +1.61884189, +2.15682983
391mean = getMean(sample, dim)
392mean
393+0.495744556, +0.818006694, +1.43700969
394call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
395covA
396+0.476294070, +0.563526750, +0.752090514
397+0.122536272, +1.43824840, +1.61884236
398+0.174719974, +0.145393625, +2.15683031
399cov ! reference
400+0.476294279, +0.563526750, +0.752090454
401+0.563526750, +1.43824840, +1.61884189
402+0.752090454, +1.61884189, +2.15682983
403
404
405dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
406[ndim, nsamA]
407+5, +10
408sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
409sampleA
410-0.965526342, -0.860236168, +0.942549229, -0.912460089, +0.439404368, +0.771071434, -0.612631798, -0.877833009, -0.394182920, +0.343142152
411+0.788126230, +0.312078595, -0.690233588, -0.141911268, -0.470047116, +0.203009129, +0.932999730, +0.401859879, +0.223711848, -0.686202168
412-0.363577724, -0.230214119, +0.158134699E-1, -0.870528579, +0.861331940, -0.982983112, -0.297505498, -0.282592535, +0.752684712, -0.494356394
413-0.679321527, -0.381837010, -0.272285342, -0.469141126, -0.599793077, +0.273284912, -0.844006062, -0.455271244, +0.839556217, +0.444440126
414-0.553802729, +0.634016395, +0.451936364, -0.398380399, -0.130800009, -0.390780568, +0.650177121, +0.666118860, -0.560217023, +0.421813250
415covA = getCov(sampleA, dim)
416covA
417+0.514760613, -0.266277045, +0.540476441E-1, +0.138521343, -0.294718752E-2
418-0.266277045, +0.295387268, -0.568471216E-1, -0.962909013E-1, -0.121340277E-1
419+0.540476441E-1, -0.568471216E-1, +0.327275723, +0.339992009E-1, -0.181579292E-1
420+0.138521343, -0.962909013E-1, +0.339992009E-1, +0.269811213, -0.795839578E-1
421-0.294718752E-2, -0.121340277E-1, -0.181579292E-1, -0.795839578E-1, +0.253723711
422meanA = getMean(sampleA, dim)
423meanA
424-0.212670326, +0.873391256E-1, -0.189192787, -0.214437410, +0.790081248E-1
425sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
426sampleB
427+1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
428+2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
429+3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
430+4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000
431+5.00000000, +5.00000000, +5.00000000, +5.00000000, +5.00000000
432meanB = getMean(sampleB, dim)
433meanB
434+1.00000000, +2.00000000, +3.00000000, +4.00000000, +5.00000000
435sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
436sample
437-0.965526342, -0.860236168, +0.942549229, -0.912460089, +0.439404368, +0.771071434, -0.612631798, -0.877833009, -0.394182920, +0.343142152, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
438+0.788126230, +0.312078595, -0.690233588, -0.141911268, -0.470047116, +0.203009129, +0.932999730, +0.401859879, +0.223711848, -0.686202168, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
439-0.363577724, -0.230214119, +0.158134699E-1, -0.870528579, +0.861331940, -0.982983112, -0.297505498, -0.282592535, +0.752684712, -0.494356394, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
440-0.679321527, -0.381837010, -0.272285342, -0.469141126, -0.599793077, +0.273284912, -0.844006062, -0.455271244, +0.839556217, +0.444440126, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000
441-0.553802729, +0.634016395, +0.451936364, -0.398380399, -0.130800009, -0.390780568, +0.650177121, +0.666118860, -0.560217023, +0.421813250, +5.00000000, +5.00000000, +5.00000000, +5.00000000, +5.00000000
442cov = getCov(sample, dim)
443cov
444+0.669967175, +0.337910295, +0.895462871, +1.22806406, +1.32415521
445+0.337910295, +1.00987422, +1.31762314, +1.72709262, +2.08350801
446+0.895462871, +1.31762314, +2.47839570, +3.00947809, +3.47544885
447+1.22806406, +1.72709262, +3.00947809, +4.12687016, +4.55565596
448+1.32415521, +2.08350801, +3.47544885, +4.55565596, +5.55051756
449mean = getMean(sample, dim)
450mean
451+0.191553131, +0.724892795, +0.873871505, +1.19037509, +1.71933877
452call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
453covA
454+0.669966936, +0.337910146, +0.895462751, +1.22806382, +1.32415533
455-0.266277045, +1.00987399, +1.31762278, +1.72709239, +2.08350801
456+0.540476441E-1, -0.568471216E-1, +2.47839499, +3.00947809, +3.47544837
457+0.138521343, -0.962909013E-1, +0.339992009E-1, +4.12687016, +4.55565786
458-0.294718752E-2, -0.121340277E-1, -0.181579292E-1, -0.795839578E-1, +5.55051804
459cov ! reference
460+0.669967175, +0.337910295, +0.895462871, +1.22806406, +1.32415521
461+0.337910295, +1.00987422, +1.31762314, +1.72709262, +2.08350801
462+0.895462871, +1.31762314, +2.47839570, +3.00947809, +3.47544885
463+1.22806406, +1.72709262, +3.00947809, +4.12687016, +4.55565596
464+1.32415521, +2.08350801, +3.47544885, +4.55565596, +5.55051756
465
466
467dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
468[ndim, nsamA]
469+3, +6
470sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
471sampleA
472-0.465553045, -0.720241547, -0.776401401, +0.695394039, +0.742467761, -0.963065147
473+0.277769089, -0.458490849E-2, -0.519737720, +0.939446449, -0.262204885, +0.586462021E-2
474+0.497704744E-1, -0.568358302, +0.536094904E-1, +0.556563258, -0.251256227E-1, -0.264130235
475covA = getCov(sampleA, dim)
476covA
477+0.488647699, +0.139781877, +0.153051645
478+0.139781877, +0.211147711, +0.884750634E-1
479+0.153051645, +0.884750634E-1, +0.117004782
480meanA = getMean(sampleA, dim)
481meanA
482-0.247899890, +0.727587789E-1, -0.329451561E-1
483sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
484sampleB
485+1.00000000, +1.00000000
486+2.00000000, +2.00000000
487+3.00000000, +3.00000000
488meanB = getMean(sampleB, dim)
489meanB
490+1.00000000, +2.00000000, +3.00000000
491sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
492sample
493-0.465553045, -0.720241547, -0.776401401, +0.695394039, +0.742467761, -0.963065147, +1.00000000, +1.00000000
494+0.277769089, -0.458490849E-2, -0.519737720, +0.939446449, -0.262204885, +0.586462021E-2, +2.00000000, +2.00000000
495+0.497704744E-1, -0.568358302, +0.536094904E-1, +0.556563258, -0.251256227E-1, -0.264130235, +3.00000000, +3.00000000
496cov = getCov(sample, dim)
497cov
498+0.658470869, +0.555774629, +0.824440956
499+0.555774629, +0.854784250, +1.16233444
500+0.824440956, +1.16233444, +1.81252050
501mean = getMean(sample, dim)
502mean
503+0.640750825E-1, +0.554569066, +0.725291133
504call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
505covA
506+0.658470929, +0.555774689, +0.824440956
507+0.139781877, +0.854784310, +1.16233444
508+0.153051645, +0.884750634E-1, +1.81252027
509cov ! reference
510+0.658470869, +0.555774629, +0.824440956
511+0.555774629, +0.854784250, +1.16233444
512+0.824440956, +1.16233444, +1.81252050
513
514
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 8553 of file pm_sampleCov.F90.


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