RANDOMIZE

Purpose:

Randomizes the order of the elements of an array.

Syntax:

RANDOMIZE(s, idx)

(r, k) = RANDOMIZE(s, idx)

s

-

A series or array, the input to randomize.

k

-

An optional series, the indices of a previous randomize used to unscramble the input.

Returns:

A series or array, the randomly reordered array.

 

(r, k) = RANDOMIZE(s) returns the randomly reordered array and the indices used to perform the reordering. The returned indices can be used to restore the result to the original order.

Example:

W1: 1..5;tableview

W2: randomize(w1)

 

W1 contains the series {1, 2, 3, 4, 5}.

 

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

Example:

W1: 1..5;tableview

W2: (r, k) = randomize(w1);r

W3: randomize(w2, k)

 

W1 contains the series {1, 2, 3, 4, 5}.

 

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

 

W3 contains the series {1, 2, 3, 4, 5}, the original series.

Example:

W1: ravel(1..12, 4);tableview

W2: (r, k) = randomize(w1);r

W3: randomize(w2, k)

 

W1 == {{1, 5,  9},

       {2, 6, 10},

       {3, 7, 11},

       {4, 8, 12}}

 

W2 == {{12, 4,  8},

       { 9, 7, 10},

       { 2, 3, 11},

       { 5, 1,  6}}

 

The actual result in W2 may differ.

 

W3 == {{1, 5,  9},

       {2, 6, 10},

       {3, 7, 11},

       {4, 8, 12}}

 

The elements of W1 are randomly reordered in W2 and restored in W3.

Remarks:

RANDOMIZE randomly reorders the elements of a series or array. The elements are reordered by row and by column.

 

See ROWRANDOMIZE  to reorder the rows of an array.

 

See COLRANDOMIZE  to reorder the columns of an array.

 

See RANDSAMPLE to return K random samples from a population.

See Also:

COLRANDOMIZE

RANDPERM

RANDSAMPLE

ROWRANDOMIZE