Roll

is a monadic scalar function which returns random or pseudo-random numbers. The name Roll comes from the analogy of rolling dice. Each scalar in the argument must be a positive integer,, and Roll chooses one of the first   indices. Some dialects allow  to be zero, in which case Roll chooses a floating-point number between 0 and 1. Roll shares its glyph with the other random-result function, Deal.

Description
Each scalar in the argument to Roll must be a positive integer.

The result of Roll on each number  is either
 * One of the elements of  chosen uniformly at random; or
 * A real number between 0 and 1 chosen uniformly at random, if  is 0 and the dialect has this extension.

Because Iota depends on index origin, Roll depends on index origin unless every number in the argument is 0.

The choices made by Roll do not have to be truly random: they may be pseudorandom (generated by a deterministic but difficult to predict algorithm) or taken from the operating system. They way random numbers are generated is controlled by the random link. Traditionally, APL uses the Lehmer random number generator, but Dyalog APL defaults to the allow choosing a different random number generator and defaults to the Mersenne Twister.

Lessons

 * APL Cultivation


 * Jupyter Notebook (Run on TryAPL)

Documentation

 * Dyalog


 * APLX


 * J Dictionary, J NuVoc