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+7.94998980,
+4.45161057,
+3.87645626,
+3.24502325,
+3.21608257
114+2.39749146,
+4.83929014,
+1.17462206,
+6.79872942,
+3.67211962
115+2.75150585,
+5.30928135,
+3.19681406,
+7.65632486,
+7.21404600
116+2.42819500,
+1.88159609,
+6.91840076,
+3.02238083,
+6.87811089
119call setVarMean(var(
1), mean(
1), sample, meang
= sample(
1,
1))
133+6.81599092,
+7.56448460,
+6.41020107,
+1.14715481,
+1.09053707
134+4.99234056,
+3.55882883,
+2.53699541,
+6.23901415,
+6.93865728
135+1.25797367,
+3.77786493,
+5.39258099,
+1.30912256,
+8.22147560
136+7.62193394,
+8.02175522,
+8.21084499,
+2.37028265,
+2.29326057
139if (dim
== 1)
then; meang
= sample(
1,:);
else; meang
= sample(:,
1);
end if
142+5.17206001,
+5.73073339,
+5.63765574,
+2.76639366,
+4.63598251
144+5.17206001,
+5.73073339,
+5.63765574,
+2.76639366,
+4.63598251
146+6.01418972,
+4.28557205,
+4.22307158,
+4.24039268,
+9.05414963
148+6.01419067,
+4.28557205,
+4.22307158,
+4.24039316,
+9.05414963
154+2.69432735,
+1.31120729,
+4.90211630,
+5.18859053,
+8.56194115
155+7.34854364,
+3.49841166,
+1.05653334,
+1.38620520,
+2.35181856
156+4.36591196,
+3.29729652,
+3.78562927,
+8.64351273,
+2.50805187
157+3.27256918,
+4.96659422,
+1.90125799,
+5.40965128,
+1.93678522
160if (dim
== 1)
then; meang
= sample(
1,:);
else; meang
= sample(:,
1);
end if
163+4.53163671,
+3.12830257,
+4.52008057,
+3.49737167
165+4.53163671,
+3.12830234,
+4.52008057,
+3.49737144
167+6.11181307,
+5.17549610,
+4.62186813,
+2.16979480
169+6.11181355,
+5.17549467,
+4.62186813,
+2.16979480
174(
+2.08800459,
-8.98819828), (
+5.08825827,
-2.36627483), (
+4.15972090,
-2.91407824), (
+7.07735348,
-6.14716530), (
+7.84971905,
-6.87458897)
175(
+3.54088163,
-5.38680601), (
+1.95898199,
-6.61446714), (
+1.83908987,
-7.53111124), (
+6.69927216,
-2.99935532), (
+4.82910442,
-2.73835850)
176(
+1.04224539,
-1.37500620), (
+8.59548378,
-8.61305332), (
+6.56422853,
-2.42932081), (
+6.96554708,
-5.31055403), (
+3.40410900,
-7.65198421)
177(
+5.46654701,
-6.09119558), (
+4.82176495,
-5.67076683), (
+2.29676819,
-7.51938629), (
+1.65075016,
-3.27941990), (
+5.46735811,
-4.31308889)
180call setVarMean(var(
1), mean(
1), sample, meang
= sample(
1,
1))
182(
+4.57025909,
-5.24070930)
184(
+4.57025909,
-5.24070835)
194(
+1.01534176,
-6.94132137), (
+5.19471741,
-2.58132601), (
+5.62161636,
-7.30456686), (
+1.44825840,
-6.02162027), (
+1.82166719,
-3.74837732)
195(
+2.49023151,
-3.39636421), (
+8.17473507,
-7.97577333), (
+4.23489189,
-8.41050053), (
+7.83253574,
-7.64903450), (
+1.80643177,
-1.11736822)
196(
+1.21414280,
-2.68762541), (
+7.59500837,
-2.08668661), (
+1.63792324,
-3.19332600), (
+5.17135048,
-1.00223970), (
+5.40919828,
-4.60305119)
197(
+2.16135454,
-4.93095589), (
+6.29819345,
-1.42012405), (
+5.72278070,
-3.33578634), (
+3.66600657,
-8.54844570), (
+1.29871130,
-1.76002932)
200if (dim
== 1)
then; meang
= sample(
1,:);
else; meang
= sample(:,
1);
end if
203(
+1.72026765,
-4.48906660), (
+6.81566334,
-3.51597738), (
+4.30430317,
-5.56104469), (
+4.52953768,
-5.80533504), (
+2.58400202,
-2.80720663)
205(
+1.72026765,
-4.48906660), (
+6.81566334,
-3.51597738), (
+4.30430317,
-5.56104517), (
+4.52953768,
-5.80533504), (
+2.58400202,
-2.80720663)
207+3.04712296,
+8.13713074,
+8.14473152,
+13.9005203,
+4.72061777
209+3.04712343,
+8.13713074,
+8.14473152,
+13.9005184,
+4.72061729
215(
+3.88544273,
-5.26088095), (
+4.00470352,
-2.12165880), (
+3.33925104,
-5.24632263), (
+2.15385342,
-2.76061201), (
+4.77310371,
-3.30723619)
216(
+1.44570684,
-5.38315821), (
+1.07031631,
-7.63331032), (
+5.37028265,
-4.99051952), (
+8.03854084,
-3.03792763), (
+2.27835321,
-6.14734316)
217(
+7.17909908,
-3.83046293), (
+5.53971720,
-7.50785971), (
+4.86186314,
-6.42338419), (
+4.62255764,
-6.36426926), (
+6.81819582,
-3.85481453)
218(
+1.56008577,
-6.56934547), (
+6.55750275,
-5.37784243), (
+8.22171688,
-4.53394413), (
+3.09237242,
-7.15203190), (
+8.25220680,
-1.49130678)
221if (dim
== 1)
then; meang
= sample(
1,:);
else; meang
= sample(:,
1);
end if
224(
+3.63127089,
-3.73934221), (
+3.64064002,
-5.43845177), (
+5.80428648,
-5.59615803), (
+5.53677654,
-5.02489424)
226(
+3.63127065,
-3.73934221), (
+3.64064002,
-5.43845177), (
+5.80428696,
-5.59615850), (
+5.53677702,
-5.02489424)
228+2.42469454,
+9.37989330,
+3.27032351,
+11.4350834
230+2.42469478,
+9.37989330,
+3.27032399,
+11.4350843
240+1.65361500,
+5.37214136,
+7.00109816,
+2.28111219,
+2.34323931
241+8.94827461,
+6.73563385,
+5.03175306,
+3.27840185,
+2.02162170
242+1.11423874,
+1.42326212,
+1.91157293,
+3.53081703,
+4.71305990
243+1.27170420,
+1.43061256,
+4.31328773,
+5.25232840,
+7.57500553
246+2,
+2,
+9,
+8,
+3,
+1,
+9,
+1,
+3,
+2,
+2,
+3,
+7,
+6,
+6,
+2,
+3,
+9,
+9,
+9
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+96.0000000,
+96.0000000
277+4.03435707,
+7.72161913,
+6.33432531,
+6.31476259,
+4.13681412
278+8.65785599,
+3.40431786,
+1.29530859,
+2.84341335,
+2.69444132
279+8.94824600,
+2.30203676,
+2.34408951,
+4.85817719,
+5.71486139
280+6.90595722,
+6.52811050,
+6.25133896,
+5.65091419,
+5.36067152
286if (dim
== 1)
then; meang
= sample(
1,:);
else; meang
= sample(:,
1);
end if
287call setVarMean(var, mean, sample, dim, iweight, iweisum, meang)
289+6.34021282,
+5.98528910,
+4.96682787,
+5.29354811,
+4.42031908
291+6.34021282,
+5.98528910,
+4.96682835,
+5.29354811,
+4.42031908
293+3.80313230,
+3.80760312,
+4.48513794,
+1.60136867,
+1.05233967
294getVar(sample, dim, iweight)
295+3.80313253,
+3.80760336,
+4.48513842,
+1.60136890,
+1.05233979
296[iweisum,
sum(iweight)]
303+3.96113110,
+1.16317797,
+8.30420208,
+2.87538433,
+8.48839188
304+8.25876904,
+5.44241714,
+8.83090401,
+1.35686874,
+3.97847795
305+8.46551609,
+5.08023834,
+4.92049360,
+8.74204159,
+5.25961733
306+6.94744015,
+3.12607765,
+8.86942577,
+2.65129375,
+3.27874422
312if (dim
== 1)
then; meang
= sample(
1,:);
else; meang
= sample(:,
1);
end if
313call setVarMean(var, mean, sample, dim, iweight, iweisum, meang)
315+4.80092669,
+5.41774940,
+6.44711494,
+4.77674484
317+4.80092669,
+5.41774988,
+6.44711447,
+4.77674532
319+8.93300533,
+7.34745121,
+2.95029521,
+5.86790609
320getVar(sample, dim, iweight)
321+8.93300533,
+7.34745121,
+2.95029449,
+5.86790752
322[iweisum,
sum(iweight)]