Shuffle


What's new in Analytica 4.0? >

Function Shuffle(a , i)

Shuffle returns a random reordering (permutation) of the values in array a over index i. If you omit i, by default it shuffles over Run -- i.e. it shuffles a random sample. You can use it generate an independent random sample from an existing probability distribution, a.

Independent Shuffles

If a contains extra dimensions, or if you include the Over parameter, e.g.:

Shuffle(a,I,Over:J)

then the elements are shuffled independently over those extra dimensions.

If you want to shuffle the slices of a multidimensional array over index i, without shuffling the values within each slice, use this method:

A[@I = Shuffle(@I,I)]

This shuffles A over index I, but does not shuffle each slice of A for each value of I.

Examples

To generate a random permutation of the numbers 1..100:

 Index I:=1..100 do Shuffle(I,I)
Comments


You are not allowed to post comments.