RANDPERM

Purpose:

Randomly permutes the sequence of integers from 1 to n.

Syntax:

RANDPERM(n, k)

n

-

The number of values to permute.

k

-

An optional integer, the number of values to select from the permutation. Must be <= n.

Returns:

A series, the permuted sequence.

Example:

W1: randperm(5)

 

W1 contains the series {2, 5, 3, 4, 1}. The actual result may differ.

Example:

W1: randperm(5, 3)

 

W1 contains the series {4, 1, 2}. The actual result may differ.

Remarks:

RANDPERM(n) randomly permutes the sequence 1..n.

 

RANDPERM(n, k) randomly permutes the sequence 1..n and returns k values from the permutation.

 

The inputs n and k must be non-negative integers.

 

RANDPERM returns an empty series for n == 0 or k == 0.

 

See RANDOMIZE to reorder the elements of an array.

 

See ROWRANDOMIZE to reorder the rows of an array.

 

See COLRANDOMIZE to reorder the columns of an array.

See Also:

COLRANDOMIZE

NCHOOSEK

RANDOMIZE

RANDSAMPLE

ROWRANDOMIZE