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 ) |
(command syntax: changed [ ] into ( )) |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | <noinclude>{{Manual Page|version= | + | <noinclude>{{Manual Page|version=5.0}}</noinclude>{{command|cas=true|statistics}} |
− | {{command|cas=true|statistics}} | + | ;Sample( <List>, <Size> ) |
− | ;Sample | + | :Returns list of ''n'' randomly chosen elements of a list; elements can be chosen several times. |
− | :Returns list of ''n'' randomly chosen elements of | + | :{{example|1=<code><nowiki>Sample({1, 2, 3, 4, 5}, 5)</nowiki></code> yields for example ''list1 = {1, 2, 1, 5, 4}''.}} |
− | :{{example|1= | + | |
− | ;Sample | + | |
− | :Returns list of ''n'' randomly chosen elements of | + | ;Sample( <List>, <Size>, <With Replacement> ) |
− | :{{example|1= | + | :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. |
− | ==CAS | + | :{{example|1=<code><nowiki>Sample({1, 2, 3, 4, 5}, 5, true)</nowiki></code> yields for example ''list1 = {2, 3, 3, 4, 5}''.}} |
− | + | ||
− | + | ||
− | :{{ | + | {{hint|1= |
− | + | In the [[File:Menu view cas.svg|link=|16px]] [[CAS View]] the input list can contain different types of objects: | |
− | : | + | :{{examples|1=<div> |
− | : | + | ::*<code><nowiki>Sample({-5, 2, a, 7, c}, 3)</nowiki></code> yields for example ''{a, 7, -5}''. |
+ | ::*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>}} | ||
+ | }} |
Latest revision as of 10:03, 12 October 2017
- 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 list1 = {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 list1 = {2, 3, 3, 4, 5}.
Hint: In the CAS View the input list can contain different types of objects:
- Examples:
Sample({-5, 2, a, 7, c}, 3)
yields for example {a, 7, -5}.- 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}.