How do random number generators work?

267 views

How do random number generators work?

In: 119

10 Answers

Anonymous 0 Comments

Random number generators don’t generate “truly random” numbers since computers are not able to just make up numbers. They make use of real-world processes (such as the milli- or nanoseconds of the current time, microphone background noise, the current speed or voltage of parts of the hardware, the last time some specific internal file was accessed, combinations of these and anything else that looks unpredictable), that look just random enough for people or programs that use random number generators to work with them. Mathematically speaking, we want good random number generators to fulfill two conditions:

(i) all numbers should have the same chance of being generated whenever the random number generator is used. We want equal probabilities because from a mathematical view, these are very easy to handle and if we ever want certain numbers to have varying probabilities (let’s say, for example, we want the numbers 1 to 10 to have a 5% probability of being generated each, and 11 to have a 50% probability), there are simple ways to build another generator with these probabilities from the first one
(ii) the random number generator is totally unpredictable, that is, no amount of knowledge we obtain should allow us to predict the generated number or even make assumptions about the probability of each number (besides the “all numbers have roughly the same probability” thing from above). In other words, nothing we learn about the random number generator should allow us to say that because of this knowledge, some numbers are now more or less likely to be generated than they would be without.

Technically, no human-made random number generator in this world fully satisfies either of these conditions: since all generators can do is take numbers from “somewhere” in the real world, throw some math at them and give us the results as our desired random number, there are lots of ways in which this process can become flawed and cause one number to become more or less likely than the others (think of a very simple generator that takes the nanoseconds of the current time and returns it as a random number between 0 and 999. There’s no way to guarantee the internal clock isn’t flawed and skips each 999, for example, making 999 impossible to be generated). Realistically, all we can do here is design the generating process really carefully and run tests (i.e. generate a lot of numbers with it and check if each number occurs about as often as the others). Then, in theory, every generator is not just not unpredictable but fully predictable: if we know everything the generator takes into account and the formulas it uses, we’d be able to predict the exact output of our generator. We choose to ignore this problem, however, since on the one hand, generators mostly use data that changes rapidly and frequently (a generator that makes use of nanoseconds could be expected to change internal values every single nanosecond) and it’s nearly impossible for anyone to look at this data fast and often enough (given they know what data to look for and which formulas to apply to that data in the first place), and on the other hand, this simply can’t be avoided. In theory, every generator made by humans is fully predictable and all we can do is to make the process of predicting the results of a generator as hard as possible

You are viewing 1 out of 10 answers, click here to view all answers.