Difference between revisions of "Shuffle"
Line 6: | Line 6: | ||
= Function Shuffle(a [, i]) = | = 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. | + | 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. If a contains dimensions other than i, it shuffles each slice over those other dimensions independently over i. |
== Declaration == | == Declaration == | ||
Line 12: | Line 12: | ||
Shuffle(a: Array[i]; i: IndexType = Run) | Shuffle(a: Array[i]; i: IndexType = Run) | ||
− | + | If you want to shuffle the slices of a multidimensional array over index i, without shuffling the values within each slice, use this method: | |
− | |||
− | If you want to shuffle the slices | ||
A[@I = Shuffle(@I,I)] | A[@I = Shuffle(@I,I)] | ||
− | This | + | This shuffles A over index I, but does not shuffle each slice of A for each value of I. |
Revision as of 22:06, 28 August 2007
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. If a contains dimensions other than i, it shuffles each slice over those other dimensions independently over i.
Declaration
Shuffle(a: Array[i]; i: IndexType = Run)
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.
Comments
Enable comment auto-refresher