RandomSelect
RandomSelect
RandomSelect[list] randomly selects an expression from a list of expressions.
Usages
RandomSelect[list]
RandomSelect[list] randomly selects one element from a list of expressions list.
| Example | in | out |
|---|---|---|
A randomly selected element of { 2, 3, 5, 7 } |
RandomSelect[ { 2, 3, 5, 7 } ] |
7 |
RandomSelect[ list, n ]
RandomSelect[ list, n ] returns a list of length n with its elements randomly selected from list. The resulting list might contain duplicates.
| Example | in | out |
|---|---|---|
A list of 3 randomly selected expressions of { a, b, c, d }. |
RandomSelect[ {a, b, c, d }, 3 ] |
{ a, a, c } |
Options
AllowDuplicates
AllowDuplicates prevents the same option from being drawn more than once if set to False.
| Syntax | Example |
|---|---|
RandomSelect[{exp1, exp2, ..., expn}, num, AllowDuplicates=>False] |
RandomSelect[{2,4,6}, 2, AllowDuplicates=>False] |