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

Return a scalar or array of arbitrary rank of Gamma-distributed random values with the specified shape and scale parameters \((\kappa, \sigma)\) of the Gamma distribution corresponding to the procedure arguments (kappa, sigma). More...

Detailed Description

Return a scalar or array of arbitrary rank of Gamma-distributed random values with the specified shape and scale parameters \((\kappa, \sigma)\) of the Gamma distribution corresponding to the procedure arguments (kappa, sigma).

See the documentation of pm_distGamma for more information on the Probability Density Function (PDF) of the Gamma distribution.

Parameters
[in,out]rng: The input/output scalar that can be an object of,
  1. type rngf_type, implying the use of intrinsic Fortran uniform RNG for Gamma RNG.
  2. type xoshiro256ssw_type, implying the use of xoshiro256** uniform RNG for Gamma RNG.
(optional, default = rngf_type, implying the use of the intrinsic Fortran URNG.)
[out]rand: The output scalar or
  1. array of rank 1, or
  2. array of arbitrary rank if the rng argument is missing or set to rngf_type, or
of,
  1. type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128).
On output, it contains Gamma-distributed random value(s).
[in]kappa: The input scalar (or array of the same shape as other array-like arguments) of the same type and kind as rand, representing the shape parameter of the Gamma distribution.
[in]sigma: The input scalar (or array of the same shape as other array-like arguments) of the same type and kind as rand, representing the scale parameter of the Gamma distribution.


Possible calling interfaces

call setGammaRand(rand, kappa, sigma)
call setGammaRand(rand(..), kappa, sigma)
call setGammaRand(rng, rand, kappa, sigma)
call setGammaRand(rng, rand(:), kappa, sigma)
Return a scalar or array of arbitrary rank of Gamma-distributed random values with the specified shap...
This module contains classes and procedures for computing various statistical quantities related to t...
Warning
The condition 0 < kappa must hold for the corresponding input arguments.
The condition 0 < sigma must hold for the corresponding input arguments.
These conditions are verified only if the library is built with the preprocessor macro CHECK_ENABLED=1.
Remarks
The procedures under discussion are impure.
The procedures under discussion are elemental.
The procedures under discussion are recursive.
Note
For repeated Gamma RNG with fixed kappa, it is best to pass a vector of rand to be filled with random numbers rather than calling the procedures with scalar rand argument repeatedly.
In addition to avoiding procedure call overhead, vectorized RGN in this particular case also avoids an unnecessary division and square-root operation.
See also
getGammaLogPDF
setGammaLogPDF
getGammaCDF
setGammaCDF


Example usage

1program example
2
3 use pm_kind, only: SK, IK
4 use pm_kind, only: RKG => RKS ! all real kinds are supported.
8 use pm_io, only: display_type
9
10 implicit none
11
12 integer(IK), parameter :: NP = 1000_IK
13 real(RKG), dimension(NP) :: Kappa, Sigma, rand
14
15 type(display_type) :: disp
16 disp = display_type(file = "main.out.F90")
17
18 call setLogSpace(Kappa, logx1 = log(0.1_RKG), logx2 = log(10._RKG))
19 call setLogSpace(Sigma, logx1 = log(0.1_RKG), logx2 = log(10._RKG))
20
21 call disp%skip()
22 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
23 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
24 call disp%show("! Generate random numbers from the Gamma distribution.")
25 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
26 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
27 call disp%skip()
28
29 call disp%skip()
30 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
31 call disp%show("! Gamma random value given integer shape and real inverse rate parameters.")
32 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
33 call disp%skip()
34
35 call disp%skip()
36 call disp%show("Kappa(1)")
37 call disp%show( Kappa(1) )
38 call disp%show("Sigma(1)")
39 call disp%show( Sigma(1) )
40 call disp%show("call setGammaRand(rand(1:2), 1._RKG, sigma = Sigma(1))")
41 call setGammaRand(rand(1:2), 1._RKG, sigma = Sigma(1))
42 call disp%show("rand(1)")
43 call disp%show( rand(1) )
44 call disp%skip()
45
46 call disp%skip()
47 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
48 call disp%show("! Gamma random value given real shape and real inverse rate parameters.")
49 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
50 call disp%skip()
51
52 call disp%skip()
53 call disp%show("Kappa(1)")
54 call disp%show( Kappa(1) )
55 call disp%show("Sigma(1)")
56 call disp%show( Sigma(1) )
57 call disp%show("call setGammaRand(rand(1:2), Kappa(1), sigma = Sigma(1))")
58 call setGammaRand(rand(1:2), Kappa(1), sigma = Sigma(1))
59 call disp%show("rand(1)")
60 call disp%show( rand(1) )
61 call disp%skip()
62
63 call disp%skip()
64 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
65 call disp%show("! Gamma random numbers with a fixed set of parameters.")
66 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
67 call disp%skip()
68
69 call disp%skip()
70 call disp%show("Kappa(1:NP:NP/3)")
71 call disp%show( Kappa(1:NP:NP/3) )
72 call disp%show("Sigma(1:NP:NP/3)")
73 call disp%show( Sigma(1:NP:NP/3) )
74 call disp%show("call setGammaRand(rand(1:NP:NP/3), Kappa(1), sigma = Sigma(1))")
75 call setGammaRand(rand(1:NP:NP/3), Kappa(1), sigma = Sigma(1))
76 call disp%show("rand(1:NP:NP/3)")
77 call disp%show( rand(1:NP:NP/3) )
78 call disp%skip()
79
80 call disp%skip()
81 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
82 call disp%show("! Gamma random numbers for a range of parameters.")
83 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
84 call disp%skip()
85
86 call disp%skip()
87 call disp%show("Kappa(1:NP:NP/3)")
88 call disp%show( Kappa(1:NP:NP/3) )
89 call disp%show("Sigma(1:NP:NP/3)")
90 call disp%show( Sigma(1:NP:NP/3) )
91 call disp%show("call setGammaRand(rand(1:NP:NP/3), Kappa(1:NP:NP/3), sigma = Sigma(1:NP:NP/3))")
92 call setGammaRand(rand(1:NP:NP/3), Kappa(1:NP:NP/3), sigma = Sigma(1:NP:NP/3))
93 call disp%show("rand(1:NP:NP/3)")
94 call disp%show( rand(1:NP:NP/3) )
95 call disp%skip()
96
97 call disp%skip()
98 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
99 call disp%show("! Test the mean of a random sample against the analytic answer.")
100 call disp%show("!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
101 call disp%skip()
102
103 block
104 use pm_sampleMean, only: getMean
105 use pm_distExp, only: getExpRand
106 real(RKG) :: kappa, omega, sigma, mean
107 integer(IK) :: itry
108 do itry = 1, 30
109 call disp%skip()
110 call disp%show("kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)")
111 kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
112 call disp%show("[kappa, sigma]")
113 call disp%show( [kappa, sigma] )
114 call disp%show("call setGammaRand(rand, kappa, sigma)")
115 call setGammaRand(rand, kappa, sigma)
116 call disp%show("mean = kappa * sigma")
117 mean = kappa * sigma
118 call disp%show("[getMean(rand), mean]")
119 call disp%show( [getMean(rand), mean] )
120 call disp%skip()
121 end do
122 end block
123
124 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
125 ! Output an example rand array for visualization.
126 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
127
128 block
129 use pm_io, only: getErrTableWrite
130 real(RKG):: rand(5000, 3)
131 call setGammaRand(rand(:, 1), +0.8_RKG, sigma = 2._RKG)
132 call setGammaRand(rand(:, 2), +1.0_RKG, sigma = 2._RKG)
133 call setGammaRand(rand(:, 3), +5.0_RKG, sigma = 2._RKG)
134 if (0 /= getErrTableWrite(SK_"setGammaRand.RK.txt", rand)) error stop "Table writing failed."
135 end block
136
137end program example
Return the linSpace output argument with size(linSpace) elements of evenly-spaced values over the int...
Return the logSpace output argument with size(logSpace) elements of logarithmically-evenly-spaced val...
Return a scalar (or array of arbitrary rank of) random value(s) from the Exponential distribution,...
Generate and return the iostat code resulting from writing the input table of rank 1 or 2 to the spec...
Definition: pm_io.F90:5940
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 (weighted) mean of an input sample of nsam observations with ndim = 1 or 2 at...
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...
Definition: pm_distExp.F90:112
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!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4! Generate random numbers from the Gamma distribution.
5!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7
8
9!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10! Gamma random value given integer shape and real inverse rate parameters.
11!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12
13
14Kappa(1)
15+0.999999940E-1
16Sigma(1)
17+0.999999940E-1
18call setGammaRand(rand(1:2), 1._RKG, sigma = Sigma(1))
19rand(1)
20+0.598768368E-1
21
22
23!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
24! Gamma random value given real shape and real inverse rate parameters.
25!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26
27
28Kappa(1)
29+0.999999940E-1
30Sigma(1)
31+0.999999940E-1
32call setGammaRand(rand(1:2), Kappa(1), sigma = Sigma(1))
33rand(1)
34+0.195523188
35
36
37!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38! Gamma random numbers with a fixed set of parameters.
39!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40
41
42Kappa(1:NP:NP/3)
43+0.999999940E-1, +0.464158833, +2.15443444, +10.0000010
44Sigma(1:NP:NP/3)
45+0.999999940E-1, +0.464158833, +2.15443444, +10.0000010
46call setGammaRand(rand(1:NP:NP/3), Kappa(1), sigma = Sigma(1))
47rand(1:NP:NP/3)
48+0.326829441E-1, +0.922724523E-18, +0.405257754E-2, +0.647063134E-4
49
50
51!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52! Gamma random numbers for a range of parameters.
53!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
54
55
56Kappa(1:NP:NP/3)
57+0.999999940E-1, +0.464158833, +2.15443444, +10.0000010
58Sigma(1:NP:NP/3)
59+0.999999940E-1, +0.464158833, +2.15443444, +10.0000010
60call setGammaRand(rand(1:NP:NP/3), Kappa(1:NP:NP/3), sigma = Sigma(1:NP:NP/3))
61rand(1:NP:NP/3)
62+0.125135131E-14, +0.188318808E-1, +5.77179337, +106.766060
63
64
65!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66! Test the mean of a random sample against the analytic answer.
67!%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68
69
70kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
71[kappa, sigma]
72+0.718482077, +0.307035238
73call setGammaRand(rand, kappa, sigma)
74mean = kappa * sigma
75[getMean(rand), mean]
76+0.211707696, +0.220599309
77
78
79kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
80[kappa, sigma]
81+0.897499144, +0.620168820E-1
82call setGammaRand(rand, kappa, sigma)
83mean = kappa * sigma
84[getMean(rand), mean]
85+0.527538955E-1, +0.556600988E-1
86
87
88kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
89[kappa, sigma]
90+0.482126296, +0.244318679
91call setGammaRand(rand, kappa, sigma)
92mean = kappa * sigma
93[getMean(rand), mean]
94+0.124512605, +0.117792457
95
96
97kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
98[kappa, sigma]
99+1.84421015, +0.326677233
100call setGammaRand(rand, kappa, sigma)
101mean = kappa * sigma
102[getMean(rand), mean]
103+0.583081722, +0.602461457
104
105
106kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
107[kappa, sigma]
108+0.916445196, +0.540956736
109call setGammaRand(rand, kappa, sigma)
110mean = kappa * sigma
111[getMean(rand), mean]
112+0.486813426, +0.495757192
113
114
115kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
116[kappa, sigma]
117+2.16448259, +0.974990055E-1
118call setGammaRand(rand, kappa, sigma)
119mean = kappa * sigma
120[getMean(rand), mean]
121+0.202412486, +0.211034894
122
123
124kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
125[kappa, sigma]
126+0.629441798, +0.850616097
127call setGammaRand(rand, kappa, sigma)
128mean = kappa * sigma
129[getMean(rand), mean]
130+0.539749265, +0.535413325
131
132
133kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
134[kappa, sigma]
135+0.766554624E-1, +0.374298632
136call setGammaRand(rand, kappa, sigma)
137mean = kappa * sigma
138[getMean(rand), mean]
139+0.279017799E-1, +0.286920350E-1
140
141
142kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
143[kappa, sigma]
144+1.73022115, +0.350722969
145call setGammaRand(rand, kappa, sigma)
146mean = kappa * sigma
147[getMean(rand), mean]
148+0.604909360, +0.606828272
149
150
151kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
152[kappa, sigma]
153+0.308323413, +0.354203403
154call setGammaRand(rand, kappa, sigma)
155mean = kappa * sigma
156[getMean(rand), mean]
157+0.107543424, +0.109209202
158
159
160kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
161[kappa, sigma]
162+0.782472849, +4.04998589
163call setGammaRand(rand, kappa, sigma)
164mean = kappa * sigma
165[getMean(rand), mean]
166+3.08144379, +3.16900396
167
168
169kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
170[kappa, sigma]
171+0.497640431, +1.95383561
172call setGammaRand(rand, kappa, sigma)
173mean = kappa * sigma
174[getMean(rand), mean]
175+0.875140965, +0.972307622
176
177
178kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
179[kappa, sigma]
180+0.453534685E-1, +0.373548746
181call setGammaRand(rand, kappa, sigma)
182mean = kappa * sigma
183[getMean(rand), mean]
184+0.191997308E-1, +0.169417318E-1
185
186
187kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
188[kappa, sigma]
189+1.24157143, +0.211577863
190call setGammaRand(rand, kappa, sigma)
191mean = kappa * sigma
192[getMean(rand), mean]
193+0.260753363, +0.262689024
194
195
196kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
197[kappa, sigma]
198+0.221977681, +0.131277546
199call setGammaRand(rand, kappa, sigma)
200mean = kappa * sigma
201[getMean(rand), mean]
202+0.302501600E-1, +0.291406848E-1
203
204
205kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
206[kappa, sigma]
207+0.945052147, +3.31201911
208call setGammaRand(rand, kappa, sigma)
209mean = kappa * sigma
210[getMean(rand), mean]
211+3.11428642, +3.13003087
212
213
214kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
215[kappa, sigma]
216+0.135524452, +0.732155219E-1
217call setGammaRand(rand, kappa, sigma)
218mean = kappa * sigma
219[getMean(rand), mean]
220+0.909386389E-2, +0.992249325E-2
221
222
223kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
224[kappa, sigma]
225+2.04230833, +1.15492058
226call setGammaRand(rand, kappa, sigma)
227mean = kappa * sigma
228[getMean(rand), mean]
229+2.41681290, +2.35870385
230
231
232kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
233[kappa, sigma]
234+0.888535023, +4.35371685
235call setGammaRand(rand, kappa, sigma)
236mean = kappa * sigma
237[getMean(rand), mean]
238+4.00702858, +3.86842990
239
240
241kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
242[kappa, sigma]
243+0.551930219E-1, +0.731519401
244call setGammaRand(rand, kappa, sigma)
245mean = kappa * sigma
246[getMean(rand), mean]
247+0.306411926E-1, +0.403747670E-1
248
249
250kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
251[kappa, sigma]
252+0.211753607, +0.122067027
253call setGammaRand(rand, kappa, sigma)
254mean = kappa * sigma
255[getMean(rand), mean]
256+0.240774006E-1, +0.258481335E-1
257
258
259kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
260[kappa, sigma]
261+0.299967043E-1, +0.985675812
262call setGammaRand(rand, kappa, sigma)
263mean = kappa * sigma
264[getMean(rand), mean]
265+0.253551845E-1, +0.295670256E-1
266
267
268kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
269[kappa, sigma]
270+0.116013601, +1.93261623
271call setGammaRand(rand, kappa, sigma)
272mean = kappa * sigma
273[getMean(rand), mean]
274+0.230711997, +0.224209771
275
276
277kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
278[kappa, sigma]
279+0.433227062, +0.540476926E-1
280call setGammaRand(rand, kappa, sigma)
281mean = kappa * sigma
282[getMean(rand), mean]
283+0.239297170E-1, +0.234149229E-1
284
285
286kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
287[kappa, sigma]
288+0.512578189, +3.60357952
289call setGammaRand(rand, kappa, sigma)
290mean = kappa * sigma
291[getMean(rand), mean]
292+1.96265066, +1.84711623
293
294
295kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
296[kappa, sigma]
297+1.95186138, +1.22501266
298call setGammaRand(rand, kappa, sigma)
299mean = kappa * sigma
300[getMean(rand), mean]
301+2.37409377, +2.39105487
302
303
304kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
305[kappa, sigma]
306+3.34607100, +1.55056524
307call setGammaRand(rand, kappa, sigma)
308mean = kappa * sigma
309[getMean(rand), mean]
310+5.23951626, +5.18830156
311
312
313kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
314[kappa, sigma]
315+0.355441153, +0.329112560E-1
316call setGammaRand(rand, kappa, sigma)
317mean = kappa * sigma
318[getMean(rand), mean]
319+0.113170194E-1, +0.116980150E-1
320
321
322kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
323[kappa, sigma]
324+1.45416820, +0.552167036E-1
325call setGammaRand(rand, kappa, sigma)
326mean = kappa * sigma
327[getMean(rand), mean]
328+0.790459737E-1, +0.802943781E-1
329
330
331kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
332[kappa, sigma]
333+0.425744683, +2.47353053
334call setGammaRand(rand, kappa, sigma)
335mean = kappa * sigma
336[getMean(rand), mean]
337+1.10324228, +1.05309248
338
339

Postprocessing of the example output
1#!/usr/bin/env python
2
3import matplotlib.pyplot as plt
4import pandas as pd
5import numpy as np
6import glob
7import sys
8
9linewidth = 2
10fontsize = 17
11
12marker ={ "CK" : "-"
13 , "IK" : "."
14 , "RK" : "-"
15 }
16xlab = { "CK" : "Gamma Random Value ( real/imaginary components )"
17 , "IK" : "Gamma Random Value ( integer-valued )"
18 , "RK" : "Gamma Random Value ( real-valued )"
19 }
20legends = [ r"$\kappa = 0.8,~\sigma = 2$"
21 , r"$\kappa = 1.0,~\sigma = 2$"
22 , r"$\kappa = 5.0,~\sigma = 2$"
23 ]
24
25for kind in ["IK", "CK", "RK"]:
26
27 pattern = "*." + kind + ".txt"
28 fileList = glob.glob(pattern)
29 if len(fileList) == 1:
30
31 df = pd.read_csv(fileList[0], delimiter = ",", header = None)
32
33 fig = plt.figure(figsize = 1.25 * np.array([6.4, 4.8]), dpi = 200)
34 ax = plt.subplot()
35
36 for j in range(len(df.values[0,:])):
37 if kind == "CK":
38 plt.hist( df.values[:,j]
39 , histtype = "stepfilled"
40 , alpha = 0.5
41 , bins = 75
42 )
43 else:
44 plt.hist( df.values[:,j]
45 , histtype = "stepfilled"
46 , alpha = 0.5
47 , bins = 75
48 )
49 ax.legend ( legends
50 , fontsize = fontsize
51 )
52 plt.xticks(fontsize = fontsize - 2)
53 plt.yticks(fontsize = fontsize - 2)
54 ax.set_xlabel(xlab[kind], fontsize = 17)
55 ax.set_ylabel("Count", fontsize = 17)
56 ax.set_title("Histograms of {} Gamma random values".format(len(df.values[:, 0])), fontsize = 17)
57
58 plt.grid(visible = True, which = "both", axis = "both", color = "0.85", linestyle = "-")
59 ax.tick_params(axis = "y", which = "minor")
60 ax.tick_params(axis = "x", which = "minor")
61
62 plt.savefig(fileList[0].replace(".txt",".png"))
63
64 elif len(fileList) > 1:
65
66 sys.exit("Ambiguous file list exists.")

Visualization of the example output
Test:
test_pm_distGamma


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, Oct 16, 2009, 11:14 AM, Michigan

Definition at line 1193 of file pm_distGamma.F90.


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