![]() |
Octopus
|
Data Types | |
| interface | hash_combine_ids |
| interface | quickrnd |
| interface | splitmix64_mixer |
| interface | to_double_open01 |
Functions/Subroutines | |
| integer(int64) function | xorshift64 (x) |
| xorshift64 pseudorandom number generator More... | |
| real(real64) function | to_double (x) |
| Generating uniform doubles in the unit interval. More... | |
| subroutine | dquickrnd_single (iseed, rnd) |
| subroutine | dquickrnd_array (iseed, nn, rnd) |
| subroutine | zquickrnd_array (iseed, nn, rnd) |
| subroutine, public | shiftseed (iseed, n) |
| integer(int64) function | random_integer_in_range (x_min, x_max, seed) |
| Generate a random int64 in the range \( [x_{min}, x_{max}] \). More... | |
| subroutine, public | fisher_yates_shuffle (m, n, seed, values) |
Return m random numbers from a range of \([1, n]\) with no replacement. More... | |
| real(real64) function, public | u01_from_ids (ids) |
Mix an integer array of ids to give a random number in the range U(0,1), which is deterministic w.r.t. input ids. More... | |
Variables | |
| integer(int64), parameter, public | splitmix64_123 = int(Z'B4DC9BD462DE412B', int64) |
| integer(int64), parameter, public | splitmix64_321 = int(Z'E95F1C4EFCF85DEE', int64) |
|
private |
xorshift64 pseudorandom number generator
Marsaglia, G. (2003). Xorshift RNGs. Journal of Statistical Software, 8(14). https:
| [in,out] | x | PRNG state |
Definition at line 174 of file quickrnd.F90.
|
private |
Generating uniform doubles in the unit interval.
We consider x to be an unsigned 64-bit integer which can represent the range \([0,2^{64})\). First we shift x right by 11 places which puts it in the range \([0,2^{53})\). Then we convert it to a double and multiply by \(2^{-53}\) which puts the result in the range \([0,1)\).
https:
| [in] | x | 64-bit integer |
Definition at line 195 of file quickrnd.F90.
|
private |
Definition at line 205 of file quickrnd.F90.
|
private |
Definition at line 217 of file quickrnd.F90.
|
private |
Definition at line 236 of file quickrnd.F90.
| subroutine, public quickrnd_oct_m::shiftseed | ( | integer(int64), intent(inout) | iseed, |
| integer(int64), intent(in) | n | ||
| ) |
Definition at line 259 of file quickrnd.F90.
|
private |
Generate a random int64 in the range \( [x_{min}, x_{max}] \).
The function includes bias, where the per-value probability can differ from perfect uniform by ~ range / 2^63, where range = x_max - x_min + 1. This is the standard modulo-mapping bound when taking MOD(seed, range) with a positive range and a 64-bit seed.
Examples (relative worst-case bias):
| [in] | x_max | range [x_min, x_max] |
| [in,out] | seed | integer seed |
Definition at line 287 of file quickrnd.F90.
| subroutine, public quickrnd_oct_m::fisher_yates_shuffle | ( | integer(int32), intent(in) | m, |
| integer(int64), intent(in) | n, | ||
| integer(int64), intent(inout) | seed, | ||
| integer(int64), dimension(:), intent(out) | values | ||
| ) |
Return m random numbers from a range of \([1, n]\) with no replacement.
The simple implementation is O(n) in memory. More details can be found on the [wikipedia page](https:
| [in] | m | Subset of random numbers to sample |
| [in] | n | Max random integer |
| [in,out] | seed | Initial seed |
Definition at line 308 of file quickrnd.F90.
| real(real64) function, public quickrnd_oct_m::u01_from_ids | ( | integer(int64), dimension(:), intent(in) | ids | ) |
Mix an integer array of ids to give a random number in the range U(0,1), which is deterministic w.r.t. input ids.
The algorithm is defined by these steps:
| [in] | ids | RNG invariant to the order of the ids |
Definition at line 349 of file quickrnd.F90.
| integer(int64), parameter, public quickrnd_oct_m::splitmix64_123 = int(Z'B4DC9BD462DE412B', int64) |
Definition at line 138 of file quickrnd.F90.
| integer(int64), parameter, public quickrnd_oct_m::splitmix64_321 = int(Z'E95F1C4EFCF85DEE', int64) |
Definition at line 138 of file quickrnd.F90.