### Author Topic: "Random" Number Generator  (Read 2508 times)

0 Members and 1 Guest are viewing this topic.

#### airman00

• Contest Winner
• Supreme Robot
• Posts: 3,650
• narobo.com
##### "Random" Number Generator
« 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"

Check out the Roboduino, Arduino-compatible board!

www.Narobo.com

#### ahab

• Jr. Member
• Posts: 18
##### Re: "Random" Number Generator
« Reply #1 on: June 29, 2008, 10:08:29 AM »
Some of them are based on the system clock.

#### airman00

• Contest Winner
• Supreme Robot
• Posts: 3,650
• narobo.com
##### Re: "Random" Number Generator
« Reply #2 on: June 29, 2008, 10:17:20 AM »
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?
Check out the Roboduino, Arduino-compatible board!

www.Narobo.com

#### izua

• Supreme Robot
• Posts: 682
##### Re: "Random" Number Generator
« Reply #3 on: June 29, 2008, 11:13:06 AM »
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 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.
« Last Edit: June 29, 2008, 11:14:22 AM by izua »
Check out my homepage for in depth tutorials on microcontrollers and electronics.

#### hgordon

• Expert Roboticist
• Supreme Robot
• Posts: 373
##### Re: "Random" Number Generator
« Reply #4 on: June 29, 2008, 11:15:15 AM »
I have used the pseudo-random number generator - the results are reasonable and the code is simple -

Surveyor Corporation
www.surveyor.com

#### airman00

• Contest Winner
• Supreme Robot
• Posts: 3,650
• narobo.com
##### Re: "Random" Number Generator
« Reply #5 on: June 29, 2008, 12:30:46 PM »
Thank you , I understand now
Check out the Roboduino, Arduino-compatible board!