Can You Generate Truly Random Numbers?

How-to basics · Updated November 25, 2026

Yes, you can generate truly random numbers, but not with a normal computer program or a spreadsheet function. True randomness requires a physical process—like radioactive decay, atmospheric noise, or quantum effects—that is fundamentally unpredictable. Software alone can only produce pseudorandom numbers, which are generated by deterministic algorithms and are reproducible if you know the starting point.

What Does “Truly Random” Actually Mean?

Randomness in the strict sense means each outcome is independent of all previous outcomes and has no pattern that can be predicted, even with full knowledge of the generator’s state. For example, a fair coin flip is truly random if the flip is not biased. In computing, we usually care about two properties: statistical randomness (the sequence passes tests for uniformity and independence) and unpredictability (an observer cannot guess the next number). A pseudorandom number generator (PRNG) can achieve the first but not the second—if you know the seed and the algorithm, you can reproduce the entire sequence.

How Pseudorandom Number Generators Work

Most software, including Excel, uses a PRNG. Excel’s RAND() function, for instance, uses a linear congruential generator (LCG) with a seed derived from the system clock. The formula is roughly:

  • Start with a seed value (e.g., time in milliseconds).
  • Compute next = (a * current + c) mod m, where a, c, and m are constants.
  • Return a fraction between 0 and 1.

Because the constants are fixed, the sequence repeats after a period (Excel’s period is 2^48, which is large but finite). If you reset the seed, you get the same numbers again. That is why you can reproduce a “random” sample in Excel by setting the seed before calling RAND()—but that also means it is not truly random.

True Random Number Generators (TRNGs)

True random number generators rely on physical phenomena that are inherently unpredictable. Common sources include:

  • Atmospheric noise – radio static captured by an antenna, as used by random.org.
  • Radioactive decay – the time between decays of a radioactive isotope is quantum-random.
  • Quantum effects – photon shot noise or quantum tunneling in specialized hardware.
  • Thermal noise – random voltage fluctuations in a resistor.

These sources produce bits that are not reproducible, even if you know the exact conditions. However, they can be biased (e.g., more 1s than 0s), so they are often passed through a “whitening” algorithm (like a cryptographic hash) to remove bias while preserving unpredictability.

How to Get Truly Random Numbers in Practice

If you need true randomness for cryptography, lotteries, or scientific sampling, you have several options:

  1. Use a dedicated hardware TRNG – Many modern CPUs (Intel, AMD) include an instruction like RDRAND that draws from on-chip thermal noise. It is fast but sometimes criticized for potential backdoors, so many cryptographers mix it with a software PRNG.
  2. Use an online service – random.org provides true random numbers from atmospheric noise. You can download batches or use their API.
  3. Use a quantum random number generator – Companies like ID Quantique sell USB devices that use photon detection.
  4. Use your own physical setup – For example, measure the timing of keystrokes or mouse movements, but these are often low-entropy and require careful processing.

For most everyday purposes—simulations, games, statistical sampling—a good PRNG is sufficient. But for security keys or gambling, true randomness is mandatory.

Common Misconceptions About Randomness

One common myth is that “random” means “no pattern at all.” In a truly random sequence, patterns appear by chance. For instance, flipping a coin 100 times might produce a run of 7 heads in a row—that is not evidence of bias. Another misconception is that a random number generator can be “seeded” to produce a different sequence each time. Seeding only works for PRNGs; a TRNG has no seed because it does not use an algorithm.

Another frequent question: “Can I use Excel’s RAND() for a lottery?” The answer is technically no, because the sequence is deterministic. However, for a non-security application like assigning random groups in a classroom, it is fine.

How to Choose Between PRNG and TRNG

Your choice depends on the stakes:

  • Simulation and modeling – PRNGs are faster and reproducible, which is useful for debugging. Use a high-quality one like the Mersenne Twister.
  • Cryptography – Use a cryptographic PRNG (CSPRNG) seeded by a TRNG, or use a TRNG directly. Never use RAND() for passwords.
  • Lotteries and gambling – Regulatory bodies require TRNGs or certified CSPRNGs with audit trails.
  • Scientific experiments – Use a TRNG if you need to prove unpredictability; otherwise, a PRNG with a fixed seed is acceptable for reproducibility.

In practice, many systems use a hybrid: a TRNG provides a seed for a CSPRNG, which then generates a long stream of numbers. This combines the unpredictability of hardware with the speed and repeatability of software.

Costs and Safety Considerations

Hardware TRNGs range from about $20 (a small USB dongle) to several thousand dollars for high-speed enterprise models. Online services like random.org are free for small requests but charge for bulk API access. The main safety concern is trust: if you use a third-party TRNG, you must trust that the provider is not biased or compromised. For high-stakes applications, you should verify the source or use your own hardware.

Another safety issue is that some PRNGs are cryptographically weak. For example, Excel’s RAND() is not suitable for generating encryption keys. Always use a well-vetted CSPRNG like CryptGenRandom (Windows) or /dev/urandom (Linux) for security purposes.

Frequently Asked Questions

Is the random number in Excel truly random?

No. Excel’s RAND() and RANDBETWEEN() use a pseudorandom algorithm. They are fine for casual use but not for cryptography or gambling. If you need true randomness in Excel, you can import numbers from a TRNG service or use a VBA macro that calls the Windows API’s CryptGenRandom.

Can a computer generate true randomness without special hardware?

Not reliably. A standard computer can gather entropy from timing of interrupts, mouse movements, or disk I/O, but these are not truly random—they are just hard to predict. True randomness requires a physical source that is inherently unpredictable, which usually means dedicated hardware.

Why do online random number generators say they are “true random”?

They use a physical source, like atmospheric noise, to generate the numbers. For example, random.org captures radio noise from the atmosphere and processes it. That is a legitimate TRNG, as long as the processing does not introduce bias.

What is the difference between a seed and a salt?

A seed is the initial value for a PRNG. A salt is a random value added to a password before hashing to prevent rainbow table attacks. They are different concepts: a seed makes a PRNG reproducible, while a salt makes a hash unique even for the same password.

Can I use a quantum computer to generate true random numbers?

Yes, but you do not need a full quantum computer. Simple quantum devices that measure photon polarization or tunneling can generate random bits. In fact, some TRNGs use quantum effects already. A full quantum computer is overkill and not commercially available for this purpose.

Is there a way to test if a sequence is truly random?

You can run statistical tests (like the NIST test suite) to check for patterns, but passing tests does not prove true randomness—it only shows that the sequence looks random. The only way to know for sure is to know the generator’s design and source. For TRNGs, you can also test the physical source for bias, but you cannot prove unpredictability absolutely.

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.