random Reference

Generate a random number

random

Description

Outputs random numbers within the range between 0 and 1 less than the argument specified.

Examples

Generate random events, or make decisions based on probability

Arguments

range [int]

Optional

Sets an initial limit to the random output. The output will always be between 0 and one less than this maximum limit. If there is no argument, the limit is initially set to 1, which causes random to output 0 whenever it receives a bang.

seed [int]

Optional

A second argument is used to set a "seed" value for the random generator. If no argument is specified, the time value will be used to initialize the seed.

Attributes

Common Box Attributes

Messages

bang

In left inlet: Sends out a randomly generated number between 0 and one less than its maximum limit.

seed

Arguments

seed-value [int]
In left inlet: The word seed, followed by a number, provides a "seed" value for the random generator, which causes a specific (reproducible) sequence of pseudo-random numbers to occur. The number 0 uses the time elapsed since system startup (an unpredictable value) as the seed, ensuring an unpredictable sequence of numbers. This unpredictable seed is used by default when the random object is created.

Output

int

When a bang is received in the left inlet, random generates a random number between 0 and one less than its maximum limit.

See Also

Name Description
decide
drunk
urn
Max Basic Tutorial 10: Random Drawing Max Basic Tutorial 10: Random Drawing