Pseudo-random Vs. Truly-random. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 23

Pseudo-random Vs. Truly-random.

Why is it so important to have truly random generators? Is it not enough to have pseudo-random generators? BTW. Do we have any true-random generators implemented yet?

31st May 2018, 10:34 PM
Amir
Amir - avatar
7 Answers
+ 32
It's usually not important unless you need it to be secure. Pseudo random can produce repeatable patterns, and can even be known what numbers it'll output if you know the starting conditions. So if you're doing random dice numbers for monsters in a video game, it's most of the time fine to have psudeo random. But if you're generating encryption then perhaps you'll need a good randomization method. Yes "true" random generators do exist. There are a few methods (I'm going off of memory here for examples, so they might not be completely correct) like taking in white noise through a microphone, or using quantum qbits. Though if you think the universe is deterministic, then it can be argued those aren't true random either. So if you're trying to secure yourself against universe spanning entities resimulating the entire universe to find your random number, I think you're out of luck.
31st May 2018, 10:59 PM
Ahri Fox
Ahri Fox - avatar
+ 18
Kirk Schafer : Thank you very much. it was really informative🙏🌹
5th Jun 2018, 9:03 AM
Amir
Amir - avatar
+ 8
[only for exploration, not competing for answer] TL;DR: Seeds aren't as helpful as they appear. Prediction: PRNG's generate their next outputs by performing reversible operations on previously-generated values. This is how they are deterministic + why we pick random-ish initial seeds. Some algorithms do this 'worse' than others, like .NET: https://code.sololearn.com/c2UZ8pn0oZPz/ No matter the initial seed, I need only 56 outputs--then 100% sync'd--because later seeds ARE prior public outputs. Reversibility, even when seeds hidden: Although javascript hides its seeds, they're still reversible because the algos 'leak' some seed bits per output; with proper analysis the next number is reliably known after 2-3 priors. Vetting: Naive averages of PRNG's output should hover ~50%: https://code.sololearn.com/WA2TQBOHm0hz/ ...but more sophisticated analyses may reveal repetitions, diagonalization, etc. If you'd like me to link something using more of Random.org's API, please let me know.
4th Jun 2018, 11:40 PM
Kirk Schafer
Kirk Schafer - avatar
+ 6
have a look at https://random.org they have also an API https://code.sololearn.com/W2GRa6bqfo1z/?ref=app the code is incomplete and a bit broken but the part retreiving the random numbers works
3rd Jun 2018, 6:22 AM
seamiki
seamiki - avatar
+ 4
what is NOT random? (veritasium) https://youtu.be/sMb00lz-IfE
4th Jun 2018, 11:44 PM
code learner
code learner - avatar
+ 3
To go more "truly" random, seed your random generator with things like the time, the mouse position, your ping to a server, processor information, the current screen pixels and so on.
3rd Jun 2018, 9:15 AM
Timon Paßlick
+ 3
Search perlin noise for true random number generation.
3rd Jun 2018, 8:30 PM
Haris
Haris - avatar