std-random


Synopsis

(std-random <num>)

Description

Pseudo random generator.

Returns any number lower than num, with the same numerical type as num.

If the argument is nil, 1.0 is assumed.

Example

(std-random 5) => 0 - 4

(std-random 1.0) => 0.0 - 0.999...

To initialize the random generator (set a random seed or change the used method) use std-make-random-state but this it is only required if you want a reproducible random sequence or a better quality.

Arguments

num: integer or real or nil.

Return Value

Returns a number lower than num, with the same numerical type as num.

Side Effects

Changes and uses the global variable *random-seed*.

Module

(std-require 'STDMATH) or (std-require 'RANDOM)

Defined in STDMATH and in RANDOM