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

From STX Wiki
Jump to navigationJump to search
(Created page with '{{DISPLAYTITLE:{{SUBPAGENAME}}}} Create a ''shuffled'' version of a set. ;Usage: '''<code>shuffle(''x'' {, ''n'' {, ''once'' { ''seed''}}})</code>''' :;''x'': the set to be shuf…')
 
No edit summary
Line 5: Line 5:
:;''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)
:;''oncem'': the size of the random sample; <code>0 < ''m'' < ''n''</code>
:;''once'': if not equal ''0'' the position of a row must not be changed more than 1 times, otherwise the number of position changes of a row is not limited
:;''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
 
 
;Result: A vector with length ''m'', containing the indices of the selected elements of the set.
;Result: A vector with length ''m'', containing the indices of the selected elements of the set.
:It is assumed that the set is indexed from 0 to ''n''-1 (i.e. the number of elements). The result vector can be applied as an index list on the set to extract the corresponding elements.
:It is assumed that the set is indexed from 0 to ''n''-1 (i.e. the number of elements). The result vector can be applied as an index list on the set to extract the corresponding elements.

Revision as of 16:00, 8 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
if not equal 0 the position of a row must not be changed more than 1 times, otherwise the number of position changes of a row is not limited
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


Result
A vector with length m, containing the indices of the selected elements of the set.
It is assumed that the set is indexed from 0 to n-1 (i.e. the number of elements). The result vector can be applied as an index list on the set to extract the corresponding elements.
See also
rand, grand, shuffle

<function list>

Navigation menu

Personal tools