API
Backends
PythonRNGs.AbstractPythonRNG — Type
AbstractPythonRNG <: Random.AbstractRNGSupertype of random number generators that delegate sampling to a Python object through PythonCall.jl.
Concrete subtypes:
PythonRandom: backed by Python's standardrandom.Random.NumPyRandomDefaultRNG: backed bynumpy.random.default_rng.NumPyRandom: backed by the legacynumpy.random.RandomState.
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.
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.
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.
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.
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
PythonRNGs.NotSupportedError — Type
NotSupportedError(msg)Thrown by PythonRandom, NumPyRandomDefaultRNG, or NumPyRandom when a requested draw has no equivalent in the wrapped Python backend.