Difference between revisions of "Shuffle"

(Ready for UG)
Line 1: Line 1:
 
[[Category:Distribution Functions]]
 
[[Category:Distribution Functions]]
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
+
[[Category:Doc Status M]] <!-- For Lumina use, do not change -->
  
= Function Shuffle =
+
= Function Shuffle(a [, i]) =
 
   
 
   
Shuffle returns a random permutation of the values in an array along a given index.   
+
Shuffle returns a random reordering (permutation) of the values in an array over index i. If you omit i [optional since build 4.0.0.48], it shuffles over Run. You may find this useful if you want to make a random sample from a probability distribution independent.   
  
 
== Declaration ==
 
== Declaration ==
  
  Shuffle(A: Array[I]; I: IndexType = Run)
+
  Shuffle(a: Array[i]; i: IndexType = Run)
  
If A contains dimensions other than I, each slice of those dimensions will be independently shuffled.
+
If a contains dimensions other than i, it independently shuffles each slice over those other dimensions.
  
If you want to shuffle an array along I, but have the same shuffling apply to all slices along other dimensions, you can do this:
+
If you want to shuffle the slices an array over index I, but leaving the values within each slice unshuffled, you can do this:
  
  Slice(A, I, Shuffle(@I,I))
+
  A[@I = Shuffle(@I,I)]
  
To make all slices of an uncertain result independent, use Shuffle(A), or equivalently, Shuffle(A,Run).
+
To make all slices of an uncertain result independent, use Shuffle(A), or equivalently, Shuffle(A,Run).
(note: I is optional as of build 4.0.0.48)
 

Revision as of 19:57, 1 August 2007


Function Shuffle(a [, i])

Shuffle returns a random reordering (permutation) of the values in an array over index i. If you omit i [optional since build 4.0.0.48], it shuffles over Run. You may find this useful if you want to make a random sample from a probability distribution independent.

Declaration

Shuffle(a: Array[i]; i: IndexType = Run)

If a contains dimensions other than i, it independently shuffles each slice over those other dimensions.

If you want to shuffle the slices an array over index I, but leaving the values within each slice unshuffled, you can do this:

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

To make all slices of an uncertain result independent, use Shuffle(A), or equivalently, Shuffle(A,Run).

Comments


You are not allowed to post comments.