How to Generate Random Numbers

Anyone familiar with flipping a coin is aware of randomness. Mathematically, this is represented by random numbers. Random numbers have a role in everything from weather patterns to the random shifts in the path a prey animal uses to elude a predator.

Ads related to

An understanding of them is also valuable in distinguishing legitimate patterns in a series of numbers from random coincidences.

Producing random numbers is usually done through a computer since it can create numbers perfectly tailored to any given purpose in terms of size and complexity. Because computers follow set rules in performing any operation, they require an external input to generate true random numbers. Often this source is some quantum-level activity with high randomness referred to as high entropy. Otherwise, computers produce artificial-random numbers that appear random but actually have a logical basis to them that can be uncovered with careful analysis by hackers.

Why Generate Random Numbers?

There are a few areas where random numbers are particularly valuable.

  • Scientific Simulations
  • Video Games and Gaming
  • Cryptography

One important use of random numbers is in the field of scientific simulations such as those involving atomic and subatomic particles affected by quantum physics factors such as radioactive decay that transform elements by causing them to randomly lose electrons and protons. Brownian motion and other random phenomena influence chemical reactions.

It can also come in handy in simulating human and animal behavior since some choices all living creatures make come down to coin tosses. Another very familiar area where random numbers are valuable is gaming. This covers everything from first-person shooter video games to slot machines.

Finally, a highly important use for random numbers, especially true random numbers, is in cryptography. This practice of securing information to keep it out of the wrong hands relies on random numbers to produce unbreakable codes with no predictable patterns a hacker can discover.

How Can You Create Your Own Random Number Generator?

As previously mentioned, a computer can generate two types of random numbers. The computer produces artificial-random numbers by taking an initial number and running it through a specific sequence of operations known as an algorithm to create a series of statistically random numbers. Since a fixed string of calculations is used, the same initial number will always generate the same results.

True random numbers are created from inputs external to the computer like the exact time a key is pressed or the touchpad is used. Virtually all programming languages along with operating systems like Linux and even packages like Excel can generate random numbers. In the language JavaScript, embedded in all popular browsers, the command Math.random() will produce an artificial-random number between and 1. In Excel, the command RAND() accomplishes the same task. Linux operating systems come close to creating true random numbers by containing a list of numbers from 1 to 2 to the 4096-power and modifying the list with the microsecond-level timestamps from keystrokes.

Alternately, a security-oriented computer will come with hardware to produce true random numbers. This capability has now been added to Intel Ivy Bridge chipsets used in standard desktop and laptop computers. Also, there are true random number generators sold as USB dongles.

Online Random Number Generators

Rather than settle with artificial-random numbers or buying hardware, online generators are available either for free or for a fee. Be aware, though, that some services provide artificial-random numbers just like the average laptop does so it’s important to check what a particular service uses as its source.

Among the physical events used to produce random numbers, a popular source with online suppliers is atmospheric noise. This consists of the low-frequency radio waves produced by lightning strikes. The numbers result from both the repetitions of the strikes and their intensity. The provider uses this method and supplies up to one million bits of random numbers per day for free to subscribers while charging a fee for larger amounts.

The Australian National University offers a stream of free true random numbers at their website,, that are generated by measuring the electromagnetic fluctuations of a vacuum. Another online generator is This free service is a joint effort by the University of Geneva and IDQ and utilizes quantum optics, the random shifts in the trajectories of photons as they pass through a semi-transparent mirror, that’s also found in many USB random number dongles.

Ads related to