On this page:
Random
Random
Random.random
Random.state
Random.current
Random  State
8.12

9.4 Random Number Generation🔗ℹ

 import: rhombus/random package: rhombus-prototype

annotation

Random

 

function

fun Random() :: Random

 

function

fun Random(state :: RandomState) :: Random

Annotation and constructors for a pseudo-random number generator (PRNG).

method

method (prng :: Random).random()

  :: Real.in(0 ~exclusive, 1 ~exclusive)

 

method

method (prng :: Random).random(n :: PosInt)

  :: Int.in(0, n ~exclusive)

 

method

method (prng :: Random).random(start :: Int, end :: Int)

  :: Int.in(start, end ~exclusive)

Steps prng to obtain a number.

Using math.random is the same as using Random.current()’s Random.random method.

property

property

| (prng :: Random).state :: RandomState

| (prng :: Random).state := (s :: RandomState)

A property for the state of prng.

context parameter

Parameter.def Random.current :: Random = Random()

A context parameter for the pseudo-random number generator that is used by math.random.

annotation

RandomState

Satisfied by an array of 6 values where the first three values are integers in the range 0 to 4294967086, inclusive, and the last three integers are in the range 0 to 4294944442, inclusive.