frost.math

Interface Random

Provices methods for calculating pseudorandom numbers. Implementations of Random generally need only implement the int64() method, with all other methods having default implementations.

Source Code:
View Source

Class Method Summary

default():Random
Provides an automatically-seeded implementation of the default random number generator.
Inherited Fields:

Instance Method Summary

bit():Bit
Returns a random Bit (either true or false with 50% odds of each).
int32():Int32
Returns a random number between Int32.MIN and Int32.MAX, inclusive.
int64():Int64
Returns a random number between Int64.MIN and Int64.MAX, inclusive.
int(n:Int):Int
Returns a random Int between 0 and n - 1, inclusive.
real32():Real32
Returns a random, uniformly distributed Real32 between 0 (inclusive) and 1 (exclusive).
real64():Real64
Returns a random, uniformly distributed Real64 between 0 (inclusive) and 1 (exclusive).

Class Methods

@class
function default ():Random

Provides an automatically-seeded implementation of the default random number generator. The precise algorithm chosen may be system- and version-dependent and is not guaranteed to remain consistent over time. Calling Random.default() multiple times within a single run of a program may return instances which all return the same sequence; generally, you should only call this method once per run of a given program.

Instance Methods

@default
method bit ():Bit

Returns a random Bit (either true or false with 50% odds of each).

Returns:
a random bit
@default
method int32 ():Int32

Returns a random number between Int32.MIN and Int32.MAX, inclusive.

method int64 ():Int64

Returns a random number between Int64.MIN and Int64.MAX, inclusive.

@default
@pre(n >= 1)
@post(@return >= 0 & @return < n)
method int (n:Int
):Int

Returns a random Int between 0 and n - 1, inclusive. For example, int(6) is equivalent to rolling a standard six-sided die, with return value between 0 and 5.

Parameters:
n - the range of possible values to generate
Returns:
a random number between 0 and n - 1
@default
@post(@return >= 0 & @return < 1)
method real32 ():Real32

Returns a random, uniformly distributed Real32 between 0 (inclusive) and 1 (exclusive).

Returns:
a random Real32
@default
@post(@return >= 0 & @return < 1)
method real64 ():Real64

Returns a random, uniformly distributed Real64 between 0 (inclusive) and 1 (exclusive).

Returns:
a random Real64