Randomizes the column order of an array.
COLRANDOMIZE(s, idx)
(r, k) = COLRANDOMIZE(s, idx)
s |
- |
A series or array, the input to randomize. |
idx |
- |
An optional series, the indices of a previous randomize used to unscramble the input. |
A series or array, the randomly column reordered array.
(r, k) = COLRANDOMIZE(s) returns the randomly column reordered array and the indices used to perform the reordering. The returned indices can be used to restore the result to the original order.
W1: 1..5
W2: colrandomize(w1)
W1 contains the series {1, 2, 3, 4, 5}.
W2 contains the series {1, 2, 3, 4, 5}. For a single column, COLRANDOMIZE does not alter the input.
W1: ravel(1..12, 4);table
W2: (r, k) = colrandomize(w1);r
W3: colrandomize(w2, k)
W1 == {{1, 5, 9},
{2, 6, 10},
{3, 7, 11},
{4, 8, 12}}
W2 == {{5, 1, 9},
{6, 2, 10},
{7, 3, 11},
{8, 4, 12}}
The actual result in W2 may differ.
W3 == {{1, 5, 9},
{2, 6, 10},
{3, 7, 11},
{4, 8, 12}}
The columns of W1 are randomly reordered in W2 and restored in W3.
COLRANDOMIZE randomly reorders the columns of a series or array. For a single column input, the original series is returned.
See ROWRANDOMIZE to reorder the rows of an array.
See RANDOMIZE to arbitrarily reorder an array.
See RANDSAMPLE to return K random samples from a population.