RandomReal

RandomReal[]

gives a pseudorandom real number in the range 0 to 1.

RandomReal[{xmin,xmax}]

gives a pseudorandom real number in the range xmin to xmax.

RandomReal[xmax]

gives a pseudorandom real number in the range 0 to xmax.

RandomReal[range,n]

gives a list of n pseudorandom reals.

RandomReal[range,{n1,n2,}]

gives an n1×n2× array of pseudorandom reals.

Details and Options

  • RandomReal[{xmin,xmax}] chooses reals with a uniform probability distribution in the range xmin to xmax.
  • RandomReal[spec,WorkingPrecision->n] yields reals with n-digit precision. Leading or trailing digits in the generated number can turn out to be 0.
  • RandomReal gives a different sequence of pseudorandom reals 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 all

Basic Examples  (6)

A random real number in the range 0 to 1:

In[1]:=
Click for copyable input
Out[1]=

A random real number in the range to :

In[1]:=
Click for copyable input
Out[1]=

A random real number in the range 0 to 10:

In[1]:=
Click for copyable input
Out[1]=

Five random reals in the range 0 to 1:

In[1]:=
Click for copyable input
Out[1]=

A 3×2 array of random reals in the range to :

In[1]:=
Click for copyable input
Out[1]=

Random coordinates for 4 points in 3 dimensions:

In[1]:=
Click for copyable input
Out[1]=

Scope  (3)

Options  (1)

Applications  (8)

Properties & Relations  (5)

Neat Examples  (1)

See Also

RandomVariate  RandomInteger  RandomComplex  RandomChoice  SeedRandom  FindInstance

Tutorials

Introduced in 2007
(6.0)