Skip to content

RandomNumbers

Index

Common Functions

Public

# RandomNumbers.RandomNumbersModule.

Main module for RandomNumbers.jl – a random number generator package for Julia Language.

This module exports two types and four submodules:

source

# RandomNumbers.AbstractRNGType.

AbstractRNG{T} <: Random.AbstractRNG

The abstract type of Random Number Generators. T indicates the original output type of a RNG.

source

# RandomNumbers.WrappedRNGType.

WrappedRNG{R, T1, T2} <: AbstractRNG{T2}
WrappedRNG(base_rng, T2)
WrappedRNG(R, T2, args...)

Wrap a RNG which originally provides output in T1 into a RNG that provides output in T2.

Examples

julia> r = Xorshifts.Xorshift128Star(123);

julia> RandomNumbers.output_type(r)
UInt64

julia> r1 = WrappedRNG(r, UInt32);

julia> RandomNumbers.output_type(r1)
UInt32

julia> r2 = WrappedRNG(Xorshifts.Xorshift128Star, UInt32, 123);

julia> RandomNumbers.output_type(r2)
UInt32

julia> @Test.test rand(r1, UInt32, 3) == rand(r2, UInt32, 3)
Test Passed

source

# RandomNumbers.output_typeMethod.

Get the original output type of a RNG.

source

# RandomNumbers.seed_typeMethod.

Get the default seed type of a RNG.

source

Internal

# RandomNumbers.gen_seedMethod.

gen_seed(T[, n])

Generate a tuple of n truly random numbers in type T. If n is missing, return only one number. The "truly" random numbers are provided by the random device of system. See Random.RandomDevice.

Examples

julia> RandomNumbers.gen_seed(UInt64, 2)  # The output should probably be different on different computers.
(0x26aa3fe5e306f725,0x7b9dc3c227d8acc9)

julia> RandomNumbers.gen_seed(UInt32)
0x9ba60fdc

source