Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/19/03 12:32
Read: times


 
#43762 - RE: Random Number ( in software)
Responding to: ???'s previous message
The pseudo random generator you posted DOES generate random numbers between 0...255. It does not pretend to be truely random, that's why it's called a PSEUDO random generator! Nothing in your controller is truely random (otherwise your controller would probably be useless :-). You will have to look for something external which is if you want to have true random. One thing which is for all sakes and purposes true random for instance is the time between powering up your controller and the first buttonpush the user makes. If you time that, you get a real random number (I think that's what Dennis is referring to). Actually, this is a common way to initialize a pseudo random number generator. This action is called "seeding" the pseudo random generator.
If you want really, really random, you could consider an analog noise generator with an A/D converter.
So:
- Seed your pseudo random generator with a free running timer the first time the user causes *anything* to happen.
- If you want real random, look for an external, analog solution. Any digital solution is BOUND to use the same basic PSEUDO random approach.

Also it might pay off to learn a little about statistics, most noteably probability distribution. I believe the pseudo random generator has even distribution, but depending on what you want to do you might need other kinds of distribution, like triangular or gaussian.

List of 17 messages in thread
TopicAuthorDate
Random Number ( in software)            01/01/70 00:00      
   RE: Random Number ( in software)            01/01/70 00:00      
      RE: Random Number ( in software)            01/01/70 00:00      
   RE: Random Number ( in software)            01/01/70 00:00      
   RE: Random Number ( in software)            01/01/70 00:00      
      RE: Random Number ( in software)            01/01/70 00:00      
   RE: Random Number ( in software)            01/01/70 00:00      
   RE: Random Number ( in software)            01/01/70 00:00      
   RE: Random Number ( in software)            01/01/70 00:00      
   RE: Random Number ( in software)            01/01/70 00:00      
      RE: Random Number ( in software)            01/01/70 00:00      
      RE: Random Number ( in software)            01/01/70 00:00      
         RE: Random Number ( in software)/ Hans            01/01/70 00:00      
            RE: Random Number ( in software)/ Hans            01/01/70 00:00      
   RE: Random Number ( in software)/ERIC            01/01/70 00:00      
      RE: Random Number ( in software)/ERIC            01/01/70 00:00      
         RE: Random Number ( in software)/            01/01/70 00:00      

Back to Subject List