Skip to content

Commit 7c566b1

Browse files
authored
fix #41346, update Random docs for Xoshiro256++ (#41353)
1 parent 161e384 commit 7c566b1

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

doc/src/manual/documentation.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ As in the example above, we recommend following some simple conventions when wri
128128
Calling `rand` and other RNG-related functions should be avoided in doctests since they will not
129129
produce consistent outputs during different Julia sessions. If you would like to show some random
130130
number generation related functionality, one option is to explicitly construct and seed your own
131-
[`MersenneTwister`](@ref) (or other pseudorandom number generator) and pass it to the functions you are
132-
doctesting.
131+
RNG object (see [`Random`](@ref Random-Numbers)) and pass it to the functions you are doctesting.
133132

134133
Operating system word size ([`Int32`](@ref) or [`Int64`](@ref)) as well as path separator differences
135134
(`/` or `\`) will also affect the reproducibility of some doctests.

stdlib/Random/docs/src/index.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@
44
DocTestSetup = :(using Random)
55
```
66

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:
2123
[`Float16`](@ref), [`Float32`](@ref), [`Float64`](@ref), [`BigFloat`](@ref), [`Bool`](@ref),
2224
[`Int8`](@ref), [`UInt8`](@ref), [`Int16`](@ref), [`UInt16`](@ref), [`Int32`](@ref),
2325
[`UInt32`](@ref), [`Int64`](@ref), [`UInt64`](@ref), [`Int128`](@ref), [`UInt128`](@ref),
@@ -67,6 +69,8 @@ Random.shuffle!
6769
```@docs
6870
Random.seed!
6971
Random.AbstractRNG
72+
Random.TaskLocalRNG
73+
Random.Xoshiro
7074
Random.MersenneTwister
7175
Random.RandomDevice
7276
```

0 commit comments

Comments
 (0)