How do computers randomise/shuffle?

655 views

I don’t understand how an algorithm can be truly random

In: Technology

8 Answers

Anonymous 0 Comments

Computers don’t actually use true randomness. They use an algorithm which is actually completely deterministic, but *looks* random, called a pseudorandom number generator, or PRNG. A PRNG takes an inital value, called a seed, and then derives an infinite sequence of values from that initial value.

Because PRNGs are deterministic, reusing the same seed results in the same sequence. Let’s say you have a PRNG, and use zero as your seed, then generate 5 values: 10, 0, 1, 99, 24. After that, you forget the values and start over, seeding with zero again. You’ll get 10, 0, 1, 99, and 24 again, because those 5 random looking values were deterministically derived from the seed.

In order to generate a different set of values, you have to use a different seed. One of the easiest ways to do this is just to use the current time as the seed. This is computer time, not clock time. Computers measure time by counting the number of seconds passed since Jan 1, 1970. Because this number is constantly increasing, PRNGs seeded with the current time will constantly generate new pseudorandom sets.

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