Navigation

Operators and Keywords

Function List:

C++ API

: randperm (n)
: randperm (n, m)

Return a row vector containing a random permutation of 1:n.

If m is supplied, return m unique entries, sampled without replacement from 1:n.

The complexity is O(n) in memory and O(m) in time, unless m < n/5, in which case O(m) memory is used as well. The randomization is performed using rand(). All permutations are equally likely.

See also: perms.

Package: octave