RandomChoice
RandomChoice[{e1,e2,…}]
gives a pseudorandom choice of one of the ei.
RandomChoice[list,n]
gives a list of n pseudorandom choices.
RandomChoice[list,{n1,n2,…}]
gives an n1×n2×… array of pseudorandom choices.
RandomChoice[{w1,w2,…}{e1,e2,…}]
gives a pseudorandom choice weighted by the wi.
RandomChoice[wlistelist,n]
gives a list of n weighted choices.
RandomChoice[wlistelist,{n1,n2,…}]
gives an n1×n2×… array of weighted choices.
Details
- RandomChoice is also known as simple random sampling or sampling with replacement.
- RandomChoice[{e1,e2,…}] chooses with equal probability between all of the ei.
- RandomChoice gives a different sequence of pseudorandom choices whenever you run the Wolfram Language. You can start with a particular seed using SeedRandom.
- A Method option to SeedRandom can be given to specify the pseudorandom generator used.
Examples
open allclose allBasic Examples (4)
Scope (2)
Applications (9)
Properties & Relations (2)
Use SeedRandom to get repeatable random values:
Use BlockRandom to block one use of RandomChoice from affecting others:
Text
Wolfram Research (2007), RandomChoice, Wolfram Language function, https://reference.wolfram.com/language/ref/RandomChoice.html.
CMS
Wolfram Language. 2007. "RandomChoice." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RandomChoice.html.
APA
Wolfram Language. (2007). RandomChoice. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RandomChoice.html