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.
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 all close allBasic Examples (6)
A random real number in the range 0 to 1:
RandomReal[]A random real number in the range
to
:
RandomReal[{-10, 10}]A random real number in the range 0 to 10:
RandomReal[10]Five random reals in the range 0 to 1:
RandomReal[1, 5]A 3×2 array of random reals in the range
to
:
RandomReal[{-1, 1}, {3, 2}]Random coordinates for 4 points in 3 dimensions:
RandomReal[1, {4, 3}]Scope (3)
Generate random reals of any magnitude:
RandomReal[10 ^ 1000]Generate random reals of any precision:
RandomReal[WorkingPrecision -> 30]RandomReal[10 ^ 1000, WorkingPrecision -> 50]RandomReal[{-1, 1}, 5, WorkingPrecision -> 5]Options (1)
Applications (8)
ListLinePlot[Accumulate[RandomReal[{-1, 1}, 100]]]Graphics[Circle /@ RandomReal[10, {40, 2}]]ArrayPlot[RandomReal[1, {30, 40}]]Graphics3D[Sphere /@ RandomReal[10, {50, 3}]]Graphics[Line[Accumulate[RandomReal[{-1, 1}, {500, 2}]]]]Three-dimensional random walk:
Graphics3D[Line[Accumulate[RandomReal[{-1, 1}, {500, 3}]]]]Determinants of random 100×100 matrices:
Table[Det[RandomReal[1, {100, 100}]], {10}]Generate a complex number in the unit square:
RandomReal[1, 2].{1, I}RandomReal[1, {5, 2}].{1, I}Use RandomComplex instead:
RandomComplex[1 + I, 5]Generate exponential random variables using inversion method:
sample = InverseCDF[ExponentialDistribution[1], RandomReal[1, 10 ^ 4]];Compare sample histogram with the PDF of ExponentialDistribution:
Show[Histogram[sample, Automatic, PDF], Plot[PDF[ExponentialDistribution[1], x], {x, 0, 6}]]Alternatively, use RandomVariate to sample from nonuniform distributions directly:
sample2 = RandomVariate[ExponentialDistribution[1], 10 ^ 4];Test whether both datasets could be samples from the same distribution:
KolmogorovSmirnovTest[sample, sample2, "TestConclusion"]Properties & Relations (5)
Use SeedRandom to get repeatable random values:
{RandomReal[], RandomReal[]}{SeedRandom[1234];RandomReal[], SeedRandom[1234];RandomReal[]}Use BlockRandom to block one use of RandomReal from affecting others:
{BlockRandom[RandomReal[]], RandomReal[]}With the same seed, RandomReal generates the "same" number, regardless of precision:
Table[SeedRandom[4567];RandomReal[WorkingPrecision -> p], {p, 10}]RandomReal generates a uniform distribution, here with mean 0.5:
Mean[RandomReal[1, 10000]]RandomReal generates white noise:
ListLinePlot[Abs[Fourier[RandomReal[{-1, 1}, 1000]]]]Tech Notes
History
Text
Wolfram Research (2007), RandomReal, Wolfram Language function, https://reference.wolfram.com/language/ref/RandomReal.html.
CMS
Wolfram Language. 2007. "RandomReal." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RandomReal.html.
APA
Wolfram Language. (2007). RandomReal. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RandomReal.html
BibTeX
@misc{reference.wolfram_2026_randomreal, author="Wolfram Research", title="{RandomReal}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/RandomReal.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_randomreal, organization={Wolfram Research}, title={RandomReal}, year={2007}, url={https://reference.wolfram.com/language/ref/RandomReal.html}, note=[Accessed: 13-June-2026]}