Programmer Guide/Command Reference/EVAL/sample: Difference between revisions
From STX Wiki
< Programmer Guide | Command Reference | EVAL
Jump to navigationJump to search
(Created page with '{{DISPLAYTITLE:{{SUBPAGENAME}}}} Creates a random sample of a set. ;Usage: '''<code>sample(''n'' , ''m'')</code>''' :;''n'': the number of elements :;''m'': the size of the rand…') |
No edit summary |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:{{SUBPAGENAME}}}} | {{DISPLAYTITLE:{{SUBPAGENAME}}}} | ||
Creates a random sample of a set. | Creates a random sample (subset) of a set. | ||
;Usage: '''<code>sample(''n'' , ''m'')</code>''' | ;Usage: '''<code>sample(''n'' , ''m'')</code>''' | ||
:;''n'': the number of elements | :;''n'': the number of elements | ||
Line 7: | Line 6: | ||
;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. | ||
;See also: [[../rand|rand]], [[../grand|grand]], [[../shuffle|shuffle]], [[../vsubn|vsubn]] | |||
[[../#Functions|<function list>]] | |||
Latest revision as of 11:46, 21 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.
- See also
- rand, grand, shuffle, vsubn