The Naked Scientists

The Naked Scientists Forum

Author Topic: How does a computer generate a random number?  (Read 1901 times)

Offline bizerl

  • Sr. Member
  • ****
  • Posts: 279
    • View Profile
How does a computer generate a random number?
« on: 15/02/2013 04:15:08 »
Or how does my ipod decide what order to play songs when I "shuffle"?

Is it truly "random" or is there always a pattern?


 

Offline CliffordK

  • Neilep Level Member
  • ******
  • Posts: 6321
  • Thanked: 3 times
  • Site Moderator
    • View Profile
Re: How does a computer generate a random number?
« Reply #1 on: 15/02/2013 06:31:21 »
Most computers will use some type of a pseudorandom number generator

The key is to get a "seed" such as the time of the clock that would be different, and not produce the same starting point every time the program is restarted.  Or, perhaps, remember the last number accessed in the sequence.

For an IPOD, a true random number may not be an issue.

There is a concern that games of chance with money involved, such of state lotteries could be compromised by poorly written pseudorandom number generators.
 

Offline evan_au

  • Neilep Level Member
  • ******
  • Posts: 4091
  • Thanked: 243 times
    • View Profile
Re: How does a computer generate a random number?
« Reply #2 on: 15/02/2013 09:42:01 »
Humans are very good at seeing patterns where there is no pattern.

With the iPod, early versions selected the next song truly at random (in software) - but sometimes a truly random selection will play the same song twice in a row, or (even more likely) twice in the same hour. People complained, and so the song selection was made less random, by avoiding recently played songs, which perversely made people feel that it was more random! You can now select the degree of randomness that you want. http://electronics.howstuffworks.com/ipod-shuffle2.htm

There are severe limitations of software random number generators;  computer pioneer John von Neumann said that "Anyone who considers arithmetical methods of producing random digits is, of course, in a state of sin."

Intel is designing a hardware random number generator into new CPUs, which will make it effectively impossible to predict the next random number without hacking the computer. http://spectrum.ieee.org/computing/hardware/behind-intels-new-randomnumber-generator/0
« Last Edit: 15/02/2013 20:41:12 by evan_au »
 

Offline RD

  • Neilep Level Member
  • ******
  • Posts: 8122
  • Thanked: 53 times
    • View Profile
Re: How does a computer generate a random number?
« Reply #3 on: 15/02/2013 14:14:30 »
some computers use thermal noise to generate truly random numbers ...
http://en.wikipedia.org/wiki/Hardware_random_number_generator
 

The Naked Scientists Forum

Re: How does a computer generate a random number?
« Reply #3 on: 15/02/2013 14:14:30 »

 

SMF 2.0.10 | SMF © 2015, Simple Machines
SMFAds for Free Forums