1

How does a computer generate 'random' numbers?

How close to truly 'random' can a number generated by a computer actually be?

Is there software / programming language out that that might generate a more 'truly random' number than others?

ruben_KAI
  • 199
  • 3
  • 11
  • http://stackoverflow.com/questions/3996904/generate-random-integers-between-0-and-9 – Leo Chapiro Oct 07 '14 at 15:06
  • This question seems borderline off-topic. The second part for sure, is far better suited for StackOverflow than SuperUser. – Ajedi32 Oct 07 '14 at 15:43
  • 1
    As was commented below, this question [How are pseudorandom and truly random numbers different and why does it matter?](http://superuser.com/q/712551/820) answers the randomness question very completely. – heavyd Oct 07 '14 at 16:21

1 Answers1

4

Many common implementations of random number generators, are not truly random. Computers typically utilize Pseudorandom Number Generators, which means the computer uses a defined algorithm to generate a sequence of numbers that appear to be random.

In Python you can use the random module to generate pseudorandom numbers. However, if you look at the docs, they include this note:

Warning The pseudo-random generators of this module should not be used for security purposes. Use os.urandom() or SystemRandom if you require a cryptographically secure pseudo-random number generator.

heavyd
  • 62,847
  • 18
  • 155
  • 177
  • 4
    @duDE, only half of the question is off-topic. I think the other half is completely on-topic and an interesting question. – heavyd Oct 07 '14 at 15:14
  • 1
    Related SU question: [How are pseudorandom and truly random numbers different and why does it matter?](http://superuser.com/questions/712551/how-are-pseudorandom-and-truly-random-numbers-different-and-why-does-it-matter?rq=1) – Ƭᴇcʜιᴇ007 Oct 07 '14 at 16:16