Are Random Number Generators Random? Truth Explained

How-to basics · Updated November 23, 2026

No, random number generators are not truly random in the strictest sense—most are deterministic algorithms that produce sequences that only appear random. However, there are hardware-based generators that use physical processes to achieve genuine unpredictability. The answer depends on which type you mean: pseudo-random number generators (PRNGs) used in software, or true random number generators (TRNGs) that rely on physical phenomena.

What Does “Random” Actually Mean?

In everyday language, “random” means unpredictable or lacking a pattern. In mathematics and computing, randomness is defined more rigorously. A sequence is considered random if it cannot be predicted better than by chance, regardless of how much of the sequence you have already seen. For practical purposes, there are two levels of randomness:

  • Statistical randomness: The sequence passes tests for uniformity (each value appears about equally often) and independence (no discernible pattern or correlation between values).
  • True unpredictability: No algorithm or physical measurement can predict the next value with better than chance probability, even with full knowledge of the generation method and past outputs.

Most computer-generated random numbers meet the first definition but not the second.

Pseudo-Random Number Generators (PRNGs)

PRNGs are algorithms that generate a sequence of numbers that mimics randomness. They start from a seed—a single initial value—and then apply a mathematical formula to produce the next number. The sequence is entirely determined by the seed and the algorithm. If you know the seed and the algorithm, you can reproduce the entire sequence. This is why they are called “pseudo” (false) random.

Common PRNGs include:

  • Linear Congruential Generator (LCG): Uses the formula Xn+1 = (a * Xn + c) mod m. Very fast but not cryptographically secure.
  • Mersenne Twister: Used in Python and many other languages. It has a long period (2^19937 – 1) and good statistical properties, but it is not suitable for cryptography because its state can be reconstructed from enough outputs.
  • Cryptographically Secure PRNGs (CSPRNGs): Designed to be unpredictable even if the algorithm is known, as long as the seed is secret. Examples include ChaCha20 and the Fortuna algorithm used in many operating systems.

PRNGs are deterministic: the same seed always produces the same sequence. This is useful for simulations and testing, where reproducibility is desired, but it means they are not truly random.

True Random Number Generators (TRNGs)

TRNGs derive randomness from physical processes that are believed to be inherently unpredictable, such as:

  • Electronic noise: Thermal noise in a resistor or semiconductor junction.
  • Radioactive decay: The time between decays of a radioactive isotope is unpredictable.
  • Quantum effects: Photon arrival times or the polarization of individual photons.
  • Atmospheric noise: Variations in radio signals captured by a receiver.

Because these processes are not governed by deterministic laws (or at least not by any algorithm we can compute), the outputs are considered truly random. However, TRNGs are slower and more expensive than PRNGs, and they may be biased or have correlations that need to be corrected with post-processing. In practice, many systems use a hybrid approach: a TRNG seeds a CSPRNG to get both speed and a high degree of unpredictability.

How Randomness Is Tested

To assess whether a generator is good enough, statisticians use a battery of tests. The most well-known is the NIST Statistical Test Suite (from the U.S. National Institute of Standards and Technology), which includes 15 tests such as the frequency test, runs test, and the serial test. Another popular suite is Diehard and its successor Dieharder. These tests look for patterns that would indicate non-randomness, such as too many repeated values or correlations between consecutive numbers.

Passing these tests does not prove true randomness—it only shows that the sequence is statistically indistinguishable from random for the tested criteria. A deterministic PRNG can pass all tests if designed well, but it is still not truly random.

Common Misconceptions

One common misconception is that a random number generator can be “seeded” with the current time to make it truly random. Seeding with time is just a way to choose a different starting point; the algorithm remains deterministic. Another misconception is that if you see a pattern in a short sequence, the generator is broken. For example, rolling a die and getting 6 five times in a row might look suspicious, but it is actually possible (probability 1/7776) and does not indicate a non-random die. Randomness does not mean every value appears equally often in a small sample; it means there is no bias over the long run.

Why It Matters: Security and Fairness

The distinction between PRNG and TRNG is critical in security. If a PRNG is used to generate encryption keys and an attacker can guess the seed (e.g., because it was based on a predictable timestamp), they can recreate the keys. This is why CSPRNGs are used for cryptographic purposes, and why operating systems gather entropy from hardware sources to seed them. For example, Linux uses a pool of entropy from device timings, mouse movements, and other sources to seed its random generator.

In online gambling or lotteries, fairness requires that outcomes be unpredictable to players. If a PRNG with a known algorithm and seed is used, players could potentially predict results. Reputable casinos use TRNGs or well-seeded CSPRNGs and have them audited to ensure fairness.

How to Choose a Random Number Generator

Choosing the right generator depends on your use case:

  • Simulations and games: A standard PRNG like the Mersenne Twister is fast and has good statistical properties. Use a different seed for each run if you want varied results.
  • Cryptography (passwords, keys): Use a CSPRNG. In most programming languages, this is available as a built-in function (e.g., secrets in Python, crypto.getRandomValues in JavaScript).
  • Scientific research requiring reproducibility: Use a PRNG with a fixed seed so others can replicate your results.
  • High-stakes gambling or security tokens: Use a TRNG or a hybrid that combines a TRNG with a CSPRNG.

Always check the documentation of your language or library to see what type of generator is provided. Many languages use a PRNG by default, so you must explicitly choose a CSPRNG for security-sensitive tasks.

Frequently Asked Questions

Can a computer generate truly random numbers?

Yes, but only with dedicated hardware that measures physical phenomena. A standard computer without such hardware cannot generate truly random numbers; it relies on PRNGs. However, modern CPUs and operating systems often include a TRNG or a source of entropy (like thermal noise) that can be used to seed a CSPRNG, giving you practically unpredictable results.

Why do random number generators need a seed?

A seed is the initial value that determines the entire sequence of a PRNG. Without a seed, a PRNG would produce the same sequence every time, which is often undesirable. Seeding with a changing value (like the current time or system entropy) makes the sequence different each run, but it does not make the generator truly random.

Is the random function in Excel random?

Excel’s RAND function uses a PRNG (specifically, a Mersenne Twister variant) and is not cryptographically secure. It is fine for simulations and random sampling in spreadsheets, but you should not use it for security purposes. Excel also has RANDBETWEEN for integers. For reproducibility, you can set a seed using the RAND function with a fixed value in a separate cell, but Excel does not have a direct seed parameter.

What is the difference between random and pseudorandom?

Random (true) numbers come from unpredictable physical processes. Pseudorandom numbers come from deterministic algorithms that are designed to look random. Pseudorandom numbers are reproducible if you know the seed, while true random numbers are not. For most non-security applications, pseudorandom is sufficient.

Can a random number generator be hacked?

Yes, if it is a PRNG and the attacker knows the algorithm and can guess or observe the seed, they can predict the sequence. Even a CSPRNG can be compromised if the seed is leaked or if the generator has a flaw. TRNGs are harder to hack because they rely on physical processes, but they can still be biased or tampered with if the hardware is compromised.

Do quantum computers affect randomness?

Quantum computers themselves do not generate random numbers directly, but quantum mechanics provides a source of true randomness (e.g., measuring the spin of a particle). Some TRNGs already use quantum effects. Quantum computers could potentially break certain PRNGs by solving the mathematical problems they rely on, but they do not change the fundamental nature of randomness.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.