Type:
Class
Constants:
DEFAULT : rand_default

Random provides an interface to Ruby's pseudo-random number generator, or PRNG. The PRNG produces a deterministic sequence of bits which approximate true randomness. The sequence may be represented by integers, floats, or binary strings.

The generator may be initialized with either a system-generated or user-supplied seed value by using ::srand.

The class method #rand provides the base functionality of Kernel#rand along with better handling of floating point values. These are both interfaces to Random::DEFAULT, the Ruby system PRNG.

::new will create a new PRNG with a state independent of Random::DEFAULT, allowing multiple generators with different seed values or sequence positions to exist simultaneously. Random objects can be marshaled, allowing sequences to be saved and resumed.

PRNGs are currently implemented as a modified Mersenne Twister with a period of 2**19937-1.

new_seed

Random.new_seed â integer Class Public methods Returns an arbitrary seed value

2015-05-01 00:14:53
srand

srand(number = Random.new_seed) â old_seed Class Public methods Seeds the system

2015-05-01 00:19:16
rand 2

prng.rand â floatprng.rand(max) â number Instance Public methods When

2015-05-01 00:29:28
seed

prng.seed â integer Instance Public methods Returns the seed value used to

2015-05-01 00:35:43
==

prng1 == prng2 â true or false Instance Public methods Returns true if the

2015-05-01 00:22:46
rand

Random.rand â floatRandom.rand(max) â number Class Public methods Alias

2015-05-01 00:17:46
new

Random.new(seed = Random.new_seed) â prng Class Public methods Creates a new

2015-05-01 00:08:20
bytes

prng.bytes(size) â a_string Instance Public methods Returns a random binary

2015-05-01 00:24:13