Difference between revisions of "Shuffle"

m
Line 1: Line 1:
 
[[Category:Distribution Functions]]
 
[[Category:Distribution Functions]]
[[Category:Doc Status D]] <!-- For Lumina use, do not change -->
+
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
 
   
 
   
 
[[What's new in Analytica 4.0?]] >
 
[[What's new in Analytica 4.0?]] >

Revision as of 23:48, 6 March 2008


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, it shuffles over Run. [Since build 4.0.0.48.] 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.