![]() |
Octopus
|
Data Types | |
| interface | quickrnd |
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... | |
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 148 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 169 of file quickrnd.F90.
|
private |
Definition at line 179 of file quickrnd.F90.
|
private |
Definition at line 191 of file quickrnd.F90.
|
private |
Definition at line 210 of file quickrnd.F90.
| subroutine, public quickrnd_oct_m::shiftseed | ( | integer(int64), intent(inout) | iseed, |
| integer(int64), intent(in) | n | ||
| ) |
Definition at line 233 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 261 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 282 of file quickrnd.F90.
| integer(int64), parameter, public quickrnd_oct_m::splitmix64_123 = int(Z'B4DC9BD462DE412B', int64) |
Definition at line 134 of file quickrnd.F90.
| integer(int64), parameter, public quickrnd_oct_m::splitmix64_321 = int(Z'E95F1C4EFCF85DEE', int64) |
Definition at line 134 of file quickrnd.F90.