Prng Derived Type

type, public :: Prng

Class that generates pseudo random numbers. See Prng_Class for more information on how to use this class.



Components

TypeVisibility AttributesNameInitial
integer(kind=i64), public :: seed(0:15) =0
integer(kind=i32), public :: ptr
logical, public :: big

Constructor

public interface Prng

Overloaded Initializer for a Prng - Pseudo random number generator. Thread safe, xorshift1024* or xorshift128+ generator than can draw from different distributions. See Prng_Class for more information on how to use this class.

  • private function initWithSetseed_Prng(seed, big) result(this)

    Arguments

    Type IntentOptional AttributesName
    integer(kind=i64), intent(in) :: seed(:)

    Fixed seeds of 64 bit integers. If big == true, must be length 16 else must be length 2.

    logical, intent(in), optional :: big

    Use the high period xorshift1024* (true) or xorshift128+ (false). Default is false.

    Return Value type(Prng)

    Prng Class

  • private function initWithRandomSeed_Prng(big, display) result(this)

    Arguments

    Type IntentOptional AttributesName
    logical, intent(in), optional :: big

    Use the high period xorshift1024* (true) or xorshift128+ (false). Default is false.

    logical, intent(in), optional :: display

    Display the randomly generated seed to the screen for reproducibility

    Return Value type(Prng)

    Prng Class


Type-Bound Procedures

procedure, public :: jump => jump_Prng

Jumps the Prng by \(2^{64}\) numbers if the Prng was instantiated with big = .false. or \(2^{512}\) if big = .true. This allows the Prng to be used correctly in parallel on multiple threads for OpenMP, or ranks for MPI.

  • private subroutine jump_Prng(this, nJumps)

    Arguments

    Type IntentOptional AttributesName
    class(Prng), intent(inout) :: this

    Prng Class

    integer(kind=i32) :: nJumps

    Number of times to skip \(2^{64}\) numbers if the Prng was initialized with big = .false. or $2^{512}$ numbers if big was .true.

generic, public :: rngExponential => rngExponential_d1_Prng_, rngExponential_d1D_Prng_, rngExponential_d2D_Prng_, rngExponential_d3D_Prng_

Prng%rngExponential() - Draw from an exponential distribution $$y = \frac{-ln(\tilde{u})}{\lambda}$$ where \(\tilde{u}\) is a sample from a uniform distribution

  • private interface rngExponential_d1_Prng()

    Arguments

    None
  • private interface rngExponential_d1D_Prng()

    Arguments

    None
  • private interface rngExponential_d2D_Prng()

    Arguments

    None
  • private interface rngExponential_d3D_Prng()

    Arguments

    None

generic, public :: rngInteger => rngInteger_i1_Prng_, rngInteger_i1D_Prng_, rngInteger_i2D_Prng_, rngInteger_i3D_Prng_

Prng%rngInteger() - Draw a random integer in the interval \(x_{0} <= \tilde{u} <= x_{1}\) $$y = x_{0} + (\tilde{u} * x_{1})$$ where \(\tilde{u}\) is a sample from a uniform distribution, and integers are generated such that \(x_{0} <= \tilde{u} <= x_{1}\).

  • private interface rngInteger_i1_Prng()

    Arguments

    None
  • private interface rngInteger_i1D_Prng()

    Arguments

    None
  • private interface rngInteger_i2D_Prng()

    Arguments

    None
  • private interface rngInteger_i3D_Prng()

    Arguments

    None

generic, public :: rngNormal => rngNormal_d1_Prng_, rngNormal_d1D_Prng_, rngNormal_d2D_Prng_, rngNormal_d3D_Prng_

Prng%rngNormal() - Draw from a normal distribution.

  • private interface rngNormal_d1_Prng()

    Arguments

    None
  • private interface rngNormal_d1D_Prng()

    Arguments

    None
  • private interface rngNormal_d2D_Prng()

    Arguments

    None
  • private interface rngNormal_d3D_Prng()

    Arguments

    None

generic, public :: rngUniform => rngUniform_d1_Prng_, rngUniform_d1D_Prng_, rngUniform_d2D_Prng_, rngUniform_d3D_Prng_

Prng%rngUniform() - Draw from a uniform distribution Draws uniform random numbers on (0, 1) using either the xorshift1024* or xorshift128+ algorithms.

  • private interface rngUniform_d1_Prng()

    Arguments

    None
  • private interface rngUniform_d1D_Prng()

    Arguments

    None
  • private interface rngUniform_d2D_Prng()

    Arguments

    None
  • private interface rngUniform_d3D_Prng()

    Arguments

    None

generic, public :: rngWeibull => rngWeibull_d1_Prng_, rngWeibull_d1D_Prng_, rngWeibull_d2D_Prng_, rngWeibull_d3D_Prng_

Prng%rngWeibull() - Draw from a Weibull distribution $$y = \left[ \frac{-1}{\lambda} ln(\tilde{u}) \right]^{\frac{1}{k}}$$ where \(\tilde{u}\) is a sample from a uniform distribution and \(\frac{-1}{\lambda} ln(\tilde{u})\) is a draw from an exponential distribution.

  • private interface rngWeibull_d1_Prng()

    Arguments

    None
  • private interface rngWeibull_d1D_Prng()

    Arguments

    None
  • private interface rngWeibull_d2D_Prng()

    Arguments

    None
  • private interface rngWeibull_d3D_Prng()

    Arguments

    None