This is the derived type for declaring and generating objects of type xoshiro256ssg_type containing a unique instance of a greedy Xoshiro256** random number generator (RNG).
Unlike the Xoshiro256**
algorithm as implemented by the derived type xoshiro256ssw_type, the greedy version of the algorithm here does not waste any of the randomly generated 64 bits in each update the RNG state.
See also the documentation of xoshiro256ssg_typer for information on the constructor of this type.
- Parameters
-
[in] | seed | : The input scalar of type integer of kind IK64, containing an integer that serves as the starting point to generate the full deterministic RNG seed.
Specify this input argument if you wish to make random simulations reproducible and deterministic, even between multiple independent runs of the program compiled by the same compiler.
(optional. If missing, it is set to a processor-dependent value based on the current date and time.) |
[in] | imageID | : The input positive scalar integer of default kind IK containing the ID of the current image/thread/process.
This can be,
-
The Coarray image ID as returned by Fortran intrinsic
this_image() within a global team of Coarray images.
-
The MPI rank of the processor (plus one) as returned by the MPI library intrinsic
mpi_comm_rank() .
-
The OpenMP thread number as returned by the OpenMP library intrinsic
omp_get_thread_num() .
-
Any (positive) integer that uniquely identifies the current processor from other processes.
The image/process/thread ID can be readily obtained by calling getImageID.
This number will be used to set the RNG seed uniquely on each processor.
(optional. If missing, the RNG seed will be set as if it is called in a serial application (or called on the first image).) |
[in] | jump | : The input vector of size xoshiro256ssStateSize of type integer of kind IK64, whose value sets the jump size of the random number generator.
It can be,
-
xoshiro256ssJump128, corresponding to a jump size of
imageID * 2**128 .
This jump can be used to generate up to 2**128 unique RNG sequences in parallel, each with length 2**128 .
-
xoshiro256ssJump192, corresponding to a jump size of
imageID * 2**192 .
This jump can be used to generate up to 2**64 unique RNG sequences in parallel, each with length 2**192 .
(optional. default = xoshiro256ssJump128) |
- Returns
rng
: The output scalar object (or array of objects, of the same rank and shape as the input array-like arguments) of type xoshiro256ssg_type containing an instance of a splitmix64 random number generator.
Possible calling interfaces ⛓
type(xoshiro256ssg_type) :: rng
Generate and return a scalar or a contiguous array of rank 1 of length s1 of randomly uniformly distr...
Return a uniform random scalar or contiguous array of arbitrary rank of randomly uniformly distribute...
This module contains classes and procedures for computing various statistical quantities related to t...
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
This is the derived type for declaring and generating objects of type xoshiro256ssg_type containing a...
- Warning
- The condition
0 < imageID
must hold for the corresponding input arguments.
This condition is verified only if the library is built with the preprocessor macro CHECK_ENABLED=1
.
-
Although the components of this derived type are
public
, they are theoretically protected
.
The end users must not manipulate the component values at any stages of the random number generation.
- Note
- Without initializing objects of this derived type, the generated RNGs will always be deterministic, always yielding identical sequences.
- See also
- rngf
isHead
getUnifCDF
getUnifRand
setUnifRand
getUnifRandState
setUnifRandState
rngu_type
rngf_type
splitmix64_type
xoshiro256ssw_type
getUnifRandStateSize
Example usage ⛓
14 integer :: itry, ntry
= 5
15 type(xoshiro256ssg_type) :: rng
16 type(display_type) :: disp
21 call disp%show(
"rng = xoshiro256ssg_type()")
26 integer :: rand, lb, ub
28 call disp%show(
"lb = -3_IKD; ub = 5_IKD")
29 lb
= -3_IKD; ub
= 5_IKD
30 call disp%show(
"rand = getUnifRand(rng, lb, ub)")
34 call disp%show(
.and."call setAsserted(lb <= rand rand <= ub)")
42 integer(IKG) :: rand, lb, ub
46 call disp%show(
"call setUnifRand(rng, rand)")
48 call disp%show(
"[-huge(rand) - 1_IKG, rand, huge(rand)]")
49 call disp%show( [
-huge(rand)
- 1_IKG, rand,
huge(rand)] )
56 integer(IKG) :: rand, lb, ub
60 call disp%show(
"call setUnifRand(rng, rand)")
62 call disp%show(
"[-huge(rand) - 1_IKG, rand, huge(rand)]")
63 call disp%show( [
-huge(rand)
- 1_IKG, rand,
huge(rand)] )
70 integer(IKG) :: rand, lb, ub
74 call disp%show(
"lb = -3_IKG; ub = 5_IKG")
75 lb
= -3_IKG; ub
= 5_IKG
76 call disp%show(
"rand = getUnifRand(rng, lb, ub)")
80 call disp%show(
.and."call setAsserted(lb <= rand rand <= ub)")
88 integer(IKG) :: rand, lb, ub
92 call disp%show(
"lb = -huge(0_IKG); ub = huge(0_IKG) / 2_IKG")
93 lb
= -huge(
0_IKG); ub
= huge(
0_IKG)
/ 2_IKG
94 call disp%show(
"rand = getUnifRand(rng, lb, ub)")
98 call disp%show(
.and."call setAsserted(lb <= rand rand <= ub)")
105 character(
2) :: rand, lb, ub
107 call disp%show(
"lb = 'ai'; ub = 'by'")
109 call disp%show(
"rand = getUnifRand(rng, lb, ub)")
113 call disp%show(
.and."call setAsserted(lb <= rand rand <= ub)")
121 logical :: rand, lb, ub
123 call disp%show(
"lb = .false.; ub = .true.")
124 lb
= .false.; ub
= .true.
125 call disp%show(
"rand = getUnifRand(rng, lb, ub)")
129 call disp%show(
.and."call setAsserted(lb <= rand rand <= ub)")
137 complex :: rand, lb, ub
139 call disp%show(
"lb = (-1., +1.); ub = (1., +2.)")
140 lb
= (
-1.,
+1.); ub
= (
1.,
+2.)
141 call disp%show(
"rand = getUnifRand(rng, lb, ub)")
145 call disp%show(
.and."call setAsserted(lb <= rand rand < ub)")
153 real(RKG) :: rand, lb, ub
154 call disp%show(
"lb = 2._RKG; ub = lb + spacing(lb)")
155 lb
= 2._RKG; ub
= lb
+ spacing(lb)
157 call disp%show(
"call setUnifRand(rng, rand, lb, ub)")
159 call disp%show(
"[lb, rand, ub], format = getFormat(width = 42_IK, ndigit = 35_IK)")
160 call disp%show( [lb, rand, ub],
format = getFormat(width
= 42_IK, ndigit
= 35_IK) )
161 call disp%show(
.and."call setAsserted(lb <= rand rand < ub)")
172 call disp%show(
"rand = getUnifRand(rng, lb, ub)")
176 call disp%show(
.and."call setAsserted(lb <= rand rand < ub)")
187 integer :: rand(
5000)
189 if (
0 /= getErrTableWrite(SK_
"xoshiro256ssg_type.IK.txt", rand))
error stop "Table writing failed."
193 complex :: rand(
5000)
195 if (
0 /= getErrTableWrite(SK_
"xoshiro256ssg_type.CK.txt", rand))
error stop "Table writing failed."
201 if (
0 /= getErrTableWrite(SK_
"xoshiro256ssg_type.RK.txt", rand))
error stop "Table writing failed."
Verify the input assertion holds and if it does not, print the (optional) input message on stdout and...
Generate and return an object of type stop_type with the user-specified input attributes.
Generate and return the iostat code resulting from writing the input table of rank 1 or 2 to the spec...
This is a generic method of the derived type display_type with pass attribute.
This module contains procedures and generic interfaces for checking if both of the corresponding real...
This module contains classes and procedures for reporting and handling errors.
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.
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
integer, parameter IKS
The single-precision integer kind in Fortran mode. On most platforms, this is a 32-bit integer kind.
integer, parameter IKL
The scalar integer constant of intrinsic default kind, representing the lowest range integer kind typ...
integer, parameter IKD
The double precision integer kind in Fortran mode. On most platforms, this is a 64-bit integer kind.
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
integer, parameter RKH
The scalar integer constant of intrinsic default kind, representing the highest-precision real kind t...
This module contains procedures and generic interfaces for performing a variety of logical comparison...
Generate and return an object of type display_type.
Example Unix compile command via Intel ifort
compiler ⛓
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example Windows Batch compile command via Intel ifort
compiler ⛓
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
Example Unix / MinGW compile command via GNU gfortran
compiler ⛓
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
Example output ⛓
13lb
= -3_IKD; ub
= 5_IKD
18lb
= -3_IKD; ub
= 5_IKD
23lb
= -3_IKD; ub
= 5_IKD
32[
-huge(rand)
- 1_IKG, rand,
huge(rand)]
33-2147483648,
-1602576114,
+2147483647
37[
-huge(rand)
- 1_IKG, rand,
huge(rand)]
38-2147483648,
-65535056,
+2147483647
42[
-huge(rand)
- 1_IKG, rand,
huge(rand)]
43-2147483648,
-656909922,
+2147483647
47[
-huge(rand)
- 1_IKG, rand,
huge(rand)]
48-2147483648,
-333595577,
+2147483647
52[
-huge(rand)
- 1_IKG, rand,
huge(rand)]
53-2147483648,
+1654462843,
+2147483647
58[
-huge(rand)
- 1_IKG, rand,
huge(rand)]
63[
-huge(rand)
- 1_IKG, rand,
huge(rand)]
68[
-huge(rand)
- 1_IKG, rand,
huge(rand)]
73[
-huge(rand)
- 1_IKG, rand,
huge(rand)]
78[
-huge(rand)
- 1_IKG, rand,
huge(rand)]
83lb
= -3_IKG; ub
= 5_IKG
90lb
= -3_IKG; ub
= 5_IKG
97lb
= -3_IKG; ub
= 5_IKG
104lb
= -3_IKG; ub
= 5_IKG
111lb
= -3_IKG; ub
= 5_IKG
119lb
= -huge(
0_IKG); ub
= huge(
0_IKG)
/ 2_IKG
126lb
= -huge(
0_IKG); ub
= huge(
0_IKG)
/ 2_IKG
133lb
= -huge(
0_IKG); ub
= huge(
0_IKG)
/ 2_IKG
140lb
= -huge(
0_IKG); ub
= huge(
0_IKG)
/ 2_IKG
147lb
= -huge(
0_IKG); ub
= huge(
0_IKG)
/ 2_IKG
179lb
= .false.; ub
= .true.
184lb
= .false.; ub
= .true.
189lb
= .false.; ub
= .true.
194lb
= .false.; ub
= .true.
199lb
= .false.; ub
= .true.
204lb
= .false.; ub
= .true.
209lb
= .false.; ub
= .true.
214lb
= .false.; ub
= .true.
219lb
= .false.; ub
= .true.
224lb
= .false.; ub
= .true.
230lb
= (
-1.,
+1.); ub
= (
1.,
+2.)
233(
-1.00000000,
+1.00000000), (
-0.999055266,
+1.07844162), (
+1.00000000,
+2.00000000)
235lb
= (
-1.,
+1.); ub
= (
1.,
+2.)
238(
-1.00000000,
+1.00000000), (
+0.248419881,
+1.79499793), (
+1.00000000,
+2.00000000)
240lb
= (
-1.,
+1.); ub
= (
1.,
+2.)
243(
-1.00000000,
+1.00000000), (
-0.739773512E-1,
+1.55295813), (
+1.00000000,
+2.00000000)
245lb
= (
-1.,
+1.); ub
= (
1.,
+2.)
248(
-1.00000000,
+1.00000000), (
+0.474034548,
+1.93165231), (
+1.00000000,
+2.00000000)
250lb
= (
-1.,
+1.); ub
= (
1.,
+2.)
253(
-1.00000000,
+1.00000000), (
-0.558471322,
+1.36327362), (
+1.00000000,
+2.00000000)
256lb
= 2._RKG; ub
= lb
+ spacing(lb)
258[lb, rand, ub],
format = getFormat(width
= 42_IK, ndigit
= 35_IK)
259 2.0000000000000000000000000000000000 ,
2.0000000000000000000000000000000000 ,
2.0000000000000000000000000000000004
262[lb, rand, ub],
format = getFormat(width
= 42_IK, ndigit
= 35_IK)
263 2.0000000000000000000000000000000000 ,
2.0000000000000000000000000000000000 ,
2.0000000000000000000000000000000004
266[lb, rand, ub],
format = getFormat(width
= 42_IK, ndigit
= 35_IK)
267 2.0000000000000000000000000000000000 ,
2.0000000000000000000000000000000000 ,
2.0000000000000000000000000000000004
270[lb, rand, ub],
format = getFormat(width
= 42_IK, ndigit
= 35_IK)
271 2.0000000000000000000000000000000000 ,
2.0000000000000000000000000000000000 ,
2.0000000000000000000000000000000004
274[lb, rand, ub],
format = getFormat(width
= 42_IK, ndigit
= 35_IK)
275 2.0000000000000000000000000000000000 ,
2.0000000000000000000000000000000000 ,
2.0000000000000000000000000000000004
281-3.00000000,
+0.117311954,
+5.00000000
286-3.00000000,
-1.32647085,
+5.00000000
291-3.00000000,
+4.69911718,
+5.00000000
296-3.00000000,
-1.89634132,
+5.00000000
301-3.00000000,
-0.843421936,
+5.00000000
Postprocessing of the example output ⛓
3import matplotlib.pyplot
as plt
16xlab = {
"CK" :
"Uniform Random Value ( real/imaginary components )"
17 ,
"IK" :
"Uniform Random Value ( integer-valued )"
18 ,
"RK" :
"Uniform Random Value ( real-valued )"
25for kind
in [
"IK",
"CK",
"RK"]:
27 pattern =
"*." + kind +
".txt"
28 fileList = glob.glob(pattern)
29 if len(fileList) == 1:
31 df = pd.read_csv(fileList[0], delimiter =
",", header =
None)
33 fig = plt.figure(figsize = 1.25 * np.array([6.4, 4.8]), dpi = 200)
36 for j
in range(len(df.values[0,:])):
38 plt.hist( df.values[:,j]
39 , histtype =
"stepfilled"
44 plt.hist( df.values[:,j]
45 , histtype =
"stepfilled"
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 {} Uniform random values".format(len(df.values[:, 0])), fontsize = 17)
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")
62 plt.savefig(fileList[0].replace(
".txt",
".png"))
64 elif len(fileList) > 1:
66 sys.exit(
"Ambiguous file list exists.")
Visualization of the example output ⛓
- Test:
- test_pm_distUnif
- Todo:
- High Priority: An illustration of the distribution of the probability of individual bits being
0
or 1
in the mantissa of real
-valued random numbers and integer
random numbers must be added to the example.
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.
-
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.
-
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.
- Copyright
- Computational Data Science Lab
- Author:
- Fatemeh Bagheri, Wednesday 12:20 AM, October 13, 2021, Dallas, TX
Definition at line 3362 of file pm_distUnif.F90.