Skip to content

Commit

Permalink
fix #41346, update Random docs for Xoshiro256++ (#41353)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson authored Jun 29, 2021
1 parent 161e384 commit 7c566b1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
3 changes: 1 addition & 2 deletions doc/src/manual/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ As in the example above, we recommend following some simple conventions when wri
Calling `rand` and other RNG-related functions should be avoided in doctests since they will not
produce consistent outputs during different Julia sessions. If you would like to show some random
number generation related functionality, one option is to explicitly construct and seed your own
[`MersenneTwister`](@ref) (or other pseudorandom number generator) and pass it to the functions you are
doctesting.
RNG object (see [`Random`](@ref Random-Numbers)) and pass it to the functions you are doctesting.

Operating system word size ([`Int32`](@ref) or [`Int64`](@ref)) as well as path separator differences
(`/` or `\`) will also affect the reproducibility of some doctests.
Expand Down
32 changes: 18 additions & 14 deletions stdlib/Random/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@
DocTestSetup = :(using Random)
```

Random number generation in Julia uses the [Mersenne Twister library](http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/#dSFMT)
via `MersenneTwister` objects. Julia has a global RNG, which is used by default. Other RNG types
can be plugged in by inheriting the `AbstractRNG` type; they can then be used to have multiple
streams of random numbers. Besides `MersenneTwister`, Julia also provides the `RandomDevice` RNG
type, which is a wrapper over the OS provided entropy.

Most functions related to random generation accept an optional `AbstractRNG` object as first argument,
which defaults to the global one if not provided. Moreover, some of them accept optionally
dimension specifications `dims...` (which can be given as a tuple) to generate arrays of random
values. In a multi-threaded program, you should generally use different RNG objects from different threads
in order to be thread-safe. However, the default global RNG is thread-safe as of Julia 1.3 (because
it internally corresponds to a per-thread RNG).

A `MersenneTwister` or `RandomDevice` RNG can generate uniformly random numbers of the following types:
Random number generation in Julia uses the [Xoshiro256++](https://prng.di.unimi.it/) algorithm
by default, with per-`Task` state.
Other RNG types can be plugged in by inheriting the `AbstractRNG` type; they can then be used to
obtain multiple streams of random numbers.
Besides the default `TaskLocalRNG` type, the `Random` package also provides `MersenneTwister`,
`RandomDevice` (which exposes OS-provided entropy), and `Xoshiro` (for explicitly-managed
Xoshiro256++ streams).

Most functions related to random generation accept an optional `AbstractRNG` object as first argument.
Some also accept dimension specifications `dims...` (which can also be given as a tuple) to generate
arrays of random values.
In a multi-threaded program, you should generally use different RNG objects from different threads
or tasks in order to be thread-safe. However, the default RNG is thread-safe as of Julia 1.3
(using a per-thread RNG up to version 1.6, and per-task thereafter).

The provided RNGs can generate uniform random numbers of the following types:
[`Float16`](@ref), [`Float32`](@ref), [`Float64`](@ref), [`BigFloat`](@ref), [`Bool`](@ref),
[`Int8`](@ref), [`UInt8`](@ref), [`Int16`](@ref), [`UInt16`](@ref), [`Int32`](@ref),
[`UInt32`](@ref), [`Int64`](@ref), [`UInt64`](@ref), [`Int128`](@ref), [`UInt128`](@ref),
Expand Down Expand Up @@ -67,6 +69,8 @@ Random.shuffle!
```@docs
Random.seed!
Random.AbstractRNG
Random.TaskLocalRNG
Random.Xoshiro
Random.MersenneTwister
Random.RandomDevice
```
Expand Down

0 comments on commit 7c566b1

Please sign in to comment.