18 type(display_type) :: disp
22 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
23 call disp%show(
"!Compute the variance of a 1-D sample.")
24 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
28 real(TKG) :: var, mean
29 real(TKG),
allocatable :: sample(:)
30 call disp%show(
"sample = getLinSpace(1._TKG, 9._TKG, 5_IK)")
34 call disp%show(
"call setVarMean(var, mean, sample, meang = sample(1))")
35 call setVarMean(var, mean, sample, meang
= sample(
1))
38 call disp%show(
"getMean(sample) ! for comparison.")
42 call disp%show(
"getVar(sample) ! for comparison.")
44 call disp%show(
"call setVarMean(var, mean, sample, dim = 1_IK, meang = sample(1))")
45 call setVarMean(var, mean, sample,
dim = 1_IK, meang
= sample(
1))
48 call disp%show(
"getMean(sample, dim = 1_IK) ! for comparison.")
52 call disp%show(
"getVar(sample, dim = 1_IK) ! for comparison.")
60 complex(TKG),
allocatable :: sample(:)
61 call disp%show(
"sample = cmplx(getLinSpace(1., 9., 5_IK), -getLinSpace(1., 9., 5_IK), TKG)")
65 call disp%show(
"call setVarMean(var, mean, sample, meang = sample(1))")
66 call setVarMean(var, mean, sample, meang
= sample(
1))
69 call disp%show(
"getMean(sample) ! for comparison.")
73 call disp%show(
"getVar(sample) ! for comparison.")
75 call disp%show(
"call setVarMean(var, mean, sample, dim = 1_IK, meang = sample(1))")
76 call setVarMean(var, mean, sample,
dim = 1_IK, meang
= sample(
1))
79 call disp%show(
"getMean(sample, dim = 1_IK) ! for comparison.")
83 call disp%show(
"getVar(sample, dim = 1_IK) ! for comparison.")
89 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
90 call disp%show(
"!Compute the variance of a 1-D weighted sample.")
91 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
95 real(TKG) :: var, weisum
96 real(TKG),
allocatable :: weight(:)
97 real(TKG),
allocatable :: sample(:)
99 call disp%show(
"sample = getLinSpace(1._TKG, 9._TKG, 5_IK)")
103 call disp%show(
"weight = getLinSpace(1._TKG, 9._TKG, size(sample, kind = IK))")
104 weight
= getLinSpace(
1._TKG,
9._TKG,
size(sample,
kind = IK))
107 call disp%show(
"call setVarMean(var, mean, sample, weight, weisum, meang = sample(1))")
108 call setVarMean(var, mean, sample, weight, weisum, meang
= sample(
1))
111 call disp%show(
"getMean(sample, weight) ! for comparison.")
115 call disp%show(
"getVar(sample, weight) ! for comparison.")
117 call disp%show(
"call setVarMean(var, mean, sample, 1_IK, weight, weisum, meang = sample(1))")
118 call setVarMean(var, mean, sample,
1_IK, weight, weisum, meang
= sample(
1))
121 call disp%show(
"getMean(sample, 1_IK, weight) ! for comparison.")
125 call disp%show(
"getVar(sample, 1_IK, weight) ! for comparison.")
131 real(TKG) :: var, weisum
132 real(TKG),
allocatable :: weight(:)
133 complex(TKG),
allocatable :: sample(:)
135 call disp%show(
"sample = cmplx(getLinSpace(1., 9., 5_IK), -getLinSpace(1., 9., 5_IK), TKG)")
139 call disp%show(
"weight = getLinSpace(1._TKG, 9._TKG, size(sample, kind = IK))")
140 weight
= getLinSpace(
1._TKG,
9._TKG,
size(sample,
kind = IK))
143 call disp%show(
"call setVarMean(var, mean, sample, weight, weisum, meang = sample(1))")
144 call setVarMean(var, mean, sample, weight, weisum, meang
= sample(
1))
147 call disp%show(
"getMean(sample, weight) ! for comparison.")
151 call disp%show(
"getVar(sample, weight) ! for comparison.")
153 call disp%show(
"call setVarMean(var, mean, sample, 1_IK, weight, weisum, meang = sample(1))")
154 call setVarMean(var, mean, sample,
1_IK, weight, weisum, meang
= sample(
1))
157 call disp%show(
"getMean(sample, 1_IK, weight) ! for comparison.")
161 call disp%show(
"getVar(sample, 1_IK, weight) ! for comparison.")
167 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
168 call disp%show(
"!Compute the variance of a 2-D array.")
169 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
173 real(TKG),
allocatable :: var(:)
174 real(TKG),
allocatable :: meang(:), mean(:), sample(:,:)
176 call disp%show(
"sample = getUnifRand(1._TKG, 9._TKG, 4_IK, 5_IK)")
180 call disp%show(
"call setResized(var, 1_IK)")
182 call disp%show(
"call setResized(mean, 1_IK)")
184 call disp%show(
"call setVarMean(var(1), mean(1), sample, meang = sample(1,1))")
185 call setVarMean(var(
1), mean(
1), sample, meang
= sample(
1,
1))
188 call disp%show(
"getMean(sample) ! for comparison.")
192 call disp%show(
"getVar(sample) ! for comparison.")
196 call disp%show(
"dim ! The observations axis.")
198 call disp%show(
"sample = getUnifRand(1._TKG, 9._TKG, 4_IK, 5_IK)")
202 call disp%show(
"call setResized(var, size(sample, 3 - dim, IK))")
204 call disp%show(
"call setResized(mean, size(sample, 3 - dim, IK))")
206 call disp%show(
"if (dim == 1) then; meang = sample(1,:); else; meang = sample(:,1); end if")
207 if (dim
== 1)
then; meang
= sample(
1,:);
else; meang
= sample(:,
1);
end if
208 call disp%show(
"call setVarMean(var, mean, sample, dim, meang)")
209 call setVarMean(var, mean, sample, dim, meang)
212 call disp%show(
"getMean(sample, dim) ! for comparison.")
216 call disp%show(
"getVar(sample, dim) ! for comparison.")
223 real(TKG),
allocatable :: var(:)
224 complex(TKG),
allocatable :: meang(:), mean(:), sample(:,:)
226 call disp%show(
"sample = cmplx(getUnifRand(1., 9., 4_IK, 5_IK), -getUnifRand(1., 9., 4_IK, 5_IK), TKG)")
230 call disp%show(
"call setResized(var, 1_IK)")
232 call disp%show(
"call setResized(mean, 1_IK)")
234 call disp%show(
"call setVarMean(var(1), mean(1), sample, meang = sample(1,1))")
235 call setVarMean(var(
1), mean(
1), sample, meang
= sample(
1,
1))
238 call disp%show(
"getMean(sample) ! for comparison.")
242 call disp%show(
"getVar(sample) ! for comparison.")
246 call disp%show(
"dim ! The observations axis.")
248 call disp%show(
"sample = cmplx(getUnifRand(1., 9., 4_IK, 5_IK), -getUnifRand(1., 9., 4_IK, 5_IK), TKG)")
252 call disp%show(
"call setResized(var, size(sample, 3 - dim, IK))")
254 call disp%show(
"call setResized(mean, size(sample, 3 - dim, IK))")
256 call disp%show(
"if (dim == 1) then; meang = sample(1,:); else; meang = sample(:,1); end if")
257 if (dim
== 1)
then; meang
= sample(
1,:);
else; meang
= sample(:,
1);
end if
258 call disp%show(
"call setVarMean(var, mean, sample, dim, meang)")
259 call setVarMean(var, mean, sample, dim, meang)
262 call disp%show(
"getMean(sample, dim) ! for comparison.")
266 call disp%show(
"getVar(sample, dim) ! for comparison.")
273 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
274 call disp%show(
"!Compute the variance of a 2-D weighted sample.")
275 call disp%show(
"!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
280 real(TKG),
allocatable :: var(:)
281 real(TKG),
allocatable :: rweight(:)
282 real(TKG),
allocatable :: meang(:), mean(:), sample(:,:)
283 integer(IK),
allocatable :: iweight(:)
284 integer(IK) :: iweisum
286 call disp%show(
"sample = getUnifRand(1._TKG, 9._TKG, 4_IK, 5_IK)")
290 call disp%show(
"iweight = getUnifRand(1, 9, size(sample, kind = IK))")
296 call disp%show(
"call setResized(var, 1_IK)")
298 call disp%show(
"call setResized(mean, 1_IK)")
300 call disp%show(
"call setVarMean(var(1), mean(1), sample, iweight, iweisum, meang = sample(1,1))")
301 call setVarMean(var(
1), mean(
1), sample, iweight, iweisum, meang
= sample(
1,
1))
304 call disp%show(
"getMean(sample, iweight) ! for comparison.")
308 call disp%show(
"getVar(sample, iweight) ! for comparison.")
310 call disp%show(
"[iweisum, sum(iweight)] ! for comparison.")
311 call disp%show( [iweisum,
sum(iweight)] )
312 call disp%show(
"call setVarMean(var(1), mean(1), sample, rweight, rweisum, meang = sample(1,1))")
313 call setVarMean(var(
1), mean(
1), sample, rweight, rweisum, meang
= sample(
1,
1))
316 call disp%show(
"getMean(sample, rweight) ! for comparison.")
320 call disp%show(
"getVar(sample, rweight) ! for comparison.")
322 call disp%show(
"[rweisum, sum(rweight)] ! for comparison.")
323 call disp%show( [rweisum,
sum(rweight)] )
326 call disp%show(
"dim ! The observations axis.")
328 call disp%show(
"sample = getUnifRand(1._TKG, 9._TKG, 4_IK, 5_IK)")
332 call disp%show(
"iweight = getUnifRand(1, 9, size(sample, dim, IK))")
336 call disp%show(
"call setResized(var, size(sample, 3 - dim, IK))")
338 call disp%show(
"call setResized(mean, size(sample, 3 - dim, IK))")
340 call disp%show(
"if (dim == 1) then; meang = sample(1,:); else; meang = sample(:,1); end if")
341 if (dim
== 1)
then; meang
= sample(
1,:);
else; meang
= sample(:,
1);
end if
342 call disp%show(
"call setVarMean(var, mean, sample, dim, iweight, iweisum, meang)")
343 call setVarMean(var, mean, sample, dim, iweight, iweisum, meang)
346 call disp%show(
"getMean(sample, dim, iweight) ! for comparison.")
350 call disp%show(
"getVar(sample, dim, iweight) ! for comparison.")
352 call disp%show(
"[iweisum, sum(iweight)] ! for comparison.")
353 call disp%show( [iweisum,
sum(iweight)] )
Allocate or resize (shrink or expand) an input allocatable scalar string or array of rank 1....
Generate count evenly spaced points over the interval [x1, x2] if x1 < x2, or [x2,...
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.
This is a generic method of the derived type display_type with pass attribute.
Generate and return the (weighted) mean of an input sample of nsam observations with ndim = 1 or 2 at...
Generate a sample of shape (nsam), or (ndim, nsam) or (nsam, ndim) that is shifted by the specified i...
Generate and return the variance of the input sample of type complex or real of shape (nsam) or (ndim...
This module contains procedures and generic interfaces for resizing allocatable arrays of various typ...
This module contains procedures and generic interfaces for generating arrays with linear or logarithm...
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...
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
integer, parameter RK
The default real kind in the ParaMonte library: real64 in Fortran, c_double in C-Fortran Interoperati...
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
integer, parameter RKS
The single-precision real kind in Fortran mode. On most platforms, this is an 32-bit real kind.
This module contains classes and procedures for computing the properties related to the covariance ma...
This module contains classes and procedures for computing the first moment (i.e., the statistical mea...
This module contains classes and procedures for shifting univariate or multivariate samples by arbitr...
Generate and return an object of type display_type.
8+1.00000000,
+3.00000000,
+5.00000000,
+7.00000000,
+9.00000000
9call setVarMean(var, mean, sample, meang
= sample(
1))
18call setVarMean(var, mean, sample,
dim = 1_IK, meang
= sample(
1))
30(
+1.00000000,
-1.00000000), (
+3.00000000,
-3.00000000), (
+5.00000000,
-5.00000000), (
+7.00000000,
-7.00000000), (
+9.00000000,
-9.00000000)
31call setVarMean(var, mean, sample, meang
= sample(
1))
33(
+5.00000000,
-5.00000000)
35(
+5.00000000,
-5.00000000)
40call setVarMean(var, mean, sample,
dim = 1_IK, meang
= sample(
1))
42(
+5.00000000,
-5.00000000)
44(
+5.00000000,
-5.00000000)
57+1.00000000,
+3.00000000,
+5.00000000,
+7.00000000,
+9.00000000
60+1.00000000,
+3.00000000,
+5.00000000,
+7.00000000,
+9.00000000
61call setVarMean(var, mean, sample, weight, weisum, meang
= sample(
1))
70call setVarMean(var, mean, sample,
1_IK, weight, weisum, meang
= sample(
1))
77getVar(sample,
1_IK, weight)
82(
+1.00000000,
-1.00000000), (
+3.00000000,
-3.00000000), (
+5.00000000,
-5.00000000), (
+7.00000000,
-7.00000000), (
+9.00000000,
-9.00000000)
85+1.00000000,
+3.00000000,
+5.00000000,
+7.00000000,
+9.00000000
86call setVarMean(var, mean, sample, weight, weisum, meang
= sample(
1))
88(
+6.59999990,
-6.59999990)
90(
+6.59999990,
-6.59999990)
95call setVarMean(var, mean, sample,
1_IK, weight, weisum, meang
= sample(
1))
97(
+6.59999990,
-6.59999990)
99(
+6.59999990,
-6.59999990)
102getVar(sample,
1_IK, weight)
113+2.71549416,
+8.70144176,
+5.82819033,
+1.19167852,
+8.32015133
114+7.69862223,
+5.48890543,
+3.90452385,
+5.66230059,
+3.40289307
115+2.02779531,
+1.91145182,
+4.23033762,
+8.16210365,
+1.42035627
116+4.06375647,
+2.13256884,
+2.12689304,
+6.76190281,
+5.46591902
119call setVarMean(var(
1), mean(
1), sample, meang
= sample(
1,
1))
133+7.82783556,
+6.55134678,
+8.08672714,
+1.38690710,
+4.06228542
134+1.49205065,
+1.23432016,
+3.60968208,
+7.44220686,
+2.50107288
135+3.85657740,
+6.44197893,
+3.09694004,
+8.52971458,
+6.62574482
136+1.98181057,
+3.74114513,
+5.61530495,
+1.97345972,
+3.08116484
139if (dim
== 1)
then; meang
= sample(
1,:);
else; meang
= sample(:,
1);
end if
142+3.78956842,
+4.49219799,
+5.10216331,
+4.83307171,
+4.06756687
144+3.78956866,
+4.49219799,
+5.10216331,
+4.83307219,
+4.06756687
146+6.21466446,
+4.80489683,
+3.85484028,
+10.1315489,
+2.49279881
148+6.21466780,
+4.80489683,
+3.85483909,
+10.1315460,
+2.49279857
154+4.86519575,
+5.17080021,
+6.07770634,
+4.70440483,
+3.72420311
155+8.93040085,
+7.03005695,
+4.77905560,
+5.46933937,
+7.68396139
156+2.40399837,
+8.78949642,
+8.46528149,
+3.81796646,
+2.42425966
157+2.52637243,
+6.82366037,
+6.51675224,
+2.33033037,
+2.08296776
160if (dim
== 1)
then; meang
= sample(
1,:);
else; meang
= sample(:,
1);
end if
163+4.90846205,
+6.77856255,
+5.18020058,
+4.05601692
165+4.90846205,
+6.77856302,
+5.18020010,
+4.05601645
167+0.576386869,
+2.24509978,
+8.19539452,
+4.58516026
169+0.576386869,
+2.24509954,
+8.19539261,
+4.58516026
174(
+8.19689751,
-6.26212835), (
+6.32065010,
-7.55263567), (
+4.96137047,
-2.30146790), (
+2.67209959,
-7.61132574), (
+5.45345354,
-5.85012150)
175(
+2.02113676,
-1.36360502), (
+1.95255613,
-4.96722412), (
+5.40246725,
-3.70249081), (
+3.66531849,
-1.05352640), (
+2.48270464,
-5.66561127)
176(
+6.91553974,
-8.15740585), (
+5.44673347,
-2.84762049), (
+2.15664864,
-5.02132463), (
+4.30838060,
-3.00564957), (
+8.53755379,
-4.40673399)
177(
+7.20681238,
-3.82577229), (
+2.12556839,
-1.73339558), (
+4.46287584,
-8.44206905), (
+4.57033920,
-3.33061457), (
+3.00900078,
-7.71163940)
180call setVarMean(var(
1), mean(
1), sample, meang
= sample(
1,
1))
182(
+4.59340572,
-4.74061823)
184(
+4.59340525,
-4.74061775)
194(
+8.24742699,
-4.64505148), (
+1.69802570,
-5.62454796), (
+4.95255470,
-8.15800667), (
+3.25329256,
-1.54981565), (
+6.34921980,
-7.00323200)
195(
+4.49966097,
-1.22723103), (
+6.68869209,
-3.12893295), (
+5.38118982,
-6.65558290), (
+1.00942326,
-7.64161825), (
+6.76740026,
-8.24177361)
196(
+6.53018951,
-5.07036495), (
+3.41584492,
-8.42527962), (
+1.08111382,
-7.82675076), (
+1.53410196,
-4.53349733), (
+5.77184248,
-2.81533957)
197(
+8.77171135,
-1.20631790), (
+1.57522583,
-1.31798840), (
+6.65175056,
-4.27846575), (
+3.71951199,
-1.02973318), (
+2.39030981,
-2.11225986)
200if (dim
== 1)
then; meang
= sample(
1,:);
else; meang
= sample(:,
1);
end if
203(
+7.01224709,
-3.03724146), (
+3.34444714,
-4.62418747), (
+4.51665211,
-6.72970152), (
+2.37908244,
-3.68866611), (
+5.31969309,
-5.04315138)
205(
+7.01224709,
-3.03724146), (
+3.34444714,
-4.62418747), (
+4.51665211,
-6.72970104), (
+2.37908244,
-3.68866634), (
+5.31969309,
-5.04315090)
207+6.12847805,
+11.4114208,
+6.63915730,
+8.28378201,
+9.89196777
209+6.12847900,
+11.4114199,
+6.63915682,
+8.28378201,
+9.89196968
215(
+8.91586399,
-3.28891897), (
+5.00160074,
-7.15572786), (
+1.14957523,
-2.88127565), (
+4.83427382,
-2.08714008), (
+3.41051817,
-3.86440372)
216(
+1.30766630,
-7.21664619), (
+7.59619904,
-3.38078403), (
+7.66982651,
-7.94244242), (
+3.81181669,
-5.91459703), (
+6.09494305,
-3.96149969)
217(
+4.46235991,
-5.73899221), (
+4.33346128,
-7.77805328), (
+8.63883686,
-7.79576492), (
+6.03275871,
-2.11102772), (
+1.02897978,
-4.26668024)
218(
+2.71071386,
-3.30129671), (
+1.61056662,
-1.09335375), (
+7.74437094,
-8.18033218), (
+6.72093534,
-8.79166794), (
+1.56245613,
-8.96508217)
221if (dim
== 1)
then; meang
= sample(
1,:);
else; meang
= sample(:,
1);
end if
224(
+4.66236639,
-3.85549331), (
+5.29609013,
-5.68319368), (
+4.89927912,
-5.53810358), (
+4.06980848,
-6.06634617)
226(
+4.66236639,
-3.85549331), (
+5.29609060,
-5.68319416), (
+4.89927959,
-5.53810406), (
+4.06980848,
-6.06634665)
228+9.48650265,
+9.08968544,
+10.8550940,
+17.4775696
230+9.48650169,
+9.08968639,
+10.8550940,
+17.4775696
240+4.51960468,
+8.71387768,
+1.69439554,
+3.91203833,
+6.96232891
241+2.96419239,
+5.04764128,
+6.34306145,
+4.60577965,
+5.04803562
242+7.45471573,
+1.78127575,
+6.18107462,
+7.87240362,
+8.38695335
243+4.97915459,
+8.43780994,
+5.47503328,
+2.24818325,
+2.47297287
246+7,
+8,
+1,
+4,
+2,
+3,
+7,
+7,
+1,
+8,
+3,
+2,
+5,
+3,
+8,
+4,
+4,
+5,
+4,
+7
250call setVarMean(var(
1), mean(
1), sample, iweight, iweisum, meang
= sample(
1,
1))
259[iweisum,
sum(iweight)]
261call setVarMean(var(
1), mean(
1), sample, rweight, rweisum, meang
= sample(
1,
1))
270[rweisum,
sum(rweight)]
271+93.0000000,
+93.0000000
277+1.88925505,
+5.69060040,
+4.45722532,
+8.87386036,
+3.64197922
278+5.64725828,
+3.45551586,
+5.88054228,
+3.79754496,
+5.27457094
279+2.92074537,
+5.57918119,
+5.13014936,
+5.57522345,
+4.37556982
280+6.04048061,
+7.83769131,
+2.45026779,
+5.34664249,
+3.24765253
286if (dim
== 1)
then; meang
= sample(
1,:);
else; meang
= sample(:,
1);
end if
287call setVarMean(var, mean, sample, dim, iweight, iweisum, meang)
289+3.75772834,
+5.78364229,
+4.51888990,
+5.97913837,
+4.10510397
291+3.75772858,
+5.78364277,
+4.51888990,
+5.97913933,
+4.10510397
293+2.67502379,
+1.69817841,
+1.34278738,
+2.63114238,
+0.430238515
294getVar(sample, dim, iweight)
295+2.67502451,
+1.69817817,
+1.34278738,
+2.63114166,
+0.430238545
296[iweisum,
sum(iweight)]
303+1.78249931,
+2.72149134,
+1.68096256,
+3.83078337,
+6.70195627
304+3.64154243,
+4.76133633,
+2.12173319,
+1.54790163,
+4.58819962
305+1.90334749,
+3.05829954,
+2.15340805,
+3.08271360,
+3.97181892
306+7.09604263,
+7.57688141,
+2.75400877,
+5.64762306,
+5.78451347
312if (dim
== 1)
then; meang
= sample(
1,:);
else; meang
= sample(:,
1);
end if
313call setVarMean(var, mean, sample, dim, iweight, iweisum, meang)
315+4.36925888,
+3.33067369,
+3.16987324,
+5.84892559
317+4.36925936,
+3.33067393,
+3.16987324,
+5.84892607
319+3.97630215,
+1.87089038,
+0.576907396,
+1.21982884
320getVar(sample, dim, iweight)
321+3.97630262,
+1.87089038,
+0.576907456,
+1.21982920
322[iweisum,
sum(iweight)]