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.965767741, +0.864598632
13covA = getCov(sampleA, dim)
14covA
15+0.837560236
16meanA = getMean(sampleA, dim)
17meanA
18-0.505845547E-1
19sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
20sampleB
21+1.00000000
22meanB = getMean(sampleB, dim)
23meanB
24+1.00000000
25sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
26sample
27-0.965767741, +0.864598632, +1.00000000
28cov = getCov(sample, dim)
29cov
30+0.803646445
31mean = getMean(sample, dim)
32mean
33+0.299610317
34call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
35meanA
36+0.299610287
37mean ! reference
38+0.299610317
39covA
40+0.803646386
41cov ! reference
42+0.803646445
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+3, +6
48sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
49sampleA
50-0.319911480, -0.233755350, +0.423461914, +0.720913172, -0.296670675, +0.547161460
51-0.564549923, -0.269218802, +0.259472370, -0.358684421, -0.551665902, +0.854834557
52+0.880737185, -0.316439033, +0.958654523, -0.393489838, -0.397066355, -0.740029812E-1
53covA = getCov(sampleA, dim)
54covA
55+0.187580675, +0.135754824, -0.167512111E-1
56+0.135754824, +0.259357095, +0.337921008E-1
57-0.167512111E-1, +0.337921008E-1, +0.340095937
58meanA = getMean(sampleA, dim)
59meanA
60+0.140199840, -0.104968689, +0.109732255
61sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
62sampleB
63+1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
64+2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
65+3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
66meanB = getMean(sampleB, dim)
67meanB
68+1.00000000, +2.00000000, +3.00000000
69sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
70sample
71-0.319911480, -0.233755350, +0.423461914, +0.720913172, -0.296670675, +0.547161460, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
72-0.564549923, -0.269218802, +0.259472370, -0.358684421, -0.551665902, +0.854834557, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
73+0.880737185, -0.316439033, +0.958654523, -0.393489838, -0.397066355, -0.740029812E-1, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
74cov = getCov(sample, dim)
75cov
76+0.278604358, +0.520340323, +0.612887561
77+0.520340323, +1.23740101, +1.53787696
78+0.612887561, +1.53787696, +2.25845957
79mean = getMean(sample, dim)
80mean
81+0.570099950, +0.947515666, +1.55486619
82call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
83meanA
84+0.570099950, +0.947515666, +1.55486608
85mean ! reference
86+0.570099950, +0.947515666, +1.55486619
87covA
88+0.278604418, +0.520340562, +0.612887621
89+0.135754824, +1.23740196, +1.53787696
90-0.167512111E-1, +0.337921008E-1, +2.25846004
91cov ! reference
92+0.278604358, +0.520340323, +0.612887561
93+0.520340323, +1.23740101, +1.53787696
94+0.612887561, +1.53787696, +2.25845957
95
96
97dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
98[ndim, nsamA]
99+2, +4
100sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
101sampleA
102+0.949618220, +0.713539124E-1, +0.430992842E-1, +0.748700500
103-0.435576558, -0.163419247, +0.718210340, +0.287227869
104covA = getCov(sampleA, dim)
105covA
106+0.161935151, -0.908717215E-1
107-0.908717215E-1, +0.193364978
108meanA = getMean(sampleA, dim)
109meanA
110+0.453192979, +0.101610601
111sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
112sampleB
113+1.00000000
114+2.00000000
115meanB = getMean(sampleB, dim)
116meanB
117+1.00000000, +2.00000000
118sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
119sample
120+0.949618220, +0.713539124E-1, +0.430992842E-1, +0.748700500, +1.00000000
121-0.435576558, -0.163419247, +0.718210340, +0.287227869, +2.00000000
122cov = getCov(sample, dim)
123cov
124+0.177387804, +0.933910385E-1
125+0.933910385E-1, +0.731313169
126mean = getMean(sample, dim)
127mean
128+0.562554359, +0.481288493
129call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
130meanA
131+0.562554359, +0.481288463
132mean ! reference
133+0.562554359, +0.481288493
134covA
135+0.177387789, +0.933910534E-1
136-0.908717215E-1, +0.731313109
137cov ! reference
138+0.177387804, +0.933910385E-1
139+0.933910385E-1, +0.731313169
140
141
142dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
143[ndim, nsamA]
144+5, +8
145sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
146sampleA
147-0.509128571, -0.747652173, +0.496444225, -0.287279725, -0.475912571, +0.308162808, -0.814969063, -0.350263119
148+0.206487060, -0.923146367, +0.682579160, -0.521739125, +0.113336325, +0.477493882, -0.828923702, +0.765937567E-1
149+0.464736223, -0.451376081, -0.820968509, +0.496510863, -0.529063344, +0.280249834, -0.751173735, +0.517570019
150-0.369887114, +0.203079224, -0.343624473, +0.631778836, +0.892307401, +0.221240401, +0.296439767, -0.743499517
151+0.903321385, -0.482751608, -0.296665430E-1, -0.298870564, -0.477373242, +0.822102547, +0.997208357, +0.548257828
152covA = getCov(sampleA, dim)
153covA
154+0.193386510, +0.200285286, +0.104472041E-1, -0.523514375E-1, +0.472715497E-2
155+0.200285286, +0.312808782, +0.447795391E-1, -0.106660515, +0.624278039E-1
156+0.104472041E-1, +0.447795391E-1, +0.306514084, -0.759007037E-1, +0.909909308E-1
157-0.523514375E-1, -0.106660515, -0.759007037E-1, +0.262940288, -0.145262122
158+0.472715497E-2, +0.624278039E-1, +0.909909308E-1, -0.145262122, +0.355854839
159meanA = getMean(sampleA, dim)
160meanA
161-0.297574759, -0.896648765E-1, -0.991893411E-1, +0.984793156E-1, +0.247778520
162sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
163sampleB
164+1.00000000, +1.00000000, +1.00000000, +1.00000000
165+2.00000000, +2.00000000, +2.00000000, +2.00000000
166+3.00000000, +3.00000000, +3.00000000, +3.00000000
167+4.00000000, +4.00000000, +4.00000000, +4.00000000
168+5.00000000, +5.00000000, +5.00000000, +5.00000000
169meanB = getMean(sampleB, dim)
170meanB
171+1.00000000, +2.00000000, +3.00000000, +4.00000000, +5.00000000
172sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
173sample
174-0.509128571, -0.747652173, +0.496444225, -0.287279725, -0.475912571, +0.308162808, -0.814969063, -0.350263119, +1.00000000, +1.00000000, +1.00000000, +1.00000000
175+0.206487060, -0.923146367, +0.682579160, -0.521739125, +0.113336325, +0.477493882, -0.828923702, +0.765937567E-1, +2.00000000, +2.00000000, +2.00000000, +2.00000000
176+0.464736223, -0.451376081, -0.820968509, +0.496510863, -0.529063344, +0.280249834, -0.751173735, +0.517570019, +3.00000000, +3.00000000, +3.00000000, +3.00000000
177-0.369887114, +0.203079224, -0.343624473, +0.631778836, +0.892307401, +0.221240401, +0.296439767, -0.743499517, +4.00000000, +4.00000000, +4.00000000, +4.00000000
178+0.903321385, -0.482751608, -0.296665430E-1, -0.298870564, -0.477373242, +0.822102547, +0.997208357, +0.548257828, +5.00000000, +5.00000000, +5.00000000, +5.00000000
179cov = getCov(sample, dim)
180cov
181+0.503080010, +0.736078441, +0.900616050, +1.09010243, +1.37345433
182+0.736078441, +1.17891669, +1.46902359, +1.74064231, +2.24840736
183+0.900616050, +1.46902359, +2.33878160, +2.63641119, +3.33355713
184+1.09010243, +1.74064231, +2.63641119, +3.55792975, +4.02335691
185+1.37345433, +2.24840736, +3.33355713, +4.02335691, +5.25581646
186mean = getMean(sample, dim)
187mean
188+0.134950161, +0.606890082, +0.933873832, +1.39898622, +1.83185232
189call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
190meanA
191+0.134950131, +0.606890023, +0.933873713, +1.39898610, +1.83185220
192mean ! reference
193+0.134950161, +0.606890082, +0.933873832, +1.39898622, +1.83185232
194covA
195+0.503079891, +0.736078262, +0.900615811, +1.09010231, +1.37345421
196+0.200285286, +1.17891681, +1.46902335, +1.74064195, +2.24840760
197+0.104472041E-1, +0.447795391E-1, +2.33878136, +2.63641071, +3.33355689
198-0.523514375E-1, -0.106660515, -0.759007037E-1, +3.55792952, +4.02335644
199+0.472715497E-2, +0.624278039E-1, +0.909909308E-1, -0.145262122, +5.25581646
200cov ! reference
201+0.503080010, +0.736078441, +0.900616050, +1.09010243, +1.37345433
202+0.736078441, +1.17891669, +1.46902359, +1.74064231, +2.24840736
203+0.900616050, +1.46902359, +2.33878160, +2.63641119, +3.33355713
204+1.09010243, +1.74064231, +2.63641119, +3.55792975, +4.02335691
205+1.37345433, +2.24840736, +3.33355713, +4.02335691, +5.25581646
206
207
208dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
209[ndim, nsamA]
210+1, +2
211sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
212sampleA
213-0.895466089, -0.585698366
214covA = getCov(sampleA, dim)
215covA
216+0.239890106E-1
217meanA = getMean(sampleA, dim)
218meanA
219-0.740582228
220sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
221sampleB
222+1.00000000
223meanB = getMean(sampleB, dim)
224meanB
225+1.00000000
226sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
227sample
228-0.895466089, -0.585698366, +1.00000000
229cov = getCov(sample, dim)
230cov
231+0.689243019
232mean = getMean(sample, dim)
233mean
234-0.160388157
235call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
236meanA
237-0.160388172
238mean ! reference
239-0.160388157
240covA
241+0.689243019
242cov ! reference
243+0.689243019
244
245
246dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
247[ndim, nsamA]
248+5, +9
249sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
250sampleA
251+0.979927897, +0.283501267, +0.497959137, -0.546624541, -0.591901541E-1, -0.400028229, +0.163236856, +0.222964168, +0.827435732
252+0.123116016, -0.681290150, -0.156124592, -0.766030550E-1, -0.948868513, +0.144181252E-1, -0.998933077, -0.860987067, -0.818501711
253-0.416078806, -0.438356876, +0.764709115, +0.631886482, +0.285053134, -0.360353112, -0.218836069, +0.426542997, +0.726936698
254-0.378825545, -0.898909450, -0.519246697, +0.351663351, -0.632739544, -0.649318814, -0.386340261, -0.304379463, -0.717479825
255+0.553564310, +0.673207641, -0.997451305, -0.957208037, -0.840828657, -0.579313517, -0.912598610, -0.819215775E-1, -0.675380230E-1
256covA = getCov(sampleA, dim)
257covA
258+0.231230691, -0.140808951E-1, -0.167828135E-2, -0.666000620E-1, +0.168956071
259-0.140808951E-1, +0.184936121, -0.282136872E-1, +0.469570942E-1, +0.105281938E-1
260-0.167828135E-2, -0.282136872E-1, +0.233385295, +0.563974865E-1, -0.145378649
261-0.666000620E-1, +0.469570942E-1, +0.563974865E-1, +0.113684021, -0.860511661E-1
262+0.168956071, +0.105281938E-1, -0.145378649, -0.860511661E-1, +0.379171163
263meanA = getMean(sampleA, dim)
264meanA
265+0.218798012, -0.489308268, +0.155722618, -0.459508419, -0.356676430
266sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
267sampleB
268+1.00000000, +1.00000000
269+2.00000000, +2.00000000
270+3.00000000, +3.00000000
271+4.00000000, +4.00000000
272+5.00000000, +5.00000000
273meanB = getMean(sampleB, dim)
274meanB
275+1.00000000, +2.00000000, +3.00000000, +4.00000000, +5.00000000
276sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
277sample
278+0.979927897, +0.283501267, +0.497959137, -0.546624541, -0.591901541E-1, -0.400028229, +0.163236856, +0.222964168, +0.827435732, +1.00000000, +1.00000000
279+0.123116016, -0.681290150, -0.156124592, -0.766030550E-1, -0.948868513, +0.144181252E-1, -0.998933077, -0.860987067, -0.818501711, +2.00000000, +2.00000000
280-0.416078806, -0.438356876, +0.764709115, +0.631886482, +0.285053134, -0.360353112, -0.218836069, +0.426542997, +0.726936698, +3.00000000, +3.00000000
281-0.378825545, -0.898909450, -0.519246697, +0.351663351, -0.632739544, -0.649318814, -0.386340261, -0.304379463, -0.717479825, +4.00000000, +4.00000000
282+0.553564310, +0.673207641, -0.997451305, -0.957208037, -0.840828657, -0.579313517, -0.912598610, -0.819215775E-1, -0.675380230E-1, +5.00000000, +5.00000000
283cov = getCov(sample, dim)
284cov
285+0.279973596, +0.277766377, +0.329165667, +0.463756919, +0.760746121
286+0.277766377, +1.07312787, +1.03018141, +1.68982160, +1.99224651
287+0.329165667, +1.03018141, +1.39440978, +1.93303132, +2.14754748
288+0.463756919, +1.68982160, +1.93303132, +3.05144310, +3.48320293
289+0.760746121, +1.99224651, +2.14754748, +3.48320293, +4.57875729
290mean = getMean(sample, dim)
291mean
292+0.360834748, -0.367067531E-1, +0.672863960, +0.351311296, +0.617264748
293call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
294meanA
295+0.360834748, -0.367067456E-1, +0.672863960, +0.351311326, +0.617264748
296mean ! reference
297+0.360834748, -0.367067531E-1, +0.672863960, +0.351311296, +0.617264748
298covA
299+0.279973686, +0.277766407, +0.329165637, +0.463756830, +0.760746121
300-0.140808951E-1, +1.07312799, +1.03018141, +1.68982160, +1.99224663
301-0.167828135E-2, -0.282136872E-1, +1.39440978, +1.93303120, +2.14754748
302-0.666000620E-1, +0.469570942E-1, +0.563974865E-1, +3.05144286, +3.48320293
303+0.168956071, +0.105281938E-1, -0.145378649, -0.860511661E-1, +4.57875729
304cov ! reference
305+0.279973596, +0.277766377, +0.329165667, +0.463756919, +0.760746121
306+0.277766377, +1.07312787, +1.03018141, +1.68982160, +1.99224651
307+0.329165667, +1.03018141, +1.39440978, +1.93303132, +2.14754748
308+0.463756919, +1.68982160, +1.93303132, +3.05144310, +3.48320293
309+0.760746121, +1.99224651, +2.14754748, +3.48320293, +4.57875729
310
311
312dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
313[ndim, nsamA]
314+1, +2
315sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
316sampleA
317+0.346621633, +0.425858498
318covA = getCov(sampleA, dim)
319covA
320+0.156962022E-2
321meanA = getMean(sampleA, dim)
322meanA
323+0.386240065
324sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
325sampleB
326+1.00000000, +1.00000000
327meanB = getMean(sampleB, dim)
328meanB
329+1.00000000
330sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
331sample
332+0.346621633, +0.425858498, +1.00000000, +1.00000000
333cov = getCov(sample, dim)
334cov
335+0.949601084E-1
336mean = getMean(sample, dim)
337mean
338+0.693120003
339call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
340meanA
341+0.693120003
342mean ! reference
343+0.693120003
344covA
345+0.949601233E-1
346cov ! reference
347+0.949601084E-1
348
349
350dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
351[ndim, nsamA]
352+3, +4
353sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
354sampleA
355-0.418892860, -0.513078928, -0.505785584, +0.624679327
356-0.665685654, -0.413586497, +0.922899842, -0.498944044
357+0.708398581, +0.652399898, -0.466067791, -0.518586874
358covA = getCov(sampleA, dim)
359covA
360+0.229872629, -0.105155453, -0.160809323
361-0.105155453, +0.401880145, -0.212789893
362-0.160809323, -0.212789893, +0.344558716
363meanA = getMean(sampleA, dim)
364meanA
365-0.203269511, -0.163829088, +0.940359533E-1
366sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
367sampleB
368+1.00000000, +1.00000000
369+2.00000000, +2.00000000
370+3.00000000, +3.00000000
371meanB = getMean(sampleB, dim)
372meanB
373+1.00000000, +2.00000000, +3.00000000
374sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
375sample
376-0.418892860, -0.513078928, -0.505785584, +0.624679327, +1.00000000, +1.00000000
377-0.665685654, -0.413586497, +0.922899842, -0.498944044, +2.00000000, +2.00000000
378+0.708398581, +0.652399898, -0.466067791, -0.518586874, +3.00000000, +3.00000000
379cov = getCov(sample, dim)
380cov
381+0.474994481, +0.508489549, +0.669828832
382+0.508489549, +1.30839920, +1.25547552
383+0.669828832, +1.25547552, +2.10628963
384mean = getMean(sample, dim)
385mean
386+0.197820336, +0.557447314, +1.06269073
387call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
388meanA
389+0.197820306, +0.557447255, +1.06269062
390mean ! reference
391+0.197820336, +0.557447314, +1.06269073
392covA
393+0.474994510, +0.508489549, +0.669828832
394-0.105155453, +1.30839920, +1.25547552
395-0.160809323, -0.212789893, +2.10628963
396cov ! reference
397+0.474994481, +0.508489549, +0.669828832
398+0.508489549, +1.30839920, +1.25547552
399+0.669828832, +1.25547552, +2.10628963
400
401
402dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
403[ndim, nsamA]
404+3, +5
405sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
406sampleA
407-0.410322309, +0.839595914, -0.880304337, -0.461480856, +0.671586394
408+0.377738237, +0.386040211E-1, +0.127860427, +0.904667497, +0.604162335
409-0.929768085E-1, +0.773385763E-1, +0.898555636, -0.960139155, -0.444846392
410covA = getCov(sampleA, dim)
411covA
412+0.460121006, -0.295905620E-1, -0.113748327
413-0.295905620E-1, +0.100194328, -0.168049440
414-0.113748327, -0.168049440, +0.377454549
415meanA = getMean(sampleA, dim)
416meanA
417-0.481850393E-1, +0.410606474, -0.104413629
418sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
419sampleB
420+1.00000000, +1.00000000, +1.00000000
421+2.00000000, +2.00000000, +2.00000000
422+3.00000000, +3.00000000, +3.00000000
423meanB = getMean(sampleB, dim)
424meanB
425+1.00000000, +2.00000000, +3.00000000
426sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
427sample
428-0.410322309, +0.839595914, -0.880304337, -0.461480856, +0.671586394, +1.00000000, +1.00000000, +1.00000000
429+0.377738237, +0.386040211E-1, +0.127860427, +0.904667497, +0.604162335, +2.00000000, +2.00000000, +2.00000000
430-0.929768085E-1, +0.773385763E-1, +0.898555636, -0.960139155, -0.444846392, +3.00000000, +3.00000000, +3.00000000
431cov = getCov(sample, dim)
432cov
433+0.545081615, +0.371969521, +0.691563725
434+0.371969521, +0.654692769, +1.05140686
435+0.691563725, +1.05140686, +2.49467087
436mean = getMean(sample, dim)
437mean
438+0.344884336, +1.00662899, +1.05974150
439call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
440meanA
441+0.344884336, +1.00662899, +1.05974150
442mean ! reference
443+0.344884336, +1.00662899, +1.05974150
444covA
445+0.545081496, +0.371969581, +0.691563427
446-0.295905620E-1, +0.654692948, +1.05140686
447-0.113748327, -0.168049440, +2.49467063
448cov ! reference
449+0.545081615, +0.371969521, +0.691563725
450+0.371969521, +0.654692769, +1.05140686
451+0.691563725, +1.05140686, +2.49467087
452
453
454dim = 2; ndim = getUnifRand(1, 5); nsamA = getUnifRand(ndim + 1_IK, ndim * 2_IK); nsamB = getUnifRand(1_IK, nsamA)
455[ndim, nsamA]
456+5, +9
457sampleA = getUnifRand(-1., +1., ndim, nsamA) ! Generate a non-singular sample.
458sampleA
459-0.728370547, +0.108977556E-1, +0.728019714, +0.721251965, +0.212120652, +0.491022468, +0.179573536, -0.440232038, +0.874706626
460-0.589933395E-1, -0.297904015, +0.314074039, -0.530974507, -0.536887407, -0.798511028, +0.127491117, -0.228580236, -0.686249256
461-0.645056844, +0.801773071, -0.812340856, -0.691423297, -0.755631924E-1, -0.541021347, -0.407658458, +0.210855246, -0.156015754
462+0.860636592, -0.251900673, -0.803233862, -0.698131442, -0.508985639, -0.494815946, +0.937446237, +0.514274955, -0.785672307
463+0.492285609, -0.933930874, +0.495355010, +0.557664156, +0.527600646, +0.816598058, -0.192715168, -0.514416575, +0.239274621
464covA = getCov(sampleA, dim)
465covA
466+0.265737325, -0.537110455E-1, -0.742574036E-1, -0.281557202, +0.107714802
467-0.537110455E-1, +0.125576705, -0.337079950E-1, +0.109284297, -0.502351150E-1
468-0.742574036E-1, -0.337079950E-1, +0.237120688, +0.240466855E-1, -0.224479869
469-0.281557202, +0.109284297, +0.240466855E-1, +0.448110253, -0.136744186
470+0.107714802, -0.502351150E-1, -0.224479869, -0.136744186, +0.303247452
471meanA = getMean(sampleA, dim)
472meanA
473+0.227665588, -0.299614966, -0.257383496, -0.136709124, +0.165301725
474sampleB = spread([(idim, idim = 1, ndim)], dim, nsamB) ! Generate a singular sample.
475sampleB
476+1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
477+2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
478+3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
479+4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000
480+5.00000000, +5.00000000, +5.00000000, +5.00000000, +5.00000000
481meanB = getMean(sampleB, dim)
482meanB
483+1.00000000, +2.00000000, +3.00000000, +4.00000000, +5.00000000
484sample = reshape([sampleA, sampleB], [ndim, nsamA + nsamB])
485sample
486-0.728370547, +0.108977556E-1, +0.728019714, +0.721251965, +0.212120652, +0.491022468, +0.179573536, -0.440232038, +0.874706626, +1.00000000, +1.00000000, +1.00000000, +1.00000000, +1.00000000
487-0.589933395E-1, -0.297904015, +0.314074039, -0.530974507, -0.536887407, -0.798511028, +0.127491117, -0.228580236, -0.686249256, +2.00000000, +2.00000000, +2.00000000, +2.00000000, +2.00000000
488-0.645056844, +0.801773071, -0.812340856, -0.691423297, -0.755631924E-1, -0.541021347, -0.407658458, +0.210855246, -0.156015754, +3.00000000, +3.00000000, +3.00000000, +3.00000000, +3.00000000
489+0.860636592, -0.251900673, -0.803233862, -0.698131442, -0.508985639, -0.494815946, +0.937446237, +0.514274955, -0.785672307, +4.00000000, +4.00000000, +4.00000000, +4.00000000, +4.00000000
490+0.492285609, -0.933930874, +0.495355010, +0.557664156, +0.527600646, +0.816598058, -0.192715168, -0.514416575, +0.239274621, +5.00000000, +5.00000000, +5.00000000, +5.00000000, +5.00000000
491cov = getCov(sample, dim)
492cov
493+0.307782590, +0.373243004, +0.529867768, +0.552526951, +0.926541805
494+0.373243004, +1.29486227, +1.69814062, +2.25432444, +2.52029538
495+0.529867768, +1.69814062, +2.58852911, +3.10917354, +3.47141004
496+0.552526951, +2.25432444, +3.10917354, +4.21692944, +4.50387001
497+0.926541805, +2.52029538, +3.47141004, +4.50387001, +5.56149530
498mean = getMean(sample, dim)
499mean
500+0.503499329, +0.521676123, +0.905967772, +1.34068716, +1.89197981
501call setCovMeanUpdated(covA, meanA, meanB, real(nsamA, TKG) / real(nsamA + nsamB, TKG), uppDia)
502meanA
503+0.503499329, +0.521676123, +0.905967712, +1.34068704, +1.89197981
504mean ! reference
505+0.503499329, +0.521676123, +0.905967772, +1.34068716, +1.89197981
506covA
507+0.307782769, +0.373243064, +0.529867887, +0.552527189, +0.926542044
508-0.537110455E-1, +1.29486203, +1.69814062, +2.25432420, +2.52029514
509-0.742574036E-1, -0.337079950E-1, +2.58853006, +3.10917401, +3.47141099
510-0.281557202, +0.109284297, +0.240466855E-1, +4.21692991, +4.50387049
511+0.107714802, -0.502351150E-1, -0.224479869, -0.136744186, +5.56149530
512cov ! reference
513+0.307782590, +0.373243004, +0.529867768, +0.552526951, +0.926541805
514+0.373243004, +1.29486227, +1.69814062, +2.25432444, +2.52029538
515+0.529867768, +1.69814062, +2.58852911, +3.10917354, +3.47141004
516+0.552526951, +2.25432444, +3.10917354, +4.21692944, +4.50387001
517+0.926541805, +2.52029538, +3.47141004, +4.50387001, +5.56149530
518
519
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: