Mathematica 9 is now available
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.
Mathematica > Data Manipulation > Statistics > Random Number Generation >
Mathematica > Mathematics and Algorithms > Mathematical Functions > Random Number Generation >
Mathematica > Mathematics and Algorithms > Statistics > Random Number Generation >

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 n_1xn_2x... array of pseudorandom reals.
RandomReal[dist, ...]
samples from the symbolic continuous distribution dist.
  • 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 Mathematica. You can start with a particular seed using SeedRandom.
  • A Method option to SeedRandom can be given to specify the pseudorandom generator used.
A random real number in the range 0 to 1:
A random real number in the range -10 to 10:
A random real number in the range 0 to 10:
A random real from a normal distribution with mean 0 and standard deviation 1:
5 random reals in the range 0 to 1:
A 3 x2 array of random reals in the range -1 to 1:
Random coordinates for 4 points in 3 dimensions:
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 -10 to 10:
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]=
 
A random real from a normal distribution with mean 0 and standard deviation 1:
In[1]:=
Click for copyable input
Out[1]=
 
5 random reals in the range 0 to 1:
In[1]:=
Click for copyable input
Out[1]=
 
A 3 x2 array of random reals in the range -1 to 1:
In[1]:=
Click for copyable input
Out[1]=
 
Random coordinates for 4 points in 3 dimensions:
In[1]:=
Click for copyable input
Out[1]=
Generate random reals of any magnitude:
Generate random reals of any precision:
Generate low-precision reals:
Generate a random real with 50-digit precision:
A random walk:
Circles at random positions:
Random array of gray levels:
Spheres at random positions:
2D random walk:
3D random walk:
Determinants of random 100×100 matrices:
Generate a complex number in the unit square:
Generate 5 complex numbers:
Use SeedRandom to get repeatable random values:
Use BlockRandom to block one use of RandomReal from affecting others:
With the same seed, RandomReal generates the "same" number, regardless of precision:
RandomReal generates a uniform distribution, here with mean 0.5:
RandomReal generates white noise:
Construct a surface from random heights:
3D normal distribution of points:
New in 6
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team