Are random numbers really random?

Jathavan Mahendrarajah
2 min readJul 10, 2021

‘Random’ means unpredictable. Because of the unpredictable nature of random numbers, we use them in cryptography, statistics, gaming, art, gambling and in many other areas. We use randomness as a method of fairness or impartiality and even in decision making. Rolling an unbiased die, flipping a coin, pulling a red or blue marble out of a jar are such so called random acts. What if we could predict the randomness?

*How random numbers generated in computer science?

A main difference between humans and computers is randomness. No matter how it tries, a computer cannot achieve randomness( we are not going into how our brains deal with randomness). Computers use 2 basic types of algorithms for random number generation.

Pseudo Random Number Generator (PRNG)

This refers to an algorithm which uses a mathematical function to generate a sequence of numbers which approximate the properties of random numbers. eg: Linear Congruential Generator

Xn+1 = (aXn + c) mod m
where X is the sequence of pseudo-random values
m, 0 < m - modulus
a, 0 < a < m - multiplier
c, 0 ≤ c < m - increment
x0, 0 ≤ x0 < m - the seed or start value

python source code of random generator:

https://github.com/python/cpython/blob/3.9/Lib/random.py

python docs:

https://docs.python.org/3/library/random.html

you can see the warning message in python docs saying that you cant use math.random() function for security purposes.

Pseudo random numbers are initially generated from Mandelbrot sets. Now there are many algorithms to generate them.

True Random Number Generator (TRNG)

TRNG generate true random numbers. They are much related to hardware. By measuring random fluctuations known as noise present in nature we can truly generate random numbers. Physical factors such as atmospheric and thermal conditions are taken into account for generating numbers. These are cryptographically secure numbers.

“For all of nature’s wonder and beauty, it is also hostile and unpredictable”

- Liam Neeson

--

--