What is a random number and what is the random number generator?

Sungmin in Year 13 looks at random numbers, explaining what they are and how they are relevant to our lives – from encrypted passwords to how games are programmed.

Random number in real life

As public and private data networks proliferate, it becomes increasingly important to protect the privacy of information. Having a random number is one of the steps which can become a core component of the computer to increase the security of the system platform. Random numbers are important for other things – computer games, for example. Random numbers will ensure there are different consequences after making different decisions during a game. The results will always be different because the given input is different. At an arcade, there are many games that rely on randomness. Falling objects fall in different patterns so that no one can anticipate when to catch the object. Otherwise, some people will be able to calculate how an object will fall and the game will no longer be loved by the people visiting arcades. It is interesting that we get some randomness as such.

The examples such as the falling object and computer games both require random numbers in order to be unique. For those games and many other situations that require randomness, private data must be encrypted. To do so, a true random number plays such a significant role and must be used. On the other hand, when we are programming games, both true random number and pseudo-random numbers can be used. As you might have noticed already, there are two types of random numbers. Random numbers are separated depending on how they are generated. One is the true/real random number and the other is the pseudo-random number.

Definitions of ‘random number’

There are several different ways to define the term, ‘random number’. First of all, it is a number which is generated for, or part of, a set exhibiting statistical randomness. Statistical randomness is a characteristic where a numeric sequence is said to be statistically random when it contains no recognisable patterns or regularities.

Secondly, a random number can be defined as a random sequence that is obtained from a stochastic process. A stochastic or random process can be defined as “a collection of random variables that is indexed by some mathematical set, meaning that each random variable of the stochastic process is uniquely associated with an element in the set.”  Moreover, a random number is an algorithmically random sequence in algorithmic information theory. An algorithm is a “process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer”. Also, the sequence which is algorithmically random can be explained as an infinite sequence of binary digits that appears random to any algorithm. The notion can be applied analogously to sequences of any finite alphabet (e.g. decimal digits).

Random sequences are the key object of study in algorithmic information theory. Algorithmic information theory is a merger of information theory and computer science that concerns itself with the relationship between computation and information of computably generated objects, such as strings or any other data structure. Random numbers can also be described as the outputs of the random number generator. In cryptography we define a random number through a slightly different method. We say that the random number is “the art and science of keeping messages secure”.

Different types of random number generators

1:

  • True random number generator (TRNG)
  • Hardware true random number generator (HRNG)

2:

  • Pseudo-random number generator (PRNG)
  • Linear Congruential Generator
  • Random number generator in C++

The major difference between pseudo-random number generators (PRNGs) and true random number generators (TRNGs) is easier to understand if you compare and contrast computer-generated random numbers to rolls of a dice. Since the pseudo-random number generator generates random numbers by using mathematical formulae or precalculated lists akin to someone rolling a dice multiple times and writing down all the outcomes, whenever you ask for a random number, you get the next roll of the dice on the list. This means that there are limitless results produced from the list. Effectively, the numbers appear random, but they are in fact predetermined. True random number generators work by “getting a computer to actually roll the dice — or, more commonly, use some other physical phenomenon that is easier to connect to a computer than is a dice”

Comparisons of PRNGs and TRNGs

As you go about your day today, consider how random numbers are being used to support your daily activities – from the passwords we use, the apps we run on our phones, and the devices and programmes we engage with. Maths is all around us.