|
4 | 4 | DocTestSetup = :(using Random)
|
5 | 5 | ```
|
6 | 6 |
|
7 |
| -Random number generation in Julia uses the [Mersenne Twister library](http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/#dSFMT) |
8 |
| -via `MersenneTwister` objects. Julia has a global RNG, which is used by default. Other RNG types |
9 |
| -can be plugged in by inheriting the `AbstractRNG` type; they can then be used to have multiple |
10 |
| -streams of random numbers. Besides `MersenneTwister`, Julia also provides the `RandomDevice` RNG |
11 |
| -type, which is a wrapper over the OS provided entropy. |
12 |
| - |
13 |
| -Most functions related to random generation accept an optional `AbstractRNG` object as first argument, |
14 |
| -which defaults to the global one if not provided. Moreover, some of them accept optionally |
15 |
| -dimension specifications `dims...` (which can be given as a tuple) to generate arrays of random |
16 |
| -values. In a multi-threaded program, you should generally use different RNG objects from different threads |
17 |
| -in order to be thread-safe. However, the default global RNG is thread-safe as of Julia 1.3 (because |
18 |
| -it internally corresponds to a per-thread RNG). |
19 |
| - |
20 |
| -A `MersenneTwister` or `RandomDevice` RNG can generate uniformly random numbers of the following types: |
| 7 | +Random number generation in Julia uses the [Xoshiro256++](https://prng.di.unimi.it/) algorithm |
| 8 | +by default, with per-`Task` state. |
| 9 | +Other RNG types can be plugged in by inheriting the `AbstractRNG` type; they can then be used to |
| 10 | +obtain multiple streams of random numbers. |
| 11 | +Besides the default `TaskLocalRNG` type, the `Random` package also provides `MersenneTwister`, |
| 12 | +`RandomDevice` (which exposes OS-provided entropy), and `Xoshiro` (for explicitly-managed |
| 13 | +Xoshiro256++ streams). |
| 14 | + |
| 15 | +Most functions related to random generation accept an optional `AbstractRNG` object as first argument. |
| 16 | +Some also accept dimension specifications `dims...` (which can also be given as a tuple) to generate |
| 17 | +arrays of random values. |
| 18 | +In a multi-threaded program, you should generally use different RNG objects from different threads |
| 19 | +or tasks in order to be thread-safe. However, the default RNG is thread-safe as of Julia 1.3 |
| 20 | +(using a per-thread RNG up to version 1.6, and per-task thereafter). |
| 21 | + |
| 22 | +The provided RNGs can generate uniform random numbers of the following types: |
21 | 23 | [`Float16`](@ref), [`Float32`](@ref), [`Float64`](@ref), [`BigFloat`](@ref), [`Bool`](@ref),
|
22 | 24 | [`Int8`](@ref), [`UInt8`](@ref), [`Int16`](@ref), [`UInt16`](@ref), [`Int32`](@ref),
|
23 | 25 | [`UInt32`](@ref), [`Int64`](@ref), [`UInt64`](@ref), [`Int128`](@ref), [`UInt128`](@ref),
|
@@ -67,6 +69,8 @@ Random.shuffle!
|
67 | 69 | ```@docs
|
68 | 70 | Random.seed!
|
69 | 71 | Random.AbstractRNG
|
| 72 | +Random.TaskLocalRNG |
| 73 | +Random.Xoshiro |
70 | 74 | Random.MersenneTwister
|
71 | 75 | Random.RandomDevice
|
72 | 76 | ```
|
|
0 commit comments