pracma (version 1.9.9)

randperm: Random Permutation

Description

Generates a random permutation.

Usage

randperm(a, k)

Arguments

a
integer or numeric vector of some length n.
k
integer, smaller as a or length(a).

Value

Vector of permuted elements of a or 1:a.

Details

Generates one random permutation of k of the elements a, if a is a vector, or of 1:a if a is a single integer.

See Also

perms

Examples

Run this code
randperm(1:6, 3)
randperm(6, 6)
randperm(11:20, 5)
randperm(seq(2, 10, by=2))

Run the code above in your browser using DataLab