No, ordinary computers cannot generate true random numbers on their own—they can only produce pseudorandom numbers using deterministic algorithms. However, computers can generate true random numbers when they are equipped with specialized hardware that samples a physical, unpredictable process, such as radioactive decay or atmospheric noise.
What “True Random” Actually Means
In mathematics and computer science, a true random number sequence has no pattern, no correlation between successive values, and cannot be predicted even if you know the entire generation method. Each outcome is independent and equally likely (for a uniform distribution). Pseudorandom numbers, by contrast, are generated by a deterministic algorithm: given the same starting value (seed), they always produce the same sequence. They look random and pass many statistical tests, but they are not truly unpredictable.
Why Computers Default to Pseudorandomness
Digital computers are built on deterministic logic gates. Every operation—addition, comparison, memory access—follows a fixed sequence of electrical states. To produce a number, the CPU executes instructions that compute a value from an internal state. There is no inherent source of unpredictability in the standard CPU or memory. Thus, software random number generators (RNGs) use algorithms like the Mersenne Twister or the xorshift family. These algorithms are fast and statistically good, but they are still mathematical functions.
How Hardware Generates True Randomness
True randomness requires a physical entropy source. Modern computers and peripherals can include a dedicated chip or circuit that measures a naturally random phenomenon. Common sources include:
- Thermal noise: Random voltage fluctuations in a resistor or semiconductor junction.
- Radioactive decay: The time intervals between emissions from a radioactive isotope are fundamentally random.
- Atmospheric noise: Variations in radio signals captured by an antenna.
- Quantum effects: The polarization state of a photon or the spin of an electron, which are unpredictable according to quantum mechanics.
The hardware samples these signals, converts them into bits, and often applies a “whitening” algorithm (like a cryptographic hash) to remove any bias. Examples include Intel’s RDRAND instruction (which uses thermal noise) and dedicated USB devices like the Quantis (which uses quantum photon effects).
Can Software Ever Be Truly Random?
No, software alone cannot be truly random because it runs on deterministic hardware. However, operating systems can harvest entropy from system events that are practically unpredictable, such as:
- Timing of keystrokes and mouse movements
- Network packet arrival times
- Disk drive seek times
- System interrupt timings
These are not purely deterministic from the user’s perspective, but they are still physical events—so the randomness ultimately comes from hardware. The OS collects these into an entropy pool and uses it to seed a pseudorandom generator. This is how /dev/random on Linux and the Windows Cryptographic API work. They are not “true” in the mathematical sense, but they are unpredictable enough for cryptographic purposes.
Why True Randomness Matters
The distinction is critical in cryptography. If a random number generator is predictable, an attacker can guess encryption keys, session tokens, or lottery numbers. A famous example is the 2012 Android bug where a flawed RNG caused Bitcoin wallets to generate the same private key for many users, leading to theft. True random numbers eliminate this risk because there is no underlying pattern to exploit. They are also used in scientific simulations (Monte Carlo methods), gambling machines, and statistical sampling where bias would invalidate results.
How to Get True Random Numbers on Your Computer
If you need true randomness, you have a few practical options:
- Use a hardware RNG: Buy a USB device like the Quantis or OneRNG, or use a CPU instruction like Intel RDRAND (available on most modern x86 processors). In C, you can call
rdrandvia intrinsics; in Python, you might use theos.urandom()which on many systems uses the CPU’s RDRAND. - Use an online true random service: Websites like random.org use atmospheric noise to generate numbers. They offer APIs for programmatic access.
- Use your webcam or microphone: Some software, like the “Random Number Generator” app, samples the noise in camera pixels or microphone input. This is less reliable but can work.
- Check your OS entropy source: On Linux,
/dev/randomblocks until enough entropy is gathered;/dev/urandomdoes not block but may be less secure in early boot. For most uses,os.urandom()in Python is sufficient.
Common Misconceptions
One common myth is that the random function in programming languages is “random enough” for everything. In reality, Python’s random.random() is a pseudorandom generator (Mersenne Twister) and is not suitable for cryptographic use. Another misconception is that a random number generator can be “fixed” by re-seeding it with the current time. While that helps, the time value is predictable to an attacker who knows when the program started. True randomness cannot be achieved by adding more deterministic inputs.
Frequently Asked Questions
Is RDRAND truly random?
Intel’s RDRAND is based on thermal noise, which is a physical source, so it is considered a true random number generator. However, it also applies a cryptographic whitening algorithm to remove bias, and there has been some controversy about whether the NSA influenced its design. For most purposes, it is safe to use, but some security experts prefer to mix it with other entropy sources.
Can I generate true random numbers with a quantum computer?
Yes, quantum computers can generate true random numbers by measuring the superposition state of qubits. In fact, quantum random number generators (QRNGs) are commercially available and are considered the gold standard for randomness because they rely on fundamental quantum indeterminacy. However, they are not yet common in consumer devices.
Why does my programming language’s random function not give true randomness?
Because it is a pseudorandom number generator (PRNG) that uses a deterministic algorithm. The algorithm is fast and passes many statistical tests, but it is a mathematical function—given the same seed, it produces the same sequence. This is fine for games or simulations, but not for security.
Is atmospheric noise truly random?
Atmospheric noise is caused by natural electromagnetic radiation, which is influenced by lightning and other chaotic processes. It is considered a good source of entropy because it is extremely difficult to predict, but it is not purely quantum. Still, it is used by services like random.org to provide high-quality random numbers.
Can I use my computer’s microphone to generate true random numbers?
Yes, the ambient sound picked up by a microphone contains thermal noise and other unpredictable variations. You can sample the audio signal and extract the least significant bits to get randomness. This works, but it is less reliable than a dedicated hardware RNG because the microphone may pick up predictable patterns (like a fan hum) that need careful filtering.
Related
- What Is Data Max? Meaning, Usage, and Context
- Random in SystemVerilog: How It Works
- COUPDAYS Function in Google Sheets Explained
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Excel yyyy/mm/dd Text: Format and Convert Dates CorrectlyTo show a real Excel date as yyyy/mm/dd, select the cells, press Ctrl+1, choose Number > Custom, enter…
- Microsoft Word Bullet Hanging Indent: Set It CorrectlyIn Microsoft Word, select the bulleted paragraphs, then go to Home > Paragraph dialog launcher > Indents and…
- Excel Power Query: Open It, Import Data, and RefreshIn Excel for Microsoft 365 on Windows, open the Data tab and choose Get Data > Launch Power…
- Shortcut for File Explorer: Best Ways to Open It FastThe fastest shortcut for File Explorer in Windows is pressing Windows + E — it opens File Explorer…
- Data Entry Pay Per Entry: Rates & ExamplesData entry pay per entry typically ranges from $0.01 to $0.50 per record, depending on complexity, volume, and…
- Conditional Formatting Multiple Cells in Excel: RulesYes. In Excel for Microsoft 365, select the cells you want to format, then choose Home > Conditional…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.