Society of Robots - Robot Forum
Software => Software => Topic started by: airman00 on June 29, 2008, 08:41:46 AM
-
I understand how hardware based "random" number generators work but can someone please explain to me how software-based generators work. I've looked it up but I don't really understand it , can someone please explain it.
and I am not talking about having a list of random numbers and then picking from that list, im talking about a mathematical algorithm that produces a number that seems to be "random"
and I am definitely not talking about this: (http://imgs.xkcd.com/comics/random_number.png) :D :D
-
Some of them are based on the system clock.
-
Some of them are based on the system clock.
I understand that , but that is considered hardware based
How does a random number generator mathematical algorithm work?
-
there is no such thing as a software random number generator.
numbers generated by software will be pseudorandom numbers. what this means is all the numbers are part of a sequence. given enough numbers, the sequence will emerge. think of it as a very long period (i'm talking about the math thing at fractional numbers). it might be very long, but after a while, it repeats.
to start every time at a different position, a "seed" or initial value is used. starting a timer on your microcontroller, waiting for a "start" key, and using the timer value as an input is a pretty good initial seed.
the basic pseudorandom generators are called linear feedback shift registers. think of them as a function that has an input, does some xoring, shifting (actually, it's barrel shifting) and a bunch of more logical operations on that input, and then returns it as an output. if you pass it again, you will get another pseudorandom value. if you pass it sufficient times, a pattern will emerge.
a true random number generator for 8 bits value will not generate any pattern after an infinite number of calls.
this (http://www.cryogenius.com/hardware/rng/) is a nice design i plan on using someday. it's based on reverse avalanche noise generated by an inverse polarised pn junction. i believe a diode will work equally well.
-
I have used the pseudo-random number generator - the results are reasonable and the code is simple -
http://inglorion.net/software/deadbeef_rand/
-
Thank you , I understand now