Programmer Guide/Command Reference/EVAL/shuffle: Difference between revisions

From STX Wiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 3: Line 3:
;Usage: <code>shuffle(''x'' {, ''n'' {, ''once'' { ''seed''}}})</code>
;Usage: <code>shuffle(''x'' {, ''n'' {, ''once'' { ''seed''}}})</code>
:;''x'': the set to be shuffled; must be a vector or matrix
:;''x'': the set to be shuffled; must be a vector or matrix
:;''n'': the number of row exchanges applied top ''x''; <code>0 < ''n''</code> (default=<code>nrow(''x'')/2)
:;''n'': the number of row exchanges applied top ''x''; <code>0 < ''n''</code> (default=<code>nrow(''x'')/2</code>)
:;''once'': change row position only once
:;''once'': change row position only once
::''once''==0: the number of exchanges of a row is not limited
::''once''=0: the number of exchanges of a row is not limited
::''once''!=0: the number of exchanges of a row is limited to 1
::''once''&ne;0: the number of exchanges of a row is limited to 1
:;''seed'': if this value is not equal ''0'', it is used to initialize the random number generator used to select the rows to be exchanged
:;''seed'': if this value is not equal ''0'', it is used to initialize the random number generator which generates the indices of the rows to be exchanged
;Result: The result has the same type and content as ''x'', but the order of the rows is changed (''shuffeld'') randomly. To shuffle the row indices, ''n'' times two randomly selected rows are exchanged.
;Result: The result has the same type and content as ''x'', but the order of the rows is changed (''shuffled'') randomly. To shuffle the row indices, ''n'' times two randomly selected rows are exchanged.
;See also: [[../rand|rand]], [[../grand|grand]], [[../sample|sample]], [[../sort|sort]]
;See also: [[../rand|rand]], [[../grand|grand]], [[../sample|sample]], [[../sort|sort]]


[[../#Functions|<function list>]]
[[../#Functions|<function list>]]

Latest revision as of 19:07, 21 April 2011

Create a shuffled version of a set.

Usage
shuffle(x {, n {, once { seed}}})
x
the set to be shuffled; must be a vector or matrix
n
the number of row exchanges applied top x; 0 < n (default=nrow(x)/2)
once
change row position only once
once=0: the number of exchanges of a row is not limited
once≠0: the number of exchanges of a row is limited to 1
seed
if this value is not equal 0, it is used to initialize the random number generator which generates the indices of the rows to be exchanged
Result
The result has the same type and content as x, but the order of the rows is changed (shuffled) randomly. To shuffle the row indices, n times two randomly selected rows are exchanged.
See also
rand, grand, sample, sort

<function list>

Navigation menu

Personal tools