r/computerscience • • Jan 27 '24
How tf do computers generate random numbers?
Hi guys, I’ve been using random number generators lately and I can’t seem to figure out how a computer can generate a random number. Don’t they just do what they’re told? Please explain like im stupid Edit: holy moly this is blowing up
501
Upvotes
View all comments
Show parent comment
112
u/theusualguy512 Jan 27 '24
Apparently according to their website, they weren't the first ones who did it either (Silicon Graphics had seemingly patented it in 1996 but the patent expired).
They mix the lava lamp data with the ones generated from the Linux OS to ensure maximum entropy.
It's generally an interesting rabbit hole to fall into although I honestly do not understand the mathematics behind many of the algorithms for pseudorandom numbers and why they are proven to be mirroring random distributions.
Two popular algorithms for pseudorandom numbers according to Wikipedia seem to be the Mersenne Twister and PCG, Python uses PCG64 by default.