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?

770 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

This depends on the implementation.  The non-secure way was to use a number that’s always changing, like the current time, as a “seed” then perform operations on that number repeatedly to generate new numbers.  The output is predictable if you know the seed number, but as long as the seed number is truly random, it’s considered “good enough.”  The problem of course is that using the current time doesn’t meet the bar for “good enough,” so it’s not really suitable in situations where you need truly random outputs.

Producing a truly random seed number is the real trick here.  Some systems have sources of randomness (Linux has /dev/random) that read things like electrical signals from hardware to generate random numbers, but the quality of said outputs is debatable and system specific.  You can also use things like camera outputs.  Going further, there are dedicated hardware systems that use anything from electrical measurements to radiation measurements in the presence of fissile material.

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