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.350463316E-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.111616500E-3
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.161919191E-21, +0.506589494E-25, +0.241757636E-8, +0.531675629E-1
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.101767357E-3, +0.392729677E-1, +8.54112053, +105.588081
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+1.00546825, +0.434241235
73call setGammaRand(rand, kappa, sigma)
74mean = kappa * sigma
75[getMean(rand), mean]
76+0.452220440, +0.436615765
77
78
79kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
80[kappa, sigma]
81+1.27718508, +0.509940147
82call setGammaRand(rand, kappa, sigma)
83mean = kappa * sigma
84[getMean(rand), mean]
85+0.638982892, +0.651287973
86
87
88kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
89[kappa, sigma]
90+0.541436449E-1, +0.261118054
91call setGammaRand(rand, kappa, sigma)
92mean = kappa * sigma
93[getMean(rand), mean]
94+0.135476189E-1, +0.141378837E-1
95
96
97kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
98[kappa, sigma]
99+1.16025317, +0.122660562
100call setGammaRand(rand, kappa, sigma)
101mean = kappa * sigma
102[getMean(rand), mean]
103+0.135582343, +0.142317310
104
105
106kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
107[kappa, sigma]
108+2.52769852, +0.642927110
109call setGammaRand(rand, kappa, sigma)
110mean = kappa * sigma
111[getMean(rand), mean]
112+1.59376228, +1.62512589
113
114
115kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
116[kappa, sigma]
117+1.20331061, +0.945478261
118call setGammaRand(rand, kappa, sigma)
119mean = kappa * sigma
120[getMean(rand), mean]
121+1.10778260, +1.13770401
122
123
124kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
125[kappa, sigma]
126+4.17782593, +0.967857659
127call setGammaRand(rand, kappa, sigma)
128mean = kappa * sigma
129[getMean(rand), mean]
130+4.15142822, +4.04354095
131
132
133kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
134[kappa, sigma]
135+0.632569134, +0.426450968E-1
136call setGammaRand(rand, kappa, sigma)
137mean = kappa * sigma
138[getMean(rand), mean]
139+0.269864183E-1, +0.269759726E-1
140
141
142kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
143[kappa, sigma]
144+0.345118403, +0.251940582E-1
145call setGammaRand(rand, kappa, sigma)
146mean = kappa * sigma
147[getMean(rand), mean]
148+0.878522173E-2, +0.869493280E-2
149
150
151kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
152[kappa, sigma]
153+0.117207125, +1.42077124
154call setGammaRand(rand, kappa, sigma)
155mean = kappa * sigma
156[getMean(rand), mean]
157+0.178616077, +0.166524515
158
159
160kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
161[kappa, sigma]
162+0.721429884, +1.66105318
163call setGammaRand(rand, kappa, sigma)
164mean = kappa * sigma
165[getMean(rand), mean]
166+1.27041173, +1.19833338
167
168
169kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
170[kappa, sigma]
171+1.35084963, +0.686897561E-1
172call setGammaRand(rand, kappa, sigma)
173mean = kappa * sigma
174[getMean(rand), mean]
175+0.941719338E-1, +0.927895308E-1
176
177
178kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
179[kappa, sigma]
180+1.72837472, +0.325220264E-1
181call setGammaRand(rand, kappa, sigma)
182mean = kappa * sigma
183[getMean(rand), mean]
184+0.586105883E-1, +0.562102497E-1
185
186
187kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
188[kappa, sigma]
189+1.67769408, +1.59111452
190call setGammaRand(rand, kappa, sigma)
191mean = kappa * sigma
192[getMean(rand), mean]
193+2.67735529, +2.66940331
194
195
196kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
197[kappa, sigma]
198+1.46930611, +0.460368961
199call setGammaRand(rand, kappa, sigma)
200mean = kappa * sigma
201[getMean(rand), mean]
202+0.663441002, +0.676422954
203
204
205kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
206[kappa, sigma]
207+0.653058171, +2.33908558
208call setGammaRand(rand, kappa, sigma)
209mean = kappa * sigma
210[getMean(rand), mean]
211+1.54577231, +1.52755892
212
213
214kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
215[kappa, sigma]
216+2.02758336, +0.965503991
217call setGammaRand(rand, kappa, sigma)
218mean = kappa * sigma
219[getMean(rand), mean]
220+1.92626476, +1.95763981
221
222
223kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
224[kappa, sigma]
225+1.80686975, +1.13532996
226call setGammaRand(rand, kappa, sigma)
227mean = kappa * sigma
228[getMean(rand), mean]
229+2.12197185, +2.05139327
230
231
232kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
233[kappa, sigma]
234+0.553639650, +0.412180930
235call setGammaRand(rand, kappa, sigma)
236mean = kappa * sigma
237[getMean(rand), mean]
238+0.226465300, +0.228199705
239
240
241kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
242[kappa, sigma]
243+0.348401934, +0.112492777
244call setGammaRand(rand, kappa, sigma)
245mean = kappa * sigma
246[getMean(rand), mean]
247+0.399899110E-1, +0.391927026E-1
248
249
250kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
251[kappa, sigma]
252+1.20892048, +1.10068536
253call setGammaRand(rand, kappa, sigma)
254mean = kappa * sigma
255[getMean(rand), mean]
256+1.30128932, +1.33064103
257
258
259kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
260[kappa, sigma]
261+4.07920074, +4.94486237
262call setGammaRand(rand, kappa, sigma)
263mean = kappa * sigma
264[getMean(rand), mean]
265+20.1848640, +20.1710854
266
267
268kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
269[kappa, sigma]
270+2.30473351, +0.521049500E-1
271call setGammaRand(rand, kappa, sigma)
272mean = kappa * sigma
273[getMean(rand), mean]
274+0.119311512, +0.120088026
275
276
277kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
278[kappa, sigma]
279+2.73516870, +0.332421422
280call setGammaRand(rand, kappa, sigma)
281mean = kappa * sigma
282[getMean(rand), mean]
283+0.914106131, +0.909228683
284
285
286kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
287[kappa, sigma]
288+1.86366689, +0.101797506
289call setGammaRand(rand, kappa, sigma)
290mean = kappa * sigma
291[getMean(rand), mean]
292+0.189615786, +0.189716637
293
294
295kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
296[kappa, sigma]
297+0.771563172, +0.594291687
298call setGammaRand(rand, kappa, sigma)
299mean = kappa * sigma
300[getMean(rand), mean]
301+0.440484166, +0.458533585
302
303
304kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
305[kappa, sigma]
306+0.243205577, +0.294669449
307call setGammaRand(rand, kappa, sigma)
308mean = kappa * sigma
309[getMean(rand), mean]
310+0.726856515E-1, +0.716652498E-1
311
312
313kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
314[kappa, sigma]
315+0.509388626, +0.730737209
316call setGammaRand(rand, kappa, sigma)
317mean = kappa * sigma
318[getMean(rand), mean]
319+0.367854625, +0.372229218
320
321
322kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
323[kappa, sigma]
324+1.74241698, +0.101324260
325call setGammaRand(rand, kappa, sigma)
326mean = kappa * sigma
327[getMean(rand), mean]
328+0.178830653, +0.176549107
329
330
331kappa = getExpRand(1._RKG); sigma = getExpRand(1._RKG)
332[kappa, sigma]
333+1.36058033, +0.411827981
334call setGammaRand(rand, kappa, sigma)
335mean = kappa * sigma
336[getMean(rand), mean]
337+0.529349804, +0.560325027
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: