what really happens when we put Math.random()
I have always listened that random numbers are not truly random, they are something pseudo-random.
Why true random number can't be generated?
what really happens when we put Math.random()
I have always listened that random numbers are not truly random, they are something pseudo-random.
Why true random number can't be generated?
For further actions, you may consider blocking this person and/or reporting abuse
Can you help us make DEV a better place?
Fill out this survey and help us by becoming a tag moderator here at DEV.
Eugene Cheah -
Nathan Tamez -
Edwin Mak -
Sarthak Sharma -
Once suspended, itsjzt will not be able to comment or publish posts until their suspension is removed.
Once unsuspended, itsjzt will be able to comment and publish posts again.
Once unpublished, all posts by itsjzt will become hidden and only accessible to themselves.
If itsjzt is not suspended, they can still re-publish their posts from their dashboard.
Once unpublished, this post will become invisible to the public and only accessible to Saurabh Sharma.
They can still re-publish the post if they are not suspended.
Thanks for keeping DEV Community π©βπ»π¨βπ» safe. Here is what you can do to flag itsjzt:
Unflagging itsjzt will restore default visibility to their posts.
Top comments (2)
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.
To add to what @nektro said, there are pseudorandom number generators (PRNG) and cryptographically secure RNGs (CSRNG).
The main difference being in non-CS RNGs, you can usually spot a repeating pattern. See this article. (Took me forever to find that again.)
The only way to get really random numbers is to have a random input. For instance, random.org uses atmospheric whitenoise measurements as its random input.
On computers without access to physical phenomena the OS collects whatever "noise" it has access to and uses that. For instance /dev/random on linux uses timings from device drivers, keyboard, and other stuff as its random input.