random Module

module provides an interface to call random_numbers and various other random distributions======= !!This module defines a set of functions that return random numbers in different distributions. !!- ran2. Returns a single float uniformly in the range [0, 1) !!- ranu. Return a single float uniformly in the range [a, b) !!- randint. Returns a single integer uniformly in the range [a, b) !!- rang. Returns a single float from a Gaussian distribution with mean avg and std sigma. !!- init_rng. Seeds the internal random number generator with a reproducible seed.



Derived Types

type, public ::  seq

Sequence type for quasi-monte carlo

Components

Type Visibility Attributes Name Initial
integer, public :: base

Base from which to calculate radical inverse from.

integer, public :: index

Current index to get value for.

Type-Bound Procedures

procedure, public :: next

Functions

private function next(this) result(res)

Arguments

Type IntentOptional Attributes Name
class(seq) :: this

Return Value real(kind=wp)

public function ran2() result(res)

wrapper for call random number

Arguments

None

Return Value real(kind=wp)

public function randint(a, b)

sample a random integer between [a, b]

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: a

lower bound

integer, intent(in) :: b

higher bound

Return Value integer

public function ranu(a, b) result(res)

uniformly sample in range[a, b)

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: a

lower bound

real(kind=wp), intent(in) :: b

upper bound

Return Value real(kind=wp)


Subroutines

public subroutine init_rng(input_seed, fwd)

initiate RNG state with reproducible state

Arguments

Type IntentOptional Attributes Name
integer, intent(in), optional :: input_seed(:)

input seed

logical, intent(in), optional :: fwd

boolean that if True runs the generator for 100 steps before returning

public subroutine rang(x, y, avg, sigma)

sample a 2D Guassian distribution

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(out) :: x

first value to return

real(kind=wp), intent(out) :: y

2nd value to return

real(kind=wp), intent(in) :: avg

mean of the gaussian to sample from

real(kind=wp), intent(in) :: sigma

of the guassian to sample from.