gives a pseudorandom choice of one of the ei.


gives a list of n pseudorandom choices.


gives an n1×n2× array of pseudorandom choices.


gives a pseudorandom choice weighted by the wi.


gives a list of n weighted choices.


gives an n1×n2× array of weighted choices.


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


open allclose all

Basic Examples  (4)

Choose among , , and at random:

A list of 20 random choices:

A 4×3 array of random choices:

Choices weighted with probabilities:

Weights are automatically normalized:

Scope  (2)

The choices can be any expressions:

Choose among all numbers between -10 and 10:

Choose among even numbers between -10 and 10:

Applications  (9)

Generate a random string:

Generate a weighted random string:

Generate integers according to a distribution:

Random array of color choices:

A random walk with steps of unit length:

2D random walk:

Random walk on a hexagonal lattice:

Randomly generate disks or circles:

A random graph with 1% of possible edges filled in:

Properties & Relations  (2)

Use SeedRandom to get repeatable random values:

Use BlockRandom to block one use of RandomChoice from affecting others:

Neat Examples  (5)

Pick 10 random words beginning with "a" from the dictionary:

Pick 10 random Wolfram Language functions:

Make a continuous string of characters:

Break the characters into "words":

2D random walk with eight directions:

3D lattice random walk:

Introduced in 2007