How does a computer program generate random numbers? Example: when you ask Siri to give you a random number between 1 to 10, how does it come up with that number?

742 viewsMathematicsOther

How does a computer program generate random numbers? Example: when you ask Siri to give you a random number between 1 to 10, how does it come up with that number?

In: Mathematics

18 Answers

Anonymous 0 Comments

Usually it’s done using a Pseudo Random Number Generator (PRNG). This algorithm takes a number as input and outputs another seemingly unrelated and usually irreversible number.

However, this algorithm isn’t inherently random, as the same input will always produce the same output, so you need to start the algorithm with a number you trust to be random enough (called a seed) such as the current time with millisecond precision, the current temperature of the CPU, camera noise, the position of the mouse cursor or a combination of all of those.

Then, the previous result of the PRNG is fed back into it, generating a sequence of numbers that looks completely random.

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