# Difference between revisions of "Sample Command"

Jump to: navigation, search

##### Sample

This article is about GeoGebra command.

##### Command Categories (All commands)

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}.

## 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}.
• GeoGebra
• Help
• Partners
• Contact us
• Feedback & Questions
• This email address is being protected from spambots. You need JavaScript enabled to view it.
• +43 677 6137 2693
© 2021 International GeoGebra Institute