DEV Community

Discussion on: Explain how a Random number is generated Like I'm Five

Collapse
 
nektro profile image
Meghan (she/her) • Edited

Why true random number can't be generated?

Because computers are designed solely to do simple task over and over again in a very predictable matter. But that's exactly the problem. It's not random if it predictable.

What we make instead is called a pseudorandom number generator. These are wild algorithms that generate "random" outputs. However, they are still algorithms and with the same input will always have the same output. To combat this, many PRNGs "seed" the algorithm with almost unpredictable data like the time or the angle of the device from the gyro.


Quantum processors bring about the potential for "truly" random number generators, but we don't really know because we don't know a lot about quantum physics, and it depends on the knowability of sub-atomic information.