Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: TiAddict on June 20, 2011, 11:13:52 am
-
so how does seed work?
what does it do?
EX:
3->rand
-
It's very important to realize that it's extremely hard to ever create a 'random' number in computers. Computers don't do random.
Instead, the next best alternative is creating 'pseudo-random' numbers -- numbers, that on the surface, seem random, but are actually determined by a complex formula.
The seed is the initial value that you are feeding the 'rand' function. The calculator (and all random-number-generators) takes the seed, and feeds it into a complex function that will output a pseudo-random number. It then takes that pseudo-random number and feeds it back into the rand function the next time it is called.
You can exploit this effect: if you constantly store the same seed, the output value will be identical each time.
tl;dr:
You can't do random numbers on computers, instead, you feed a function a seed number, and it transforms that seed into something that's random enough.
(And if I got anything wrong, or am unclear, feel free to point it out :))
-
oh i see... :P i read alot about this in internet, but couldnt really understand. Anyways, thanks for explanation!:D
-
No problem!
-
This is also useful if you are trying to test some encryption program, or a game that uses random values, and you want them to be the same each test in case you are testing a specific bug and you don't know if it's related to the random number generator (RNG) or your code.