This module has been comprised using different sources. The first was a public domain pseudo-random number generator using the xorshift1024* and xorshift128+ methods. See Prng_Class for more details on those methods.
The secound source are the functions inside http://www.netlib.org/random/random.f90. These are used to generate random numbers from distributions other than a uniform distribution.
This module contains subroutines to generate numbers randomly from different distributions. They do so by instantiating a globally available Prng_Class and making calls into its type bound procedures. Since the Prng for these routines is globally available, you should not use it for any random number generation in parallel, whether using OpenMP or MPI! Instead, refer to Prng_Class to see how to use the Prng in a thread safe manner.
Example Usage:
program randomTest use m_random, only: setPRNG, rngInteger, rngUniform, rngNormal, rngExponential, rngrngWeibull implicit none end program
Original Netlib random.f90 Author: Alan Miller
Updated coretran version: Version 2.00, 11 November 2016 Increased precision to double Added seed setters Added overloaded operations for single number, nD arrays
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| type(Prng), | public | :: | globalPrng |
Interfaced to setPrng() Sets the seed of the random number generator with a specified seed
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=i64), | intent(in) | :: | seed(:) | |||
| logical, | intent(in), | optional | :: | big |
Interfaced to setPrng() 'Randomly' sets the seed of the random number generator
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| logical, | intent(in), | optional | :: | big | ||
| logical, | intent(in), | optional | :: | display |
Interfaced with rngExponential
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64) | :: | this | Random number |
|||
| real(kind=r64) | :: | lambda | Inverse scale > 0 |
Interfaced with rngExponential
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64) | :: | this(:) | Random numbers |
|||
| real(kind=r64) | :: | lambda | Inverse scale > 0 |
Interfaced with rngExponential
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64) | :: | this(:,:) | Random numbers |
|||
| real(kind=r64) | :: | lambda | Inverse scale > 0 |
Interfaced with rngExponential
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64) | :: | this(:,:,:) | Random numbers |
|||
| real(kind=r64) | :: | lambda | Inverse scale > 0 |
Generate size(this) random integers starting from imin
Interfaced with rngInteger
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=i32), | intent(inout) | :: | this | |||
| integer(kind=i32), | intent(in) | :: | imin | |||
| integer(kind=i32), | intent(in) | :: | imax |
Interfaced with rngInteger
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=i32), | intent(inout) | :: | this(:) | |||
| integer(kind=i32), | intent(in) | :: | imin | |||
| integer(kind=i32), | intent(in) | :: | imax |
Interfaced with rngInteger
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=i32), | intent(inout) | :: | this(:,:) | |||
| integer(kind=i32), | intent(in) | :: | imin | |||
| integer(kind=i32), | intent(in) | :: | imax |
Interfaced with rngInteger
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=i32), | intent(inout) | :: | this(:,:,:) | |||
| integer(kind=i32), | intent(in) | :: | imin | |||
| integer(kind=i32), | intent(in) | :: | imax |
Interfaced with rngNormal
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this | |||
| real(kind=r64), | intent(in), | optional | :: | mean | ||
| real(kind=r64), | intent(in), | optional | :: | std |
Interfaced with rngNormal
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this(:) | |||
| real(kind=r64), | intent(in), | optional | :: | mean | ||
| real(kind=r64), | intent(in), | optional | :: | std |
Interfaced with rngNormal
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this(:,:) | |||
| real(kind=r64), | intent(in), | optional | :: | mean | ||
| real(kind=r64), | intent(in), | optional | :: | std |
Interfaced with rngNormal
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this(:,:,:) | |||
| real(kind=r64), | intent(in), | optional | :: | mean | ||
| real(kind=r64), | intent(in), | optional | :: | std |
Interfaced with rngUniform
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this | |||
| real(kind=r64), | intent(in), | optional | :: | rmin | ||
| real(kind=r64), | intent(in), | optional | :: | rmax |
Interfaced with rngUniform
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this(:) | |||
| real(kind=r64), | intent(in), | optional | :: | rmin | ||
| real(kind=r64), | intent(in), | optional | :: | rmax |
Interfaced with rngUniform
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this(:,:) | |||
| real(kind=r64), | intent(in), | optional | :: | rmin | ||
| real(kind=r64), | intent(in), | optional | :: | rmax |
Interfaced with rngUniform
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this(:,:,:) | |||
| real(kind=r64), | intent(in), | optional | :: | rmin | ||
| real(kind=r64), | intent(in), | optional | :: | rmax |
Interfaced with rngWeibull
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this | Draw from Weibull distribution |
||
| real(kind=r64), | intent(in) | :: | lambda | Scale of the distribution |
||
| real(kind=r64), | intent(in) | :: | k | Shape of the distribution |
Interfaced with rngWeibull
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this(:) | Draw from Weibull distribution |
||
| real(kind=r64), | intent(in) | :: | lambda | Scale of the distribution |
||
| real(kind=r64), | intent(in) | :: | k | Shape of the distribution |
Interfaced with rngWeibull
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this(:,:) | Draw from Weibull distribution |
||
| real(kind=r64), | intent(in) | :: | lambda | Scale of the distribution |
||
| real(kind=r64), | intent(in) | :: | k | Shape of the distribution |
Interfaced with rngWeibull
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this(:,:,:) | Draw from Weibull distribution |
||
| real(kind=r64), | intent(in) | :: | lambda | Scale of the distribution |
||
| real(kind=r64), | intent(in) | :: | k | Shape of the distribution |
Interfaced to setPrng() Sets the seed of the random number generator with a specified seed
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=i64), | intent(in) | :: | seed(:) | |||
| logical, | intent(in), | optional | :: | big |
Interfaced to setPrng() 'Randomly' sets the seed of the random number generator
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| logical, | intent(in), | optional | :: | big | ||
| logical, | intent(in), | optional | :: | display |
Interfaced with rngExponential
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64) | :: | this | Random number |
|||
| real(kind=r64) | :: | lambda | Inverse scale > 0 |
Interfaced with rngExponential
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64) | :: | this(:) | Random numbers |
|||
| real(kind=r64) | :: | lambda | Inverse scale > 0 |
Interfaced with rngExponential
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64) | :: | this(:,:) | Random numbers |
|||
| real(kind=r64) | :: | lambda | Inverse scale > 0 |
Interfaced with rngExponential
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64) | :: | this(:,:,:) | Random numbers |
|||
| real(kind=r64) | :: | lambda | Inverse scale > 0 |
Interfaced with rngInteger
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=i32), | intent(inout) | :: | this | |||
| integer(kind=i32), | intent(in) | :: | imin | |||
| integer(kind=i32), | intent(in) | :: | imax |
Interfaced with rngInteger
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=i32), | intent(inout) | :: | this(:) | |||
| integer(kind=i32), | intent(in) | :: | imin | |||
| integer(kind=i32), | intent(in) | :: | imax |
Interfaced with rngInteger
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=i32), | intent(inout) | :: | this(:,:) | |||
| integer(kind=i32), | intent(in) | :: | imin | |||
| integer(kind=i32), | intent(in) | :: | imax |
Interfaced with rngInteger
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=i32), | intent(inout) | :: | this(:,:,:) | |||
| integer(kind=i32), | intent(in) | :: | imin | |||
| integer(kind=i32), | intent(in) | :: | imax |
Interfaced with rngNormal
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this | |||
| real(kind=r64), | intent(in), | optional | :: | mean | ||
| real(kind=r64), | intent(in), | optional | :: | std |
Interfaced with rngNormal
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this(:) | |||
| real(kind=r64), | intent(in), | optional | :: | mean | ||
| real(kind=r64), | intent(in), | optional | :: | std |
Interfaced with rngNormal
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this(:,:) | |||
| real(kind=r64), | intent(in), | optional | :: | mean | ||
| real(kind=r64), | intent(in), | optional | :: | std |
Interfaced with rngNormal
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this(:,:,:) | |||
| real(kind=r64), | intent(in), | optional | :: | mean | ||
| real(kind=r64), | intent(in), | optional | :: | std |
Interfaced with rngUniform
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this | |||
| real(kind=r64), | intent(in), | optional | :: | rmin | ||
| real(kind=r64), | intent(in), | optional | :: | rmax |
Interfaced with rngUniform
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this(:) | |||
| real(kind=r64), | intent(in), | optional | :: | rmin | ||
| real(kind=r64), | intent(in), | optional | :: | rmax |
Interfaced with rngUniform
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this(:,:) | |||
| real(kind=r64), | intent(in), | optional | :: | rmin | ||
| real(kind=r64), | intent(in), | optional | :: | rmax |
Interfaced with rngUniform
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this(:,:,:) | |||
| real(kind=r64), | intent(in), | optional | :: | rmin | ||
| real(kind=r64), | intent(in), | optional | :: | rmax |
Interfaced with rngWeibull
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this | Draw from Weibull distribution |
||
| real(kind=r64), | intent(in) | :: | lambda | Scale of the distribution |
||
| real(kind=r64), | intent(in) | :: | k | Shape of the distribution |
Interfaced with rngWeibull
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this(:) | Draw from Weibull distribution |
||
| real(kind=r64), | intent(in) | :: | lambda | Scale of the distribution |
||
| real(kind=r64), | intent(in) | :: | k | Shape of the distribution |
Interfaced with rngWeibull
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this(:,:) | Draw from Weibull distribution |
||
| real(kind=r64), | intent(in) | :: | lambda | Scale of the distribution |
||
| real(kind=r64), | intent(in) | :: | k | Shape of the distribution |
Interfaced with rngWeibull
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=r64), | intent(inout) | :: | this(:,:,:) | Draw from Weibull distribution |
||
| real(kind=r64), | intent(in) | :: | lambda | Scale of the distribution |
||
| real(kind=r64), | intent(in) | :: | k | Shape of the distribution |