next up previous contents index
Next: 20.2 Random Variables Up: 20.1 Random Number Generation Previous: Seeding the random OTcl support

The RNG class can be accessed from OTcl. For example, a new RNG is created and seeded with:

set rng [new RNG]
$rng seed 0 # seeds the RNG heuristically;
$rng seed n # seeds the RNG with value n;
$rng next-random #  return the next random number;
$rng uniform a b # return a number uniformly distributed on [a, b];
$rng integer k # return an integer uniformly distributed on [0, (k-1)];
$rng exponential # return a number from an exponential distribution with average 1.;

Currently there is no way to select predefined seeds from OTcl.