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

Return the covariance and mean of a sample that results from the merger of two separate (potentially weighted) non-singular \(A\) and singular \(B\) samples.
More...

Detailed Description

Return the covariance and mean of a sample that results from the merger of two separate (potentially weighted) non-singular \(A\) and singular \(B\) samples.

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]covA: The input contiguous matrix of shape (1 : ndim, 1 : ndim) of,
  1. type complex of kind any supported by the processor (e.g., CK, CK32, CK64, or CK128),
  2. type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128),
containing the biased covariance of the first sample that must be merged with the second sample.
[in]meanA: The input object of the same type and kind as the input argument covA of size size(covA, 1), containing the mean of the first sample that must be merged with the mean of the second sample meanB.
[in]meanB: The input or input/output object of the same type and kind and rank as the input argument covA of size size(covA, 1), containing the mean of the second sample that must be merged with the mean of the first sample meanA.
If the input argument mean is missing, then meanB contains the updated mean of the merged sample on return.
Otherwise, the contents of meanB remain intact upon return.
[in]fracA: The input scalar of type real of the same kind as covA, containing the ratio of the sum of the weights of all points in sample \(A\) to sum of weights of all points in the merged sample.
If the sample is unweighted, then fracA is simply size(sampleA) / (size(sampleA) + size(sampleB)).
[in]subset: The input scalar constant that can be:
  1. The constant lowDia, implying that only the lower-diagonal subset of the input cov, and covA matrices must be accessed and/or manipulated.
  2. The constant uppDia, implying that only the upper-diagonal subset of the input cov, 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 setCovMeanUpdated(covA(1:ndim, 1:ndim), meanA(1:ndim), meanB(1:ndim), fracA, subset)
Return the covariance and mean of a sample that results from the merger of two separate (potentially ...
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(meanB) == shape(covA)) must hold for the corresponding input arguments.
The condition all(size(meanA) == shape(covA)) must hold for the corresponding input arguments.
These conditions are verified only if the library is built with the preprocessor macro CHECK_ENABLED=1.
The pure procedure(s) documented herein become impure when the ParaMonte library is compiled with preprocessor macro CHECK_ENABLED=1.
By default, these procedures are pure in release build and impure in debug and testing builds.
See also
getCor
setCor
getCov
setCov
getVar
setVar
getMean
setMean
getCovMerged
setCovMerged
setCovMeanUpdated
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 setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)")
72 call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
73 call disp%show("meanA")
74 call disp%show( meanA )
75 call disp%show("mean ! reference")
76 call disp%show( mean )
77 call disp%show("covA")
78 call disp%show( covA )
79 call disp%show("cov ! reference")
80 call disp%show( cov )
81 call disp%skip()
82 end do
83 end block
84
85end 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+1, +2
10sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
11sampleA
12-0.684280396E-1, +0.365089059
13covA = getCov(sampleA, dim)
14covA
15+0.469842702E-1
16meanA = getMean(sampleA, dim)
17meanA
18+0.148330510
19sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
20sampleB
21+1.00000000, +1.00000000
22meanB = getMean(sampleB, dim)
23meanB
24+1.00000000
25sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
26sample
27-0.684280396E-1, +0.365089059, +1.00000000, +1.00000000
28cov = getCov(sample, dim)
29cov
30+0.204827398
31mean = getMean(sample, dim)
32mean
33+0.574165225
34call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
35meanA
36+0.574165225
37mean ! reference
38+0.574165225
39covA
40+0.204827368
41cov ! reference
42+0.204827398
43
44
45dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
46[ndim, nsamA]
47+2, +4
48sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
49sampleA
50-0.268353105, +0.902813435, -0.625329852, +0.964020491
51+0.403311968, -0.914786935, -0.815971375, -0.252722144
52covA = getCov(sampleA, dim)
53covA
54+0.492675632, -0.707636178E-1
55-0.707636178E-1, +0.276235223
56meanA = getMean(sampleA, dim)
57meanA
58+0.243287742, -0.395042121
59sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
60sampleB
61+1.00000000, +1.00000000
62+2.00000000, +2.00000000
63meanB = getMean(sampleB, dim)
64meanB
65+1.00000000, +2.00000000
66sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
67sample
68-0.268353105, +0.902813435, -0.625329852, +0.964020491, +1.00000000, +1.00000000
69+0.403311968, -0.914786935, -0.815971375, -0.252722144, +2.00000000, +2.00000000
70cov = getCov(sample, dim)
71cov
72+0.455697894, +0.355570376
73+0.355570376, +1.45887375
74mean = getMean(sample, dim)
75mean
76+0.495525181, +0.403305262
77call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
78meanA
79+0.495525151, +0.403305203
80mean ! reference
81+0.495525181, +0.403305262
82covA
83+0.455697864, +0.355570406
84-0.707636178E-1, +1.45887387
85cov ! reference
86+0.455697894, +0.355570376
87+0.355570376, +1.45887375
88
89
90dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
91[ndim, nsamA]
92+4, +8
93sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
94sampleA
95-0.593934536, +0.207599401E-1, -0.655868173, -0.779442549, +0.526072621, -0.365898728, +0.445330501, -0.331532955E-1
96+0.291546583, +0.634677649, -0.604514360, +0.530744076, -0.817532420, -0.223498583, -0.764541626E-1, +0.511463046
97+0.456022978, -0.978993177, +0.421995759, -0.601902843, -0.836045980, +0.292365432, -0.753318071E-1, +0.341084838
98-0.860185385, -0.399177313, +0.940710902, -0.976643085, +0.709389567, -0.834399819, -0.340094209, -0.886177421
99covA = getCov(sampleA, dim)
100covA
101+0.217890665, -0.665319413E-1, -0.108314961, +0.910222828E-1
102-0.665319413E-1, +0.264137685, -0.292970389E-1, -0.291291952
103-0.108314961, -0.292970389E-1, +0.311621130, -0.568497479E-1
104+0.910222828E-1, -0.291291952, -0.568497479E-1, +0.495364457
105meanA = getMean(sampleA, dim)
106meanA
107-0.179516777, +0.308039784E-1, -0.122600600, -0.330822110
108sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
109sampleB
110+1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
111+2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
112+3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
113+4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000
114meanB = getMean(sampleB, dim)
115meanB
116+1.00000000, +2.00000000, +3.00000000, +4.00000000
117sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
118sample
119-0.593934536, +0.207599401E-1, -0.655868173, -0.779442549, +0.526072621, -0.365898728, +0.445330501, -0.331532955E-1, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
120+0.291546583, +0.634677649, -0.604514360, +0.530744076, -0.817532420, -0.223498583, -0.764541626E-1, +0.511463046, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
121+0.456022978, -0.978993177, +0.421995759, -0.601902843, -0.836045980, +0.292365432, -0.753318071E-1, +0.341084838, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
122-0.860185385, -0.399177313, +0.940710902, -0.976643085, +0.709389567, -0.834399819, -0.340094209, -0.886177421, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000
123cov = getCov(sample, dim)
124cov
125+0.456760049, +0.547408938, +0.866632640, +1.32258058
126+0.547408938, +1.10150218, +1.52260447, +1.98641431
127+0.866632640, +1.52260447, +2.59346914, +3.35243177
128+1.32258058, +1.98641431, +3.35243177, +4.93668890
129mean = getMean(sample, dim)
130mean
131+0.410241604, +1.01540196, +1.43869972, +1.83458900
132call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
133meanA
134+0.410241604, +1.01540196, +1.43869972, +1.83458900
135mean ! reference
136+0.410241604, +1.01540196, +1.43869972, +1.83458900
137covA
138+0.456760317, +0.547408998, +0.866632462, +1.32258046
139-0.665319413E-1, +1.10150218, +1.52260458, +1.98641336
140-0.108314961, -0.292970389E-1, +2.59346914, +3.35243177
141+0.910222828E-1, -0.291291952, -0.568497479E-1, +4.93668699
142cov ! reference
143+0.456760049, +0.547408938, +0.866632640, +1.32258058
144+0.547408938, +1.10150218, +1.52260447, +1.98641431
145+0.866632640, +1.52260447, +2.59346914, +3.35243177
146+1.32258058, +1.98641431, +3.35243177, +4.93668890
147
148
149dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
150[ndim, nsamA]
151+5, +8
152sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
153sampleA
154+0.733378291, +0.400316954, +0.992570400, -0.277933598, +0.209508896, -0.289315581, -0.711770058, +0.365519166
155-0.243218303, -0.125657320E-1, -0.540019751, +0.618052006, -0.371950865E-1, +0.283687711, +0.845891237E-1, +0.953742743
156+0.403027534E-1, -0.379487276, -0.893040180, -0.537527919, +0.737740278, -0.866895914E-1, +0.905394912, -0.542064905
157+0.802765369, +0.744126678, +0.351109266, +0.857968211, +0.307981968, -0.266614795, +0.751134157E-1, +0.377030611
158-0.834305286, +0.440862179, +0.113449216, +0.123936653, +0.819953203, +0.361718059, +0.250027895, -0.148756504E-1
159covA = getCov(sampleA, dim)
160covA
161+0.284437597, -0.111183897, -0.173499659, +0.806202888E-1, -0.872029662E-1
162-0.111183897, +0.197295502, -0.303625278E-1, -0.434471667E-2, +0.146652460E-1
163-0.173499659, -0.303625278E-1, +0.353264838, -0.754991397E-1, +0.697719678E-1
164+0.806202888E-1, -0.434471667E-2, -0.754991397E-1, +0.131422937, -0.672960281E-1
165-0.872029662E-1, +0.146652460E-1, +0.697719678E-1, -0.672960281E-1, +0.198232889
166meanA = getMean(sampleA, dim)
167meanA
168+0.177784294, +0.138384089, -0.944214910E-1, +0.406185061, +0.157595783
169sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
170sampleB
171+1.00000000, +1.00000000, +1.00000000, +1.00000000
172+2.00000000, +2.00000000, +2.00000000, +2.00000000
173+3.00000000, +3.00000000, +3.00000000, +3.00000000
174+4.00000000, +4.00000000, +4.00000000, +4.00000000
175+5.00000000, +5.00000000, +5.00000000, +5.00000000
176meanB = getMean(sampleB, dim)
177meanB
178+1.00000000, +2.00000000, +3.00000000, +4.00000000, +5.00000000
179sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
180sample
181+0.733378291, +0.400316954, +0.992570400, -0.277933598, +0.209508896, -0.289315581, -0.711770058, +0.365519166, +1.00000000, +1.00000000, +1.00000000, +1.00000000
182-0.243218303, -0.125657320E-1, -0.540019751, +0.618052006, -0.371950865E-1, +0.283687711, +0.845891237E-1, +0.953742743, +2.00000000, +2.00000000, +2.00000000, +2.00000000
183+0.403027534E-1, -0.379487276, -0.893040180, -0.537527919, +0.737740278, -0.866895914E-1, +0.905394912, -0.542064905, +3.00000000, +3.00000000, +3.00000000, +3.00000000
184+0.802765369, +0.744126678, +0.351109266, +0.857968211, +0.307981968, -0.266614795, +0.751134157E-1, +0.377030611, +4.00000000, +4.00000000, +4.00000000, +4.00000000
185-0.834305286, +0.440862179, +0.113449216, +0.123936653, +0.819953203, +0.361718059, +0.250027895, -0.148756504E-1, +5.00000000, +5.00000000, +5.00000000, +5.00000000
186cov = getCov(sample, dim)
187cov
188+0.339855909, +0.266021907, +0.449729562, +0.710389495, +0.826642752
189+0.266021907, +0.901666641, +1.25989723, +1.48383760, +2.01304269
190+0.449729562, +1.25989723, +2.36338663, +2.42095137, +3.37639022
191+0.710389495, +1.48383760, +2.42095137, +2.95772743, +3.82240295
192+0.826642752, +2.01304269, +3.37639022, +3.82240295, +5.34301949
193mean = getMean(sample, dim)
194mean
195+0.451856226, +0.758922756, +0.937052369, +1.60412347, +1.77173042
196call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
197meanA
198+0.451856196, +0.758922696, +0.937052250, +1.60412335, +1.77173042
199mean ! reference
200+0.451856226, +0.758922756, +0.937052369, +1.60412347, +1.77173042
201covA
202+0.339855850, +0.266021758, +0.449729443, +0.710389256, +0.826642573
203-0.111183897, +0.901666701, +1.25989687, +1.48383737, +2.01304269
204-0.173499659, -0.303625278E-1, +2.36338592, +2.42095089, +3.37638998
205+0.806202888E-1, -0.434471667E-2, -0.754991397E-1, +2.95772743, +3.82240343
206-0.872029662E-1, +0.146652460E-1, +0.697719678E-1, -0.672960281E-1, +5.34301710
207cov ! reference
208+0.339855909, +0.266021907, +0.449729562, +0.710389495, +0.826642752
209+0.266021907, +0.901666641, +1.25989723, +1.48383760, +2.01304269
210+0.449729562, +1.25989723, +2.36338663, +2.42095137, +3.37639022
211+0.710389495, +1.48383760, +2.42095137, +2.95772743, +3.82240295
212+0.826642752, +2.01304269, +3.37639022, +3.82240295, +5.34301949
213
214
215dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
216[ndim, nsamA]
217+5, +8
218sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
219sampleA
220-0.455495119, -0.212714911, +0.366974711, -0.638763785, +0.787898183, -0.872093558, -0.490419269, +0.613118291
221-0.332322359, +0.420439005, -0.197796822, -0.253468513, -0.140622854E-1, -0.280755877, -0.934448242E-1, +0.466843963
222-0.440102935, -0.767717004, -0.297649980, +0.910135508E-1, +0.422972202, -0.851113081, -0.766758442, -0.621585846
223+0.469906926, -0.927305579, -0.865140438, -0.820937157, +0.264079213, -0.153295875, +0.923818588, +0.461553335E-1
224-0.102893710, +0.685007453, -0.170946002, -0.937471271, +0.172721624, +0.166361809, +0.262119770, -0.244860768
225covA = getCov(sampleA, dim)
226covA
227+0.336447775, +0.856267437E-1, +0.112844408, -0.158086419E-2, +0.163025688E-1
228+0.856267437E-1, +0.857689455E-1, -0.301464554E-1, -0.287609845E-1, +0.499553308E-1
229+0.112844408, -0.301464554E-1, +0.181584075, -0.295211729E-1, -0.876259059E-1
230-0.158086419E-2, -0.287609845E-1, -0.295211729E-1, +0.413843930, +0.577896200E-1
231+0.163025688E-1, +0.499553308E-1, -0.876259059E-1, +0.577896200E-1, +0.196307361
232meanA = getMean(sampleA, dim)
233meanA
234-0.112686932, -0.355709642E-1, -0.403867692, -0.132839873, -0.212451369E-1
235sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
236sampleB
237+1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
238+2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
239+3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
240+4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000
241+5.00000000, +5.00000000, +5.00000000, +5.00000000, +5.00000000
242meanB = getMean(sampleB, dim)
243meanB
244+1.00000000, +2.00000000, +3.00000000, +4.00000000, +5.00000000
245sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
246sample
247-0.455495119, -0.212714911, +0.366974711, -0.638763785, +0.787898183, -0.872093558, -0.490419269, +0.613118291, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
248-0.332322359, +0.420439005, -0.197796822, -0.253468513, -0.140622854E-1, -0.280755877, -0.934448242E-1, +0.466843963, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
249-0.440102935, -0.767717004, -0.297649980, +0.910135508E-1, +0.422972202, -0.851113081, -0.766758442, -0.621585846, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
250+0.469906926, -0.927305579, -0.865140438, -0.820937157, +0.264079213, -0.153295875, +0.923818588, +0.461553335E-1, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000
251-0.102893710, +0.685007453, -0.170946002, -0.937471271, +0.172721624, +0.166361809, +0.262119770, -0.244860768, +5.00000000, +5.00000000, +5.00000000, +5.00000000, +5.00000000
252cov = getCov(sample, dim)
253cov
254+0.500079811, +0.588777065, +0.965878010, +1.08744299, +1.33241689
255+0.588777065, +1.03350282, +1.62140429, +1.97346997, +2.44993711
256+0.965878010, +1.62140429, +2.85406685, +3.31145191, +3.99143839
257+1.08744299, +1.97346997, +3.31145191, +4.29736328, +4.94727993
258+1.33241689, +2.44993711, +3.99143839, +4.94727993, +6.08835697
259mean = getMean(sample, dim)
260mean
261+0.315269589, +0.747340977, +0.905312181, +1.45671391, +1.91000319
262call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
263meanA
264+0.315269560, +0.747340918, +0.905312061, +1.45671380, +1.91000295
265mean ! reference
266+0.315269589, +0.747340977, +0.905312181, +1.45671391, +1.91000319
267covA
268+0.500079572, +0.588776886, +0.965877891, +1.08744276, +1.33241642
269+0.856267437E-1, +1.03350234, +1.62140417, +1.97346950, +2.44993687
270+0.112844408, -0.301464554E-1, +2.85406709, +3.31145191, +3.99143791
271-0.158086419E-2, -0.287609845E-1, -0.295211729E-1, +4.29736233, +4.94727898
272+0.163025688E-1, +0.499553308E-1, -0.876259059E-1, +0.577896200E-1, +6.08835459
273cov ! reference
274+0.500079811, +0.588777065, +0.965878010, +1.08744299, +1.33241689
275+0.588777065, +1.03350282, +1.62140429, +1.97346997, +2.44993711
276+0.965878010, +1.62140429, +2.85406685, +3.31145191, +3.99143839
277+1.08744299, +1.97346997, +3.31145191, +4.29736328, +4.94727993
278+1.33241689, +2.44993711, +3.99143839, +4.94727993, +6.08835697
279
280
281dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
282[ndim, nsamA]
283+2, +4
284sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
285sampleA
286+0.828679800, +0.744160414E-1, -0.927911043, +0.700528622E-1
287+0.508560896, +0.399140000, -0.462279916, +0.668952584
288covA = getCov(sampleA, dim)
289covA
290+0.389415622, +0.228587538
291+0.228587538, +0.192172512
292meanA = getMean(sampleA, dim)
293meanA
294+0.113094151E-1, +0.278593391
295sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
296sampleB
297+1.00000000, +1.00000000
298+2.00000000, +2.00000000
299meanB = getMean(sampleB, dim)
300meanB
301+1.00000000, +2.00000000
302sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
303sample
304+0.828679800, +0.744160414E-1, -0.927911043, +0.700528622E-1, +1.00000000, +1.00000000
305+0.508560896, +0.399140000, -0.462279916, +0.668952584, +2.00000000, +2.00000000
306cov = getCov(sample, dim)
307cov
308+0.476834714, +0.530600309
309+0.530600309, +0.786612928
310mean = getMean(sample, dim)
311mean
312+0.340872943, +0.852395654
313call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
314meanA
315+0.340872914, +0.852395535
316mean ! reference
317+0.340872943, +0.852395654
318covA
319+0.476834655, +0.530600250
320+0.228587538, +0.786612868
321cov ! reference
322+0.476834714, +0.530600309
323+0.530600309, +0.786612928
324
325
326dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
327[ndim, nsamA]
328+5, +10
329sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
330sampleA
331+0.287277341, +0.794893503E-1, +0.801655412, -0.965929627, -0.381404519, -0.828216672, -0.221018553, -0.155552030, -0.803939700, +0.885947347
332-0.303014159, -0.804553628, +0.277642965, +0.855230093, -0.699876666, +0.391191125, -0.355965853, +0.128044605, +0.169337988, +0.272277951
333+0.427664280, -0.627458572, +0.705642462, +0.360101581, +0.808489203, -0.322374701, +0.445165873, +0.394420028, +0.174618483, +0.323376656E-1
334+0.555742264, +0.232821226, -0.314476013, -0.157380819, -0.738346696, +0.928263068, +0.828882337, +0.651695967, +0.877295494, -0.625211120
335+0.237431645, +0.377485633, -0.627346039, +0.826566100, +0.673902035, -0.985977411, +0.241273165, -0.916727066, -0.110224962, +0.321837664
336covA = getCov(sampleA, dim)
337covA
338+0.383075744, -0.656802580E-1, +0.290214475E-1, -0.166139960, -0.175538305E-1
339-0.656802580E-1, +0.243591830, +0.134298000E-1, +0.845811982E-2, -0.834316984E-1
340+0.290214475E-1, +0.134298000E-1, +0.177173138, -0.861299261E-1, +0.310170483E-1
341-0.166139960, +0.845811982E-2, -0.861299261E-1, +0.366439730, -0.182969794
342-0.175538305E-1, -0.834316984E-1, +0.310170483E-1, -0.182969794, +0.371612370
343meanA = getMean(sampleA, dim)
344meanA
345-0.130169168, -0.696855783E-2, +0.239860639, +0.223928556, +0.382207637E-2
346sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
347sampleB
348+1.00000000, +1.00000000, +1.00000000, +1.00000000
349+2.00000000, +2.00000000, +2.00000000, +2.00000000
350+3.00000000, +3.00000000, +3.00000000, +3.00000000
351+4.00000000, +4.00000000, +4.00000000, +4.00000000
352+5.00000000, +5.00000000, +5.00000000, +5.00000000
353meanB = getMean(sampleB, dim)
354meanB
355+1.00000000, +2.00000000, +3.00000000, +4.00000000, +5.00000000
356sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
357sample
358+0.287277341, +0.794893503E-1, +0.801655412, -0.965929627, -0.381404519, -0.828216672, -0.221018553, -0.155552030, -0.803939700, +0.885947347, +1.00000000, +1.00000000, +1.00000000, +1.00000000
359-0.303014159, -0.804553628, +0.277642965, +0.855230093, -0.699876666, +0.391191125, -0.355965853, +0.128044605, +0.169337988, +0.272277951, +2.00000000, +2.00000000, +2.00000000, +2.00000000
360+0.427664280, -0.627458572, +0.705642462, +0.360101581, +0.808489203, -0.322374701, +0.445165873, +0.394420028, +0.174618483, +0.323376656E-1, +3.00000000, +3.00000000, +3.00000000, +3.00000000
361+0.555742264, +0.232821226, -0.314476013, -0.157380819, -0.738346696, +0.928263068, +0.828882337, +0.651695967, +0.877295494, -0.625211120, +4.00000000, +4.00000000, +4.00000000, +4.00000000
362+0.237431645, +0.377485633, -0.627346039, +0.826566100, +0.673902035, -0.985977411, +0.241273165, -0.916727066, -0.110224962, +0.321837664, +5.00000000, +5.00000000, +5.00000000, +5.00000000
363cov = getCov(sample, dim)
364cov
365+0.534295440, +0.415986359, +0.657346904, +0.752267301, +1.13981390
366+0.415986359, +0.996019125, +1.14010549, +1.55266523, +1.98676753
367+0.657346904, +1.14010549, +1.68132150, +2.06551623, +2.83647060
368+0.752267301, +1.55266523, +2.06551623, +3.17168450, +3.71949601
369+1.13981390, +1.98676753, +2.83647060, +3.71949601, +5.35968161
370mean = getMean(sample, dim)
371mean
372+0.192736328, +0.566451073, +1.02847195, +1.30280614, +1.43130159
373call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
374meanA
375+0.192736298, +0.566451013, +1.02847183, +1.30280602, +1.43130136
376mean ! reference
377+0.192736328, +0.566451073, +1.02847195, +1.30280614, +1.43130159
378covA
379+0.534295440, +0.415986329, +0.657346845, +0.752267241, +1.13981390
380-0.656802580E-1, +0.996019185, +1.14010561, +1.55266523, +1.98676741
381+0.290214475E-1, +0.134298000E-1, +1.68132162, +2.06551623, +2.83647108
382-0.166139960, +0.845811982E-2, -0.861299261E-1, +3.17168474, +3.71949625
383-0.175538305E-1, -0.834316984E-1, +0.310170483E-1, -0.182969794, +5.35968161
384cov ! reference
385+0.534295440, +0.415986359, +0.657346904, +0.752267301, +1.13981390
386+0.415986359, +0.996019125, +1.14010549, +1.55266523, +1.98676753
387+0.657346904, +1.14010549, +1.68132150, +2.06551623, +2.83647060
388+0.752267301, +1.55266523, +2.06551623, +3.17168450, +3.71949601
389+1.13981390, +1.98676753, +2.83647060, +3.71949601, +5.35968161
390
391
392dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
393[ndim, nsamA]
394+2, +3
395sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
396sampleA
397-0.783626199, +0.600347757, -0.125415206
398-0.989058852, -0.353696346, +0.567558169
399covA = getCov(sampleA, dim)
400covA
401+0.319484204, +0.137254998
402+0.137254998, +0.408383608
403meanA = getMean(sampleA, dim)
404meanA
405-0.102897882, -0.258399010
406sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
407sampleB
408+1.00000000, +1.00000000, +1.00000000
409+2.00000000, +2.00000000, +2.00000000
410meanB = getMean(sampleB, dim)
411meanB
412+1.00000000, +2.00000000
413sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
414sample
415-0.783626199, +0.600347757, -0.125415206, +1.00000000, +1.00000000, +1.00000000
416-0.989058852, -0.353696346, +0.567558169, +2.00000000, +2.00000000, +2.00000000
417cov = getCov(sample, dim)
418cov
419+0.463837951, +0.691323280
420+0.691323280, +1.47928369
421mean = getMean(sample, dim)
422mean
423+0.448551059, +0.870800495
424call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
425meanA
426+0.448551059, +0.870800495
427mean ! reference
428+0.448551059, +0.870800495
429covA
430+0.463838041, +0.691323340
431+0.137254998, +1.47928333
432cov ! reference
433+0.463837951, +0.691323280
434+0.691323280, +1.47928369
435
436
437dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
438[ndim, nsamA]
439+3, +5
440sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
441sampleA
442-0.720906854, +0.675368071, +0.571119785E-1, -0.160129070E-1, -0.181246638
443+0.969111085, +0.543625951, +0.440006852, +0.736594915, -0.383182168
444-0.935801268, -0.906371474, -0.433654904, -0.458913803, -0.395189404
445covA = getCov(sampleA, dim)
446covA
447+0.201060250, -0.326123498E-1, +0.924825654E-4
448-0.326123498E-1, +0.210808143, -0.666830912E-1
449+0.924825654E-4, -0.666830912E-1, +0.585545860E-1
450meanA = getMean(sampleA, dim)
451meanA
452-0.371372700E-1, +0.461231321, -0.625986218
453sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
454sampleB
455+1.00000000
456+2.00000000
457+3.00000000
458meanB = getMean(sampleB, dim)
459meanB
460+1.00000000, +2.00000000, +3.00000000
461sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
462sample
463-0.720906854, +0.675368071, +0.571119785E-1, -0.160129070E-1, -0.181246638, +1.00000000
464+0.969111085, +0.543625951, +0.440006852, +0.736594915, -0.383182168, +2.00000000
465-0.935801268, -0.906371474, -0.433654904, -0.458913803, -0.395189404, +3.00000000
466cov = getCov(sample, dim)
467cov
468+0.316946596, +0.194477826, +0.522388935
469+0.194477826, +0.504535794, +0.719368815
470+0.522388935, +0.719368815, +1.87487543
471mean = getMean(sample, dim)
472mean
473+0.135718942, +0.717692792, -0.216551628E-1
474call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
475meanA
476+0.135718957, +0.717692792, -0.216550827E-1
477mean ! reference
478+0.135718942, +0.717692792, -0.216551628E-1
479covA
480+0.316946566, +0.194477811, +0.522388935
481-0.326123498E-1, +0.504535854, +0.719368815
482+0.924825654E-4, -0.666830912E-1, +1.87487555
483cov ! reference
484+0.316946596, +0.194477826, +0.522388935
485+0.194477826, +0.504535794, +0.719368815
486+0.522388935, +0.719368815, +1.87487543
487
488
489dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
490[ndim, nsamA]
491+3, +5
492sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
493sampleA
494-0.353447318, +0.484949231, +0.924181700, +0.323956966, +0.424858689
495-0.727890015, +0.208188891, +0.737259984, +0.793293953, +0.927120209
496+0.217493773E-1, +0.223648548, -0.792405128, -0.385578394, -0.196278811
497covA = getCov(sampleA, dim)
498covA
499+0.169684410, +0.198213622, -0.864899978E-1
500+0.198213622, +0.370887756, -0.120757557
501-0.864899978E-1, -0.120757557, +0.122145347
502meanA = getMean(sampleA, dim)
503meanA
504+0.360899866, +0.387594610, -0.225772887
505sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
506sampleB
507+1.00000000, +1.00000000, +1.00000000, +1.00000000
508+2.00000000, +2.00000000, +2.00000000, +2.00000000
509+3.00000000, +3.00000000, +3.00000000, +3.00000000
510meanB = getMean(sampleB, dim)
511meanB
512+1.00000000, +2.00000000, +3.00000000
513sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
514sample
515-0.353447318, +0.484949231, +0.924181700, +0.323956966, +0.424858689, +1.00000000, +1.00000000, +1.00000000, +1.00000000
516-0.727890015, +0.208188891, +0.737259984, +0.793293953, +0.927120209, +2.00000000, +2.00000000, +2.00000000, +2.00000000
517+0.217493773E-1, +0.223648548, -0.792405128, -0.385578394, -0.196278811, +3.00000000, +3.00000000, +3.00000000, +3.00000000
518cov = getCov(sample, dim)
519cov
520+0.195120707, +0.364560246, +0.460985094
521+0.364560246, +0.847987294, +1.21717262
522+0.460985094, +1.21717262, +2.63714480
523mean = getMean(sample, dim)
524mean
525+0.644944370, +1.10421920, +1.20790398
526call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
527meanA
528+0.644944370, +1.10421920, +1.20790386
529mean ! reference
530+0.644944370, +1.10421920, +1.20790398
531covA
532+0.195120722, +0.364560306, +0.460985065
533+0.198213622, +0.847987294, +1.21717262
534-0.864899978E-1, -0.120757557, +2.63714480
535cov ! reference
536+0.195120707, +0.364560246, +0.460985094
537+0.364560246, +0.847987294, +1.21717262
538+0.460985094, +1.21717262, +2.63714480
539
540
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 8922 of file pm_sampleCov.F90.


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