Statistics
Shuffle
apply random permutation to a data sample
Calling Sequence
Parameters
Description
Notes
Examples
Shuffle(X, options)
X
-
data sample
options
(optional) equation of the form inplace = truefalse; indicates whether to change the argument
The Shuffle command applies a random permutation to X.
The first parameter X is a data sample - given as e.g. a Vector.
An option inplace = true or inplace = false can be specified as a second argument. With inplace = true, Shuffle will change X in place if it is an Array or a Vector; with inplace = false, Shuffle will return a new (shuffled) copy of X. If X is a list, then Shuffle returns a new copy either way. The default is inplace = false.
The option inplace = true can be abbreviated to inplace.
The Shuffle command accepts non-numeric data.
with⁡Statistics:
A≔Array⁡a,b,c,d,e,f,g,h,i,j
A≔abcdefghij
A1≔Shuffle⁡A
A1≔gdeaifbhjc
A2≔Shuffle⁡A
A2≔cejgafbhid
A3≔Shuffle⁡A
A3≔cdibhefjga
sort⁡A1
abcdefghij
B≔Array⁡seq⁡i,i=1..10
B≔12345678910
C≔Shuffle⁡B
C≔10351269487
OrderByRank⁡A,C
debhcfjiga
So far, A itself has not changed. The inplace option changes this.
A
Shuffle⁡A,inplace:A
edhibjgcfa
Note that the output of Maple's random number generator is reproducible after a restart. If this is undesirable, one can use the randomize command.
restart
randomize⁡
47294191414
A1≔fchjgdibea
See Also
Statistics[Computation]
Statistics[OrderByRank]
Statistics[Rank]
Statistics[Sort]
Download Help Document