menu

Generating random numbers

To introduce stochastic events, you can generate pseuorandom numbers in Cacatoo. For this, Cacatoo relies on the Mersenne-Twister library. The random number generator (rng) is part of the simulation object, and below you can read how to use it.

Using the RNG:

sim.rng.genrand_real1() // Generates a random real number on the [0,1] interval
sim.rng.genrand_real2() // Generates a random real number on the [0,1) interval
sim.rng.genrand_real3() // Generates a random real number on the (0,1) interval
sim.rng.genrand_int(min,max) // Generates a random integer between [min,max] interval
sim.rng.random() // (same as genrand_real1, but a nicer name)