Difference between revisions of "Sample Command"
From GeoGebra Manual
m (Text replace - "<div class="box info"> 48px|left This page is part of the official manual for print and pdf. For structural reasons normal users can't edit this page. If you found any errors on this page please contact ) |
|||
Line 1: | Line 1: | ||
<noinclude>{{Manual Page|version=4.2}}</noinclude> | <noinclude>{{Manual Page|version=4.2}}</noinclude> | ||
{{command|cas=true|statistics}} | {{command|cas=true|statistics}} | ||
− | ;Sample[ <List | + | ;Sample[ <List>, <Size> ] |
− | :Returns list of ''n'' randomly chosen elements of | + | :Returns list of ''n'' randomly chosen elements of a list; elements can be chosen several times. |
:{{example|1=<div><code><nowiki>Sample[{1, 2, 3, 4, 5}, 5]</nowiki></code> yields for example ''{1, 2, 1, 5, 4}''.</div>}} | :{{example|1=<div><code><nowiki>Sample[{1, 2, 3, 4, 5}, 5]</nowiki></code> yields for example ''{1, 2, 1, 5, 4}''.</div>}} | ||
− | ;Sample[ <List | + | |
− | :Returns list of ''n'' randomly chosen elements of | + | |
+ | ;Sample[ <List>, <Size>, <With Replacement> ] | ||
+ | :Returns list of ''n'' randomly chosen elements of a list. Elements can be chosen several times if and only if the last parameter is true. | ||
:{{example|1=<div><code><nowiki>Sample[{1, 2, 3, 4, 5}, 5, true]</nowiki></code> yields for example ''{2, 3, 3, 4, 5}''.</div>}} | :{{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 | + | ;Sample[ <List>, <Size> ] |
− | :Returns list of ''n'' randomly chosen elements of | + | :Returns list of ''n'' randomly chosen elements of a list; elements can be chosen several times. |
:{{example|1=<div><code><nowiki>Sample[{-5, 2, a, 7, c}, 3]</nowiki></code> yields for example ''{a, 7, -5}''.</div>}} | :{{example|1=<div><code><nowiki>Sample[{-5, 2, a, 7, c}, 3]</nowiki></code> yields for example ''{a, 7, -5}''.</div>}} | ||
− | ;Sample[ <List | + | |
− | :Returns list of ''n'' randomly chosen elements of | + | |
+ | ;Sample[ <List>, <Size>, <With Replacement> ] | ||
+ | :Returns list of ''n'' randomly chosen elements of a list. Elements can be chosen several times if and only if the last parameter is true. | ||
:{{example|1=<div>The list can include lists as well: Let ''List1'' be ''{1, 2, 3}''.<br /><code><nowiki>Sample[{List1, 4, 5, 6, 7, 8}, 3, false]</nowiki></code> yields for example ''{6, {1, 2, 3}, 4}''.</div>}} | :{{example|1=<div>The list can include lists as well: Let ''List1'' be ''{1, 2, 3}''.<br /><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 07:17, 17 July 2013
- Sample[ <List>, <Size> ]
- Returns list of n randomly chosen elements of a list; elements can be chosen several times.
- Example:
Sample[{1, 2, 3, 4, 5}, 5]
yields for example {1, 2, 1, 5, 4}.
- Sample[ <List>, <Size>, <With Replacement> ]
- Returns list of n randomly chosen elements of a list. Elements can be chosen several 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>, <Size> ]
- Returns list of n randomly chosen elements of a list; elements can be chosen several times.
- Example:
Sample[{-5, 2, a, 7, c}, 3]
yields for example {a, 7, -5}.
- Sample[ <List>, <Size>, <With Replacement> ]
- Returns list of n randomly chosen elements of a list. Elements can be chosen several 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}.