apply random permutation to a data sample - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Statistics : Statistics Package : Data Manipulation : Statistics/Shuffle

Statistics[Shuffle] - apply random permutation to a data sample

Calling Sequence

Shuffle(X, options)

Parameters

X

-

data sample

options

-

(optional) equation of the form inplace = truefalse; indicates whether to change the argument

Description

• 

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.

Notes

• 

The Shuffle command accepts non-numeric data.

Examples

withStatistics:

A:=Arraya,b,c,d,e,f,g,h,i,j

A:=abcdefghij

(1)

A1:=ShuffleA

A1:=cgajdehibf

(2)

A2:=ShuffleA

A2:=jceaidfghb

(3)

A3:=ShuffleA

A3:=bjhigaedfc

(4)

sortA1

abcdefghij

(5)

B:=Arrayseqi,i=1..10

B:=12345678910

(6)

C:=ShuffleB

C:=23457691108

(7)

OrderByRankA,C

habcdfejgi

(8)

So far, A itself has not changed. The inplace option changes this.

A

abcdefghij

(9)

ShuffleA,inplace:A

aeidcghjfb

(10)

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

withStatistics:

A:=Arraya,b,c,d,e,f,g,h,i,j

A:=abcdefghij

(11)

A1:=ShuffleA

A1:=cgajdehibf

(12)

restart

withStatistics:

A:=Arraya,b,c,d,e,f,g,h,i,j

A:=abcdefghij

(13)

randomize

142423358224525

(14)

A1:=ShuffleA

A1:=fjbciaghde

(15)

See Also

Statistics, Statistics[Computation], Statistics[OrderByRank], Statistics[Rank], Statistics[Sort]


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam