What are RNGs and How are They Used on Computers and Phones?

Random number generators are an often unheralded but crucial component of much of the technology that we use every day.

From shuffling songs to keeping our devices and details safe, randomly generated numbers can make a world of difference.

Some people may choose to express their surprise at bumping into an acquaintance on an unfamiliar street or their surprise when realizing they’re  wearing exactly the same outfit as somebody else by declaring it as “random”. Yet true randomness is very difficult to achieve.

Obviously these hypothetical situations are far from random, with their occurrence driven by a multitude of factors and by outcomes from a finite set of possibilities. But events such as these can certainly seem as if they are bizarre enough to make you pose the question, “what are the chances of that happening?”

Truly random numbers are used in cryptography, which helps to keep our details safe when using technological devices. Computers cannot generate true randomness independently because they are programmed by humans, but computers can take random real-life events such as the timing and length of a certain keystroke to produce true random numbers. This enables files to stay encrypted and browsing to stay secure, as this randomness is not derived by a set algorithm that hackers could access and trace back to the original data.

When listening to music on phones, you may elect to have your experience defined by the shuffle function. Yet most shuffle functions do not select songs in a completely random fashion. A developer at Spotify, Matthias Petter Johansson, attests that their shuffle used to be totally random but drew complaints from users who perceived it to be the opposite. In a fascinating explanation, Johansson attributes this reaction to our underestimation of just how likely it can be for the same song to play twice in a row. Because we are conditioned to expect to get a different song played after the first, when we are faced with repeats it sounds jarring to our minds and therefore sticks out as “not random”. Instead, now the shuffle function aims to spread out artists evenly; if 10% of songs in a playlist are by Bruce Springsteen, then you should expect to hear The Boss in 10% intervals.

However, there are ways in which our phones either use or access randomly generated numbers. In the world of gambling, objectively random numbers are required to grant games impartiality and to ensure that the game does not offer leeway for dishonesty among players. Mobiles can now access many of these games. For example, mobile bingo websites and apps will deploy random number generators to keep their winning outcomes devoid of influence from anything other than preordained algorithms. If these generators are truly random, there is nothing to stop the same winning numbers coming up on consecutive instances.

This might cause consternation for a losing player (and jubilation for a winning player who always chooses the same numbers), because as with the music shuffle, our perception is that the same outcome can’t repeat twice in succession. One notable example of this happening arose in Bulgaria in 2009, where the same six winning numbers featured in consecutive rounds of bingo. A mathematician claimed there was a one-in-four-million chance of this happening, which isn’t so bad considering the chance of winning the lottery in the United Kingdom is one in fourteen million.

Almost all video games rely on randomness to some extent, from the generation of maps to the instruction of movement to background characters. Pokemon is perhaps the most useful example, particularly considering its relatively recent resurgence in popular consciousness. All forms of the game rely on the spawning of creatures, and players are either lucky enough to chance upon that desirable rare one or doomed to be plagued by the most common Pokemon time after time. While certain Pokemon will have a higher chance of spawning in certain areas, there is randomness to their appearances; a player could conceivably come across ten rare creatures in a row, or never see anything other than Pidgeys.

Most of these examples other than cryptography are varying degrees of pseudorandomness rather than randomness if we are to be exact in our definition, but in day-to-day life there is not much difference; such pseudorandom number generators are so complex and intelligent that trained and untrained eyes will not be able to discern whether the outcomes are pure randomness. And as the shuffle conundrum proves, we are not to be trusted anyway when it comes to perceiving randomness.