When people talk about randomness in quantitative development, they usually mean pseudorandomness. Pseudorandom refers to a sequence of numbers or data that appears random but is actually generated by a deterministic, predictable mathematical algorithm making it repeatable if you know the starting point (the seed).
In many financial applications this predictability does not matter. For example, Monte Carlo-based option pricing relies on the statistical properties of the pseudorandom numbers (such as their variance), rather than unpredictability (which they don’t have).
In applications such as cryptography, where predictability is a hurdle, it may be mitigated by setting the seed (relatively) unpredictably, e.g., by using the system clock.
However, the word “relatively” is important here. Predictable random seeds lead to vulnerabilities that can and have been exploited. Think of the (in)famous Netscape pseudorandom generator attack by Ian Goldberg and David Wagner in 1995.
In essence, a pseudorandom generator is a very fast, deterministic machine that looks random if you don’t know how it works. Give it the same starting point (the seed), and it will always produce the same sequence.
Think of it like:
- A very long, scrambled playlist
- Perfectly repeatable if you start from the same track
- Convincing enough that, for most purposes, it feels random
The most common families of PRNGs are:
- Linear Congruential Generators (LCGs)
- These are the pocket calculators of randomness: very old and very simple; easy to implement; extremely fast.
- However, patterns show up quickly if you look closely.
- Think of a rolling die that secretly repeats every few thousand throws.
- Use when speed and simplicity matter more than quality (now mostly obsolete).
- Mersenne Twister
- Dominated scientific computing for over 20 years.
- Huge cycle length (you won’t see repeats for an astronomically long time).
- Produces very even-looking randomness.
- Weak only if you are actively attacking it or doing cryptography.
- Think of a DJ playlist with millions of songs and excellent shuffling – but not encrypted.
- Xorshift / Xoshiro family
- The fast, modern shuffle.
- Designed to be much faster than Mersenne Twister.
- Excellent statistical quality for simulations.
- Small internal state, so good for parallel computing.
- Think of a modern shuffle algorithm tuned for SSDs instead of vinyl.
- PCG (Permuted Congruential Generator)
- Starts with a simple core but adds a clever “scrambling” step.
- Very good statistical behaviour.
- Excellent reproducibility and portability.
- Think of a basic engine with a sophisticated gearbox.
- Cryptographic generators
- These are designed so no one can predict future outputs.
- Are typically much slower.
- Overkill for simulations, essential for security.
- Think of rolling dice inside a vault with armed guards.
Now, which of these are used by NumPy? Originally, NumPy used the Mersenne Twister. Nowadays it’s PCG64 by default – from the PCG family:
- High quality
- Fast
- Stable across platforms
- Excellent for scientific simulation and research
By moving from Mersenne Twister to PCG64 NumPy moved from a “big, old, reliable engine” to a “smaller, cleaner, more modern one.”
PCG64 is a very sensible default. It gives reproducibility (same seed -> same results); simulation safety (fewer hidden patterns); parallel work (better behaviour when many streams are used).
Quasirandomness differs from pseudorandomness in intent and structure: pseudorandom sequences are designed to look random, mimicking the irregularity of true randomness while actually being generated by a deterministic algorithm (as in the generators used by NumPy), whereas quasirandom (or low-discrepancy) sequences are designed to avoid randomness altogether, deliberately spreading points out as evenly as possible over a space. In practical terms, pseudorandomness embraces noise and clumping because that is what randomness does, while quasirandomness suppresses clumping to achieve uniform coverage; this makes quasirandom sequences especially effective for numerical integration and simulation in moderate dimensions, where even coverage reduces error, but unsuitable for tasks that rely on genuine stochastic behaviour, statistical independence, or probabilistic modelling.
True random number generators (TRNGs) work by measuring unpredictable physical processes rather than computing numbers algorithmically: they sample phenomena such as electronic noise, radioactive decay, photon arrival times, thermal fluctuations, or other quantum effects whose outcomes are fundamentally uncontrollable and not reproducible even if you repeat the experiment under the same conditions. The raw physical signal is then carefully digitized, cleaned of bias, and often passed through statistical conditioning to ensure uniformity, but unlike pseudorandom generators, the unpredictability comes from nature itself rather than from a deterministic rule. As a result, TRNGs produce sequences that cannot be regenerated from a seed, making them especially valuable for cryptography, security, and high-assurance systems where predictability—even hidden predictability—is unacceptable.

Leave a Reply