Skip to content

rand

builtin · libnexusinterp/corefcn/rand-proprietary.cc

: R = rand ()
: R = rand (n)
: R = rand (m, n, …)
: R = rand ([m n …])
: R = rand (…, "single")
: R = rand (…, "like", p)
: s = rand ("state")
: rand ("state", s)
: rand ("seed", s)

Uniformly distributed pseudorandom numbers on the open interval (0,1).

With no size arguments one value is returned; a single size argument n gives an n-by-n matrix, and several sizes (or a size vector) give an array of that shape. Negative sizes count as zero. The class is "double" unless "single" is requested.

rand ("state") returns the 35-element v5 uniform state as a column of doubles; rand ("state", s) seeds or restores that generator. rand ("seed", s) selects the v4 Park-Miller generator. rand ("twister") returns the 625-element Mersenne Twister state as a column of uint32.