API

Backends

PythonRNGs.PythonRandom — Type
PythonRandom([seed])

Create an AbstractRNG that draws random numbers from Python's standard random.Random.

rand(rng, Float64) returns exactly the value that random.Random(seed).random() would return on the same draw. When seed is omitted the generator is seeded from the operating system entropy.

source
PythonRNGs.NumPyRandomDefaultRNG — Type
NumPyRandomDefaultRNG([seed])

Create an AbstractRNG that draws random numbers from NumPy's numpy.random.default_rng.

rand(rng, Float64) returns exactly the value that default_rng(seed).random() would return on the same draw. When seed is omitted the generator is seeded from the operating system entropy.

source
PythonRNGs.NumPyRandom — Type
NumPyRandom([seed])

Create an AbstractRNG that draws random numbers from NumPy's legacy numpy.random.RandomState, i.e. the generator behind np.random.seed(...) and np.random.random(...).

rand(rng, Float64) returns exactly the value that RandomState(seed).random_sample() would return on the same draw. When seed is omitted the generator is seeded from the operating system entropy.

source

Random interface

Random.seed! — Function
Random.seed!(rng::AbstractPythonRNG, [seed])

Reseed rng. With an integer seed, the wrapped Python generator is replaced by a fresh one created from seed, so the stream restarts exactly as it would from a newly constructed generator. When seed is omitted (or nothing), the generator is seeded from operating system entropy.

source
Base.copy — Function
copy(rng::AbstractPythonRNG)

Return an independent copy of rng that starts from the same state, using Python's copy.deepcopy on the wrapped generator.

source

The backends implement rand/rand!, randn/randn!, randperm, and vector shuffle/shuffle!. Normal and uniform arrays use C-order assignment; see Reproducibility for backend mappings and type conversions.

Errors