Random Number

Contribute to this entry

A random number is a number chosen as if by chance from some specified distribution such that selection of a large set of these numbers reproduces the underlying distribution. Almost always, such numbers are also required to be independent, so that there are no correlations between successive numbers. Computer-generated random numbers are sometimes called pseudorandom numbers, while the term "random" is reserved for the output of unpredictable physical processes. When used without qualification, the word "random" usually means "random with a uniform distribution." Other distributions are of course possible. For example, the Box-Muller transformation allows pairs of uniform random numbers to be transformed to corresponding random numbers having a two-dimensional normal distribution.

It is impossible to produce an arbitrarily long string of random digits and prove it is random. Strangely, it is also very difficult for humans to produce a string of random digits, and computer programs can be written which, on average, actually predict some of the digits humans will write down based on previous ones.

There are a number of common methods used for generating pseudorandom numbers, the simplest of which is the linear congruence method. Another simple and elegant method is elementary cellular automaton rule 30, whose central column is given by 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, ... (OEIS A051023), and which provides the random number generator used for large integers in the Wolfram Language. Most random number generators require specification of an initial number used as the starting point, which is known as a "seed." The goodness of random numbers generated by a given algorithm can be analyzed by examining its noise sphere.

When generating random numbers over some specified boundary, it is often necessary to normalize the distributions so that each differential area is equally populated. For example, picking theta and phi from uniform distributions does not give a uniform distribution for sphere point picking.

In order to generate a power-law distribution P(x) from a uniform distribution P(y), write P(x)=Cx^n for x in [x_0,x_1]. Then normalization gives

 int_(x_0)^(x_1)P(x)dx=C([x^(n+1)]_(x_0)^(x_1))/(n+1)=1,
(1)

so

 C=(n+1)/(x_1^(n+1)-x_0^(n+1)).
(2)

Let Y be a uniformly distributed variate on [0,1]. Then

D(x)=int_(x_0)^xP(x^')dx^'
(3)
=Cint_(x_0)^xx^('n)dx^'
(4)
=C/(n+1)(x^(n+1)-x_0^(n+1))
(5)
=y,
(6)

and the variate given by

X=((n+1)/Cy+x_0^(n+1))^(1/(n+1))
(7)
=[(x_1^(n+1)-x_0^(n+1))y+x_0^(n+1)]^(1/(n+1))
(8)

is distributed as P(x).

Wolfram Web Resources

Mathematica »

The #1 tool for creating Demonstrations and anything technical.

Wolfram|Alpha »

Explore anything with the first computational knowledge engine.

Wolfram Demonstrations Project »

Explore thousands of free applications across science, mathematics, engineering, technology, business, art, finance, social sciences, and more.

Computerbasedmath.org »

Join the initiative for modernizing math education.

Online Integral Calculator »

Solve integrals with Wolfram|Alpha.

Step-by-step Solutions »

Walk through homework problems step-by-step from beginning to end. Hints help you try the next step on your own.

Wolfram Problem Generator »

Unlimited random practice problems and answers with built-in Step-by-step solutions. Practice online or make a printable study sheet.

Wolfram Education Portal »

Collection of teaching and learning tools built by Wolfram education experts: dynamic textbook, lesson plans, widgets, interactive Demonstrations, and more.

Wolfram Language »

Knowledge-based programming for everyone.