Programmer Guide/Command Reference/EVAL/sample: Difference between revisions
From STX Wiki
< Programmer Guide | Command Reference | EVAL
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 8: | Line 8: | ||
: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. | ||
;See also: [[Programmer_Guide/Command_Reference/EVAL/rand|rand]], [[Programmer_Guide/Command_Reference/EVAL/ | ;See also: [[Programmer_Guide/Command_Reference/EVAL/rand|rand]], [[Programmer_Guide/Command_Reference/EVAL/grand|grand]], [[Programmer_Guide/Command_Reference/EVAL/shuffle|shuffle]] | ||
[[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]] | [[Programmer_Guide/Command_Reference/EVAL#Functions|<function list>]] |
Revision as of 15:50, 8 April 2011
Creates a random sample (subset) of a set.
- Usage
sample(n , m)
- n
- the number of elements
- m
- the size of the random sample;
0 < m < n
- 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.