Difference between revisions of "RandomElement Command"

From GeoGebra Manual
Jump to: navigation, search
(command syntax: changed [ ] into ( ))
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
<noinclude>{{Manual Page|version=5.0}}</noinclude>{{command|cas=true|list}}
 
<noinclude>{{Manual Page|version=5.0}}</noinclude>{{command|cas=true|list}}
;RandomElement[ &lt;List> ]
+
;RandomElement( &lt;List> )
 
:Returns randomly chosen element from the [[Lists|list]] (with uniform probability). All elements in the list must be of the same type.
 
:Returns randomly chosen element from the [[Lists|list]] (with uniform probability). All elements in the list must be of the same type.
:{{example| 1=<div><code><nowiki>RandomElement[{3, 2, -4, 7}]</nowiki></code> yields one of ''{-4, 2, 3, 7}''.</div>}}
+
:{{example| 1=<div><code><nowiki>RandomElement({3, 2, -4, 7})</nowiki></code> yields one of ''{-4, 2, 3, 7}''.</div>}}
{{note| 1=<div>See also [[Element Command]].</div>}}
+
<br>
 
+
{{hint| 1=
==CAS Syntax==
+
In the [[File:Menu view cas.svg|link=|16px]] [[CAS View]] this command also works with symbolic input.
;RandomElement[ &lt;List> ]
+
:{{example| 1=<div><code><nowiki>RandomElement({a,b,c,d})</nowiki></code> yields one of ''{a, b, c, d}''.</div>}}
:Returns randomly chosen element from the [[Lists|list]] (with uniform probability). All elements in the list must be of the same type.
+
}}
:{{example| 1=<div><code><nowiki>RandomElement[{3, 2, -4, 7}]</nowiki></code> yields one of ''{-4, 2, 3, 7}''.</div>}}
+
{{note| 1=<div>See also [[Element Command]], [[SetSeed Command]], [[RandomBetween Command]], [[RandomBinomial Command]], [[RandomNormal Command]], [[RandomPoisson Command]] and [[RandomUniform Command]].</div>}}
{{note| 1=<div>See also [[Element Command]].</div>}}
 
{{Note|1= See also [[SetSeed Command|SetSeed command]], [[RandomBetween Command|RandomBetween command]], [[RandomBinomial Command|RandomBinomial command]], [[RandomNormal Command|RandomNormal command]], [[RandomPoisson Command|RandomPoisson command]], [[RandomUniform Command|RandomUniform command]].}}
 

Latest revision as of 11:26, 6 October 2017


RandomElement( <List> )
Returns randomly chosen element from the list (with uniform probability). All elements in the list must be of the same type.
Example:
RandomElement({3, 2, -4, 7}) yields one of {-4, 2, 3, 7}.


Note Hint: In the Menu view cas.svg CAS View this command also works with symbolic input.
Example:
RandomElement({a,b,c,d}) yields one of {a, b, c, d}.
© 2024 International GeoGebra Institute