Viraj Patel


Having completed the Computational Physics module last term, I wanted to investigate further into the importance of random numbers in physics and how true random numbers can be generated. In this article, I will discuss the main types of random numbers and their applications in physics.

There are many areas of physics that employ the use of randomness, especially in Computational Physics, an area that specialises in simulating physical processes as realistically as possible. In statistical physics and quantum physics, many processes are believed to be stochastic, so mathematical and computational models must be treated as such [1]. The main issue that we face today is: are these random numbers that we generate random enough? We are currently facing this issue in quantum computing, as scientists are trying to find ways to improve the security of encryption algorithms. One of the most common cracking techniques exploits the fact that computer generated random numbers can be backtracked to find the encryption key [2].

Figure 1: A Gaussian random walk (Source:
Pseudo random numbers

You are probably most familiar with pseudo random numbers. These are a sequence of numbers with very little correlation, and there are many algorithms that can achieve this. The most basic one being a linear congruential generator (LCG):

    \[I_{n+1}=(aI_n+b)\cdot \textrm{mod}\,m\]

This is an iterative function where the “mod” operation is the (modulo) remainder operation. The constants a and b are chosen by the system, and the initial value I_0 is known as the seed. The biggest issue with the LCG is that, at best, it repeats every m iterations. Setting m to a very large number reduces the effect of this problem, but can cause the generator to run slowly for larger sequences [3].

The Mersenne Twister (MT) is a better pseudo random number generator than the LCG. It is widely used in programming and is, in fact, the default random number generator in Python and R. Rather than purely using mathematical operations, as in the LCG, the MT algorithm uses bitwise logic operators:

\bigoplusBitwise exclusive-or (XOR)
&Bitwise AND
\llbShift bits to the left by b
\ggbShift bits to the right by b

Manipulating the binary representation of a number causes less correlation and a larger degree of recurrence, n. The algorithm is as follows:

    \[x_{k+n} = x_{k+m} \oplus\, (x_k^u|x_{k+1}^l)A\]

In this equation, x_{k+1}^l is the rightmost r (arbitrary constant) bits of x_{k+1}, x_k^u is the leftmost w-r (w is the number of bits to represent a number) bits, the pipe symbol represents concatenation, and A is a matrix defined as follows:

    \[xA = \begin{Bmatrix} x\gg1, & x_0=0\\ (x\gg1)\oplus a, & x_0=1 \end{Bmatrix}\]

where a is the bottom row of A [4]. This algorithm has been made in such a way that, if given a 32-bit number, it cannot output the subsequent 32-bit number, which leads to a very high degree of unpredictability [5].

Pseudorandom numbers might seem pointless, given that they are periodic and the sequence can be determined from the seed (starting value(s)). However, for the purpose of simulation, these properties are desirable. If one needed to compare different simulations of the same stochastic process, a fair test would require all simulations to have the same input. True random number sequences can’t be reproduced, but pseudorandom sequences can.

True random numbers

As discussed previously, pseudorandom numbers aren’t truly random, just very uncorrelated. Pseudorandom number generators (PRNGs) use mathematical and logical operations to generate numbers that may be used to simulate a stochastic physical process. In contrast, true random number generators (TRNGs) use measurements of real physical processes as random numbers [6].

These physical processes can vary from the time between keystrokes by a user of a device, to a radioactive decay. In fact, radioactive decays are used quite often as they are completely unpredictable and they can be easily detected. Another, very creative, TRNG is called LavaRnd, which uses the random motion of lava lamps to produce random numbers, it also happens to be one of the most secure random number generators that is used in cryptography [7]. Although these methods are useful, they require expensive and extensive apparatus to detect and make measurements. There are cheaper methods that still use the entropy of natural phenomena. One of the most common methods measures atmospheric noise using a simple radio. The disadvantage of this is that the fan from the device you may be working on can cause periodic (yet predictive) variations in atmospheric noise, reducing the randomness of the sample.

Another common method used by physicists is laser-based generation. There are different ways to produce laser-based generators, one is having two photons race each other, with the faster one representing the chosen value of a binary random number generator. Photons travel at the speed of light but may have slight variations in their speed due to the environment they are in, which is purely random. Physicists have also generated random numbers by measuring the varying intensity of a chaotic laser, with this generator being one of the fastest random number generators available [8].

The benefit of using true random numbers lies in what they are used for. In Monte Carlo processes, it is common to use a Maxwell-Boltzmann distribution to draw pseudorandom numbers from. To do this, the computer will have to perform some intermediate steps to convert a uniform distribution into the desired distribution. If the computer was able to draw measurements from a thermodynamic system, not only would these numbers be truly random, but they would automatically follow the Maxwell-Boltzmann distribution [9].


We have discussed the two main types of random numbers: pseudorandom numbers and true random numbers. There are some more types of random numbers but they generally fall into one of these two categories. For example, quasi-random numbers can be classified as pseudorandom and quantum random numbers are just true random numbers generated by measurements of a quantum system. Despite pseudorandom numbers being periodic, we found that this could help for simulations, but could pose as threats to cybersecurity. Moreover, true random numbers cannot be reproduced, but they are also difficult and often expensive to generate in the first place. Random numbers and randomness have many applications to other areas of physics, including complexity science, and it will be interesting to see how we can improve random number generating algorithms and processes in the future.


[1] N. Metropolis, “The Beginning of the Monte Carlo Method,” Los Alamos Science, no. Special, pp. 125-130, 1987.

[2] N. Metropolis, “The Beginning of the Monte Carlo Method,” Los Alamos Science, no. Special, pp. 125-130, 1987.

[3] D. D. Johnson and D. M. Ceperley, “Generation of Random Numbers,” 2001. [Online]. Available: [Accessed 14 January 2022].

[4] A. Jagannatam, “Mersenne Twister – A Pseudo Random Generator and its Variants,” George Mason University, Department of Electrical and Computer Engineering, 2008.

[5] M. Shema, Hacking Web Apps, Newnes, 2012.

[6] M. Haahr, “Introduction to Randomness and Random Numbers,” June 1999. [Online]. Available: [Accessed 26 January 2022].

[7] LavaRnd Number Generator, “LavaRnd,” 2000. [Online]. Available: [Accessed 26 January 2022].

[8] D. F. DiCarlo, “Random number generation: Types and Techniques,” 2012.

[9] Y. Ilan, “Generating randomness: making the most out of disordering a false order into a real one,” Journal of translational medicine, vol. 17, no. 1, pp. 1-12, 2019.

Inline Feedbacks
View all comments