Difference between revisions of "Sample Command"
From GeoGebra Manual
Line 5: | Line 5: | ||
;Sample[ <List L>, <Size n>, <Boolean for replacement> ] | ;Sample[ <List L>, <Size n>, <Boolean for replacement> ] | ||
:Returns list of ''n'' randomly chosen elements of ''L''. Elements can be chosen more times if and only if the last parameter is true. | :Returns list of ''n'' randomly chosen elements of ''L''. Elements can be chosen more times if and only if the last parameter is true. | ||
− | {{example|1=<code>Sample[{1, 2, 3, 4, 5}, 5, true]</code> yields for example ''{2,3,3,4,5}''.}} | + | :{{example|1=<div><code><nowiki>Sample[{1, 2, 3, 4, 5}, 5, true]</nowiki></code> yields for example ''{2, 3, 3, 4, 5}''.</div>}} |
− | |||
==CAS Syntax== | ==CAS Syntax== | ||
;Sample[ <List L>, <Size n> ] | ;Sample[ <List L>, <Size n> ] | ||
Line 12: | Line 11: | ||
;Sample[ <List L>, <Size n>, <Boolean for replacement> ] | ;Sample[ <List L>, <Size n>, <Boolean for replacement> ] | ||
:Returns list of ''n'' randomly chosen elements of ''L''. Elements can be chosen more times if and only if the last parameter is true. | :Returns list of ''n'' randomly chosen elements of ''L''. Elements can be chosen more times if and only if the last parameter is true. | ||
− | {{example|1=The list can include lists as well: Let ''List1'' be ''{1,2,3}''. <code>Sample[{List1,4,5,6,7,8}, 3, false]</code> yields for example {6,{1,2,3},4}.}} | + | :{{example|1=<div>The list can include lists as well: Let ''List1'' be ''{1, 2, 3}''. <code><nowiki>Sample[{List1,4,5,6,7,8}, 3, false]</nowiki></code> yields for example {6, {1, 2, 3}, 4}.</div>}} |
Revision as of 13:26, 24 August 2011
- Sample[ <List L>, <Size n> ]
- Returns list of n randomly chosen elements of L; elements can be chosen more times.
- Sample[ <List L>, <Size n>, <Boolean for replacement> ]
- Returns list of n randomly chosen elements of L. Elements can be chosen more times if and only if the last parameter is true.
- Example:
Sample[{1, 2, 3, 4, 5}, 5, true]
yields for example {2, 3, 3, 4, 5}.
CAS Syntax
- Sample[ <List L>, <Size n> ]
- Returns list of n randomly chosen elements of L; elements can be chosen more times.
- Sample[ <List L>, <Size n>, <Boolean for replacement> ]
- Returns list of n randomly chosen elements of L. Elements can be chosen more times if and only if the last parameter is true.
- Example:The list can include lists as well: Let List1 be {1, 2, 3}.
Sample[{List1,4,5,6,7,8}, 3, false]
yields for example {6, {1, 2, 3}, 4}.