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+2, +4
10sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
11sampleA
12+0.786061049, +0.867853642, -0.256690025, -0.716351151
13-0.749715567E-1, +0.378776312, +0.498526692, -0.774505019
14covA = getCov(sampleA, dim)
15covA
16+0.458553284, +0.172976077
17+0.172976077, +0.249321371
18meanA = getMean(sampleA, dim)
19meanA
20+0.170218378, +0.695660710E-2
21sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
22sampleB
23+1.00000000
24+2.00000000
25meanB = getMean(sampleB, dim)
26meanB
27+1.00000000, +2.00000000
28sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
29sample
30+0.786061049, +0.867853642, -0.256690025, -0.716351151, +1.00000000
31-0.749715567E-1, +0.378776312, +0.498526692, -0.774505019, +2.00000000
32cov = getCov(sample, dim)
33cov
34+0.477008641, +0.402987391
35+0.402987391, +0.835012853
36mean = getMean(sample, dim)
37mean
38+0.336174697, +0.405565262
39call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
40covA
41+0.477008641, +0.402987421
42+0.172976077, +0.835012615
43cov ! reference
44+0.477008641, +0.402987391
45+0.402987391, +0.835012853
46
47
48dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
49[ndim, nsamA]
50+3, +4
51sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
52sampleA
53-0.112256050, +0.217585564E-1, -0.919040918, +0.705004454
54-0.298811674, +0.467298150, -0.464084148, -0.955752850
55-0.217513204, -0.853716373, +0.234398007, -0.281140685
56covA = getCov(sampleA, dim)
57covA
58+0.332889289, -0.747140497E-1, -0.123225093
59-0.747140497E-1, +0.261256009, -0.130941957
60-0.123225093, -0.130941957, +0.149415165
61meanA = getMean(sampleA, dim)
62meanA
63-0.761334896E-1, -0.312837631, -0.279493064
64sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
65sampleB
66+1.00000000
67+2.00000000
68+3.00000000
69meanB = getMean(sampleB, dim)
70meanB
71+1.00000000, +2.00000000, +3.00000000
72sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
73sample
74-0.112256050, +0.217585564E-1, -0.919040918, +0.705004454, +1.00000000
75-0.298811674, +0.467298150, -0.464084148, -0.955752850, +2.00000000
76-0.217513204, -0.853716373, +0.234398007, -0.281140685, +3.00000000
77cov = getCov(sample, dim)
78cov
79+0.451601565, +0.338456273, +0.466087490
80+0.338456273, +1.06487978, +1.10883605
81+0.466087490, +1.10883605, +1.84034383
82mean = getMean(sample, dim)
83mean
84+0.139093205, +0.149729893, +0.376405567
85call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
86covA
87+0.451601565, +0.338456243, +0.466087520
88-0.747140497E-1, +1.06487966, +1.10883594
89-0.123225093, -0.130941957, +1.84034395
90cov ! reference
91+0.451601565, +0.338456273, +0.466087490
92+0.338456273, +1.06487978, +1.10883605
93+0.466087490, +1.10883605, +1.84034383
94
95
96dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
97[ndim, nsamA]
98+2, +4
99sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
100sampleA
101-0.256214619, -0.371683836E-1, +0.146213055, +0.187662840E-1
102+0.872844100, -0.645677090, +0.859633565, +0.359085202
103covA = getCov(sampleA, dim)
104covA
105+0.211589970E-1, -0.519850105E-2
106-0.519850105E-2, +0.381005287
107meanA = getMean(sampleA, dim)
108meanA
109-0.321009159E-1, +0.361471444
110sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
111sampleB
112+1.00000000, +1.00000000, +1.00000000, +1.00000000
113+2.00000000, +2.00000000, +2.00000000, +2.00000000
114meanB = getMean(sampleB, dim)
115meanB
116+1.00000000, +2.00000000
117sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
118sample
119-0.256214619, -0.371683836E-1, +0.146213055, +0.187662840E-1, +1.00000000, +1.00000000, +1.00000000, +1.00000000
120+0.872844100, -0.645677090, +0.859633565, +0.359085202, +2.00000000, +2.00000000, +2.00000000, +2.00000000
121cov = getCov(sample, dim)
122cov
123+0.276887655, +0.420182467
124+0.420182467, +0.861696601
125mean = getMean(sample, dim)
126mean
127+0.483949542, +1.18073571
128call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
129covA
130+0.276887566, +0.420182467
131-0.519850105E-2, +0.861696601
132cov ! reference
133+0.276887655, +0.420182467
134+0.420182467, +0.861696601
135
136
137dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
138[ndim, nsamA]
139+4, +5
140sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
141sampleA
142-0.738200188, +0.392305970, -0.770943522, -0.192098618E-1, -0.370406032
143-0.159012079E-1, +0.513484955, -0.863012075, +0.359098434, +0.807807803
144-0.230511189, -0.895267844, +0.679485559, +0.663548589, -0.213944435
145+0.763373375, -0.523609757, +0.136598945, -0.768026114, -0.949482679
146covA = getCov(sampleA, dim)
147covA
148+0.195377275, +0.162775561, -0.127480686, -0.182374865
149+0.162775561, +0.332348228, -0.195504561, -0.245341495
150-0.127480686, -0.195504561, +0.360481471, +0.160048008E-1
151-0.182374865, -0.245341495, +0.160048008E-1, +0.401442140
152meanA = getMean(sampleA, dim)
153meanA
154-0.301290721, +0.160295591, +0.662136066E-3, -0.268229246
155sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
156sampleB
157+1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
158+2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
159+3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
160+4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000
161meanB = getMean(sampleB, dim)
162meanB
163+1.00000000, +2.00000000, +3.00000000, +4.00000000
164sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
165sample
166-0.738200188, +0.392305970, -0.770943522, -0.192098618E-1, -0.370406032, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
167-0.159012079E-1, +0.513484955, -0.863012075, +0.359098434, +0.807807803, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
168-0.230511189, -0.895267844, +0.679485559, +0.663548589, -0.213944435, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
169+0.763373375, -0.523609757, +0.136598945, -0.768026114, -0.949482679, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000
170cov = getCov(sample, dim)
171cov
172+0.521027982, +0.679885387, +0.912012696, +1.29736435
173+0.679885387, +1.01230204, +1.28172112, +1.84039915
174+0.912012696, +1.28172112, +2.42924762, +3.20846796
175+1.29736435, +1.84039915, +3.20846796, +4.75516653
176mean = getMean(sample, dim)
177mean
178+0.349354655, +1.08014774, +1.50033116, +1.86588538
179call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
180covA
181+0.521028042, +0.679885328, +0.912012339, +1.29736435
182+0.162775561, +1.01230216, +1.28172147, +1.84039938
183-0.127480686, -0.195504561, +2.42924762, +3.20846796
184-0.182374865, -0.245341495, +0.160048008E-1, +4.75516701
185cov ! reference
186+0.521027982, +0.679885387, +0.912012696, +1.29736435
187+0.679885387, +1.01230204, +1.28172112, +1.84039915
188+0.912012696, +1.28172112, +2.42924762, +3.20846796
189+1.29736435, +1.84039915, +3.20846796, +4.75516653
190
191
192dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
193[ndim, nsamA]
194+4, +8
195sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
196sampleA
197+0.771550894, -0.181419015, +0.285038948, +0.544025302, +0.602142811, +0.283999443, -0.823602557, -0.480298758
198-0.946884394, +0.120863676, -0.692712307, -0.754947901, -0.716239333, +0.201028585, -0.333398581E-1, -0.321276784
199+0.149420500, -0.242371678, -0.637250543, +0.442001224, -0.464412093, +0.922939897, -0.608757496, -0.471724510
200+0.989246368, +0.160412073, +0.519544601, -0.159225225, -0.177788258, +0.655472398, +0.408898950, +0.482012153
201covA = getCov(sampleA, dim)
202covA
203+0.279036820, -0.144946545, +0.130302832, -0.673735142E-2
204-0.144946545, +0.172941327, +0.336685330E-1, +0.808948278E-2
205+0.130302832, +0.336685330E-1, +0.279947817, +0.307751447E-1
206-0.673735142E-2, +0.808948278E-2, +0.307751447E-1, +0.140579224
207meanA = getMean(sampleA, dim)
208meanA
209+0.125179633, -0.392938495, -0.113769338, +0.359821618
210sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
211sampleB
212+1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
213+2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
214+3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
215+4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000
216meanB = getMean(sampleB, dim)
217meanB
218+1.00000000, +2.00000000, +3.00000000, +4.00000000
219sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
220sample
221+0.771550894, -0.181419015, +0.285038948, +0.544025302, +0.602142811, +0.283999443, -0.823602557, -0.480298758, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
222-0.946884394, +0.120863676, -0.692712307, -0.754947901, -0.716239333, +0.201028585, -0.333398581E-1, -0.321276784, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
223+0.149420500, -0.242371678, -0.637250543, +0.442001224, -0.464412093, +0.922939897, -0.608757496, -0.471724510, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
224+0.989246368, +0.160412073, +0.519544601, -0.159225225, -0.177788258, +0.655472398, +0.408898950, +0.482012153, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000
225cov = getCov(sample, dim)
226cov
227+0.330845982, +0.450874656, +0.746148646, +0.792757034
228+0.450874656, +1.51800966, +1.87959909, +2.18172598
229+0.746148646, +1.87959909, +2.56386423, +2.84905696
230+0.792757034, +2.18172598, +2.84905696, +3.38301420
231mean = getMean(sample, dim)
232mean
233+0.562589824, +0.803530753, +1.44311535, +2.17991066
234call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
235covA
236+0.330846071, +0.450874567, +0.746148586, +0.792756855
237-0.144946545, +1.51800942, +1.87959898, +2.18172574
238+0.130302832, +0.336685330E-1, +2.56386375, +2.84905648
239-0.673735142E-2, +0.808948278E-2, +0.307751447E-1, +3.38301444
240cov ! reference
241+0.330845982, +0.450874656, +0.746148646, +0.792757034
242+0.450874656, +1.51800966, +1.87959909, +2.18172598
243+0.746148646, +1.87959909, +2.56386423, +2.84905696
244+0.792757034, +2.18172598, +2.84905696, +3.38301420
245
246
247dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
248[ndim, nsamA]
249+2, +4
250sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
251sampleA
252+0.802503824, +0.928859353, -0.858460784, +0.176436424
253-0.236625671, +0.138427973, +0.825672269, -0.733766079
254covA = getCov(sampleA, dim)
255covA
256+0.499899685, -0.224483162
257-0.224483162, +0.323822886
258meanA = getMean(sampleA, dim)
259meanA
260+0.262334704, -0.157287717E-2
261sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
262sampleB
263+1.00000000, +1.00000000, +1.00000000
264+2.00000000, +2.00000000, +2.00000000
265meanB = getMean(sampleB, dim)
266meanB
267+1.00000000, +2.00000000
268sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
269sample
270+0.802503824, +0.928859353, -0.858460784, +0.176436424, +1.00000000, +1.00000000, +1.00000000
271-0.236625671, +0.138427973, +0.825672269, -0.733766079, +2.00000000, +2.00000000, +2.00000000
272cov = getCov(sample, dim)
273cov
274+0.418918252, +0.233313516
275+0.233313516, +1.16617477
276mean = getMean(sample, dim)
277mean
278+0.578477025, +0.856244147
279call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
280covA
281+0.418918252, +0.233313516
282-0.224483162, +1.16617477
283cov ! reference
284+0.418918252, +0.233313516
285+0.233313516, +1.16617477
286
287
288dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
289[ndim, nsamA]
290+4, +8
291sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
292sampleA
293+0.472215414, -0.626202822E-1, -0.655271888, +0.519253016E-1, +0.520857096, +0.785553098, -0.846956730, -0.103863001
294-0.788194656, -0.726788998, -0.771555066, +0.737514138, +0.428032994, -0.106883883, -0.419764876, +0.443420410E-1
295+0.964806437, -0.671944618E-1, +0.161279678, +0.157700300, -0.273656964, +0.523476839, +0.145460486, -0.963441014
296+0.509739518, -0.846667528, -0.969759941, -0.828577399, -0.204167604, -0.904116511, +0.382681608, +0.235826254
297covA = getCov(sampleA, dim)
298covA
299+0.284027636, +0.924400836E-1, +0.743428767E-1, -0.282400250E-1
300+0.924400836E-1, +0.292522788, -0.108332694, -0.395393372E-1
301+0.743428767E-1, -0.108332694, +0.278997898, -0.143200159E-1
302-0.282400250E-1, -0.395393372E-1, -0.143200159E-1, +0.350433767
303meanA = getMean(sampleA, dim)
304meanA
305+0.202298760E-1, -0.200412273, +0.810539126E-1, -0.328130186
306sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
307sampleB
308+1.00000000, +1.00000000, +1.00000000
309+2.00000000, +2.00000000, +2.00000000
310+3.00000000, +3.00000000, +3.00000000
311+4.00000000, +4.00000000, +4.00000000
312meanB = getMean(sampleB, dim)
313meanB
314+1.00000000, +2.00000000, +3.00000000, +4.00000000
315sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
316sample
317+0.472215414, -0.626202822E-1, -0.655271888, +0.519253016E-1, +0.520857096, +0.785553098, -0.846956730, -0.103863001, +1.00000000, +1.00000000, +1.00000000
318-0.788194656, -0.726788998, -0.771555066, +0.737514138, +0.428032994, -0.106883883, -0.419764876, +0.443420410E-1, +2.00000000, +2.00000000, +2.00000000
319+0.964806437, -0.671944618E-1, +0.161279678, +0.157700300, -0.273656964, +0.523476839, +0.145460486, -0.963441014, +3.00000000, +3.00000000, +3.00000000
320+0.509739518, -0.846667528, -0.969759941, -0.828577399, -0.204167604, -0.904116511, +0.382681608, +0.235826254, +4.00000000, +4.00000000, +4.00000000
321cov = getCov(sample, dim)
322cov
323+0.396968722, +0.494845390, +0.621319711, +0.820567131
324+0.494845390, +1.17310357, +1.19517314, +1.86023700
325+0.621319711, +1.19517314, +1.89287353, +2.49541926
326+0.820567131, +1.86023700, +2.49541926, +3.97044039
327mean = getMean(sample, dim)
328mean
329+0.287439913, +0.399700165, +0.877130210, +0.852268934
330call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
331covA
332+0.396968752, +0.494845271, +0.621319652, +0.820567071
333+0.924400836E-1, +1.17310357, +1.19517303, +1.86023653
334+0.743428767E-1, -0.108332694, +1.89287353, +2.49541903
335-0.282400250E-1, -0.395393372E-1, -0.143200159E-1, +3.97043967
336cov ! reference
337+0.396968722, +0.494845390, +0.621319711, +0.820567131
338+0.494845390, +1.17310357, +1.19517314, +1.86023700
339+0.621319711, +1.19517314, +1.89287353, +2.49541926
340+0.820567131, +1.86023700, +2.49541926, +3.97044039
341
342
343dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
344[ndim, nsamA]
345+4, +5
346sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
347sampleA
348+0.552137971, +0.170957565, -0.603675246, -0.662389398, -0.856788993
349-0.733471870, +0.550650716, -0.588717699, -0.737070918, -0.948831201
350-0.145474315, -0.918779135, -0.864166021E-1, +0.867311001, +0.165608406
351-0.366667867, +0.433053493, +0.392364502, -0.763051748, -0.305147886
352covA = getCov(sampleA, dim)
353covA
354+0.295897871, +0.131553218, -0.186916023, +0.461980477E-1
355+0.131553218, +0.284707367, -0.240525469, +0.165765926
356-0.186916023, -0.240525469, +0.329933465, -0.221027493
357+0.461980477E-1, +0.165765926, -0.221027493, +0.215401605
358meanA = getMean(sampleA, dim)
359meanA
360-0.279951632, -0.491488189, -0.235501286E-1, -0.121889904
361sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
362sampleB
363+1.00000000, +1.00000000, +1.00000000
364+2.00000000, +2.00000000, +2.00000000
365+3.00000000, +3.00000000, +3.00000000
366+4.00000000, +4.00000000, +4.00000000
367meanB = getMean(sampleB, dim)
368meanB
369+1.00000000, +2.00000000, +3.00000000, +4.00000000
370sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
371sample
372+0.552137971, +0.170957565, -0.603675246, -0.662389398, -0.856788993, +1.00000000, +1.00000000, +1.00000000
373-0.733471870, +0.550650716, -0.588717699, -0.737070918, -0.948831201, +2.00000000, +2.00000000, +2.00000000
374-0.145474315, -0.918779135, -0.864166021E-1, +0.867311001, +0.165608406, +3.00000000, +3.00000000, +3.00000000
375-0.366667867, +0.433053493, +0.392364502, -0.763051748, -0.305147886, +4.00000000, +4.00000000, +4.00000000
376cov = getCov(sample, dim)
377cov
378+0.568907261, +0.829638958, +0.790208280, +1.26539397
379+0.829638958, +1.63282800, +1.61525142, +2.51055074
380+0.790208280, +1.61525142, +2.34883070, +2.78281260
381+1.26539397, +2.51055074, +2.78281260, +4.11665106
382mean = getMean(sample, dim)
383mean
384+0.200030237, +0.442819893, +1.11028123, +1.42381883
385call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
386covA
387+0.568907142, +0.829638958, +0.790208101, +1.26539409
388+0.131553218, +1.63282800, +1.61525106, +2.51055074
389-0.186916023, -0.240525469, +2.34883070, +2.78281283
390+0.461980477E-1, +0.165765926, -0.221027493, +4.11665201
391cov ! reference
392+0.568907261, +0.829638958, +0.790208280, +1.26539397
393+0.829638958, +1.63282800, +1.61525142, +2.51055074
394+0.790208280, +1.61525142, +2.34883070, +2.78281260
395+1.26539397, +2.51055074, +2.78281260, +4.11665106
396
397
398dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
399[ndim, nsamA]
400+4, +6
401sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
402sampleA
403+0.813669086, +0.349640489, +0.380893350, +0.921152472, +0.685636282, -0.253697038
404+0.652592182E-1, -0.384718657, +0.917993784, -0.139811158, -0.477453709, +0.286117435
405-0.365535975, +0.672603369, -0.287604094, -0.425071359, +0.818051696, +0.614841223
406-0.662151694, +0.612948775, +0.194646120, -0.595208526, -0.582296491, +0.399139047
407covA = getCov(sampleA, dim)
408covA
409+0.152219027, -0.649344474E-1, -0.109085545, -0.165579304
410-0.649344474E-1, +0.218739361, -0.124608696, +0.672170818E-1
411-0.109085545, -0.124608696, +0.286794305, +0.121460065
412-0.165579304, +0.672170818E-1, +0.121460065, +0.272987843
413meanA = getMean(sampleA, dim)
414meanA
415+0.482882440, +0.445644855E-1, +0.171214148, -0.105487131
416sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
417sampleB
418+1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
419+2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
420+3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
421+4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000
422meanB = getMean(sampleB, dim)
423meanB
424+1.00000000, +2.00000000, +3.00000000, +4.00000000
425sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
426sample
427+0.813669086, +0.349640489, +0.380893350, +0.921152472, +0.685636282, -0.253697038, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
428+0.652592182E-1, -0.384718657, +0.917993784, -0.139811158, -0.477453709, +0.286117435, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
429-0.365535975, +0.672603369, -0.287604094, -0.425071359, +0.818051696, +0.614841223, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
430-0.662151694, +0.612948775, +0.194646120, -0.595208526, -0.582296491, +0.399139047, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000
431cov = getCov(sample, dim)
432cov
433+0.142962158, +0.220330283, +0.311160922, +0.447965235
434+0.220330283, +1.06530142, +1.32057285, +2.04061198
435+0.311160922, +1.32057285, +2.14390445, +2.96411681
436+0.447965235, +2.04061198, +2.96411681, +4.35025024
437mean = getMean(sample, dim)
438mean
439+0.741441250, +1.02228236, +1.58560705, +1.94725645
440call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
441covA
442+0.142962158, +0.220330298, +0.311160922, +0.447965264
443-0.649344474E-1, +1.06530166, +1.32057273, +2.04061246
444-0.109085545, -0.124608696, +2.14390445, +2.96411610
445-0.165579304, +0.672170818E-1, +0.121460065, +4.35025024
446cov ! reference
447+0.142962158, +0.220330283, +0.311160922, +0.447965235
448+0.220330283, +1.06530142, +1.32057285, +2.04061198
449+0.311160922, +1.32057285, +2.14390445, +2.96411681
450+0.447965235, +2.04061198, +2.96411681, +4.35025024
451
452
453dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
454[ndim, nsamA]
455+5, +6
456sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
457sampleA
458-0.746997595, -0.194206715, +0.113978148, +0.578418970E-1, +0.728306532, -0.433409333
459-0.398545861, +0.402339458, -0.420929670, +0.132973313, +0.700826049, +0.548105240E-1
460-0.131039143, +0.784418464, -0.754829288, +0.309328675, -0.107936144, +0.937005162
461+0.345732093, -0.323467255, +0.269772530, +0.887199640E-1, +0.418754816E-1, +0.129249692
462-0.833655953, -0.141269922, +0.361464739, -0.218225360, +0.819943666, +0.552417040
463covA = getCov(sampleA, dim)
464covA
465+0.215468258, +0.117205977, -0.875516161E-1, -0.235729627E-1, +0.179875851
466+0.117205977, +0.162115455, +0.103486858, -0.627710447E-1, +0.109445415
467-0.875516161E-1, +0.103486858, +0.334725618, -0.756696314E-1, -0.104109454E-2
468-0.235729627E-1, -0.627710447E-1, -0.756696314E-1, +0.454177968E-1, -0.180615187E-1
469+0.179875851, +0.109445415, -0.104109454E-2, -0.180615187E-1, +0.303661436
470meanA = getMean(sampleA, dim)
471meanA
472-0.790811777E-1, +0.785789713E-1, +0.172824621, +0.919804201E-1, +0.901123732E-1
473sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
474sampleB
475+1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
476+2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
477+3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
478+4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000
479+5.00000000, +5.00000000, +5.00000000, +5.00000000, +5.00000000
480meanB = getMean(sampleB, dim)
481meanB
482+1.00000000, +2.00000000, +3.00000000, +4.00000000, +5.00000000
483sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
484sample
485-0.746997595, -0.194206715, +0.113978148, +0.578418970E-1, +0.728306532, -0.433409333, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
486-0.398545861, +0.402339458, -0.420929670, +0.132973313, +0.700826049, +0.548105240E-1, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
487-0.131039143, +0.784418464, -0.754829288, +0.309328675, -0.107936144, +0.937005162, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
488+0.345732093, -0.323467255, +0.269772530, +0.887199640E-1, +0.418754816E-1, +0.129249692, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000
489-0.833655953, -0.141269922, +0.361464739, -0.218225360, +0.819943666, +0.552417040, +5.00000000, +5.00000000, +5.00000000, +5.00000000, +5.00000000
490cov = getCov(sample, dim)
491cov
492+0.406226069, +0.577988923, +0.708629131, +1.03269672, +1.41170883
493+0.577988923, +1.00376308, +1.40327251, +1.82748449, +2.39869547
494+0.708629131, +1.40327251, +2.16429400, +2.69806170, +3.44103050
495+1.03269672, +1.82748449, +2.69806170, +3.81137228, +4.74748802
496+1.41170883, +2.39869547, +3.44103050, +4.74748802, +6.14257336
497mean = getMean(sample, dim)
498mean
499+0.411410272, +0.951952159, +1.45790434, +1.86835313, +2.32187963
500call setCovUpdated(covA, meanA - meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
501covA
502+0.406226367, +0.577988982, +0.708629310, +1.03269649, +1.41170943
503+0.117205977, +1.00376344, +1.40327239, +1.82748473, +2.39869618
504-0.875516161E-1, +0.103486858, +2.16429329, +2.69806194, +3.44103050
505-0.235729627E-1, -0.627710447E-1, -0.756696314E-1, +3.81137228, +4.74748755
506+0.179875851, +0.109445415, -0.104109454E-2, -0.180615187E-1, +6.14257526
507cov ! reference
508+0.406226069, +0.577988923, +0.708629131, +1.03269672, +1.41170883
509+0.577988923, +1.00376308, +1.40327251, +1.82748449, +2.39869547
510+0.708629131, +1.40327251, +2.16429400, +2.69806170, +3.44103050
511+1.03269672, +1.82748449, +2.69806170, +3.81137228, +4.74748802
512+1.41170883, +2.39869547, +3.44103050, +4.74748802, +6.14257336
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 at Austin

Definition at line 8553 of file pm_sampleCov.F90.


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