3

This question may not be language specific.

  • Is it possible to create a true random number ?
  • If not why random number generation has to go through some algorithm, why garbage values cannot act as random numbers.
jjnguy
  • 136,852
  • 53
  • 295
  • 323
Xinus
  • 29,617
  • 32
  • 119
  • 165

5 Answers5

19

It can. Depending on your definition of a random number:

You can never be sure
(source: dilbert.com)

In most applications, what you expect from a random number generator is to generate a sequence of numbers that are uniformly distributed. A garbage value does not provide this characteristic.

Is it possible to create a true random number?

If you define "truly random" as unpredictable, the question is "unpredictable by what?"

There are cryptographically secure (pseudo-)random number generators that try to hide the state of the random number generator from user-level code, that is, ideally, only kernel mode code can feasibly predict the next random number.

However, an isolated computer system (without any external input) is a deterministic finite state machine. That is, by knowing the current state of the machine, you can always predict the next state. So, if you mean "unpredictable" by a software system in general, no, you can't use a deterministic system to generate "true randomness" according to this definition.

There's another kind of unpredictability that is more philosophical. Even if you rely on external input (such as atmospheric noise or other means), are they really unpredictable? One might argue that we live in a deterministic world and like a digital computer, everything is determined to happen; so, there's no randomness. I don't have an answer for that.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Mehrdad Afshari
  • 414,610
  • 91
  • 852
  • 789
  • However, it could be used as an input for the seed at certain timespans. Like, seed every x minutes wiuth some garbage. – Dykam Sep 20 '09 at 11:47
  • 4
    Our world is not 100% predictable due uncertainty principle. You may measure something to predict its future behavior, but during that measurement you change that thing a little, so its future not precisely predictable after measurement. – actual Sep 20 '09 at 12:38
  • 1
    actual: I didn't claim world is predictable. I said "I don't have an answer for this case." As far as I know, there is a claim that the uncertainty in the quantum phenomena can be a result of a "cause" that we don't know of. We just see the effect and consider it random. – Mehrdad Afshari Sep 20 '09 at 12:52
  • 1
    @actual: That is not a problem. We want to predict what's actually going to happen, not predict what would have happened if you wouldn't have tried to predicted what will happen. – Guffa Sep 20 '09 at 13:23
  • @Guffa: We don't have data on hands to do that. In some sense, measurements required for precise prediction are always one step behind the things. – actual Sep 20 '09 at 20:56
  • 1
    @actual: While we can still gather noise from various sources (and there is hardware to do so) to get "true" random numbers, it still is very messy. That's because you may have unpredictability of the exact value, but the noise is still biased. Thermal noise for example varies in color (i.e. the distribution of frequencies within) – it's not automagically white. So you still have to eliminate bias in order to use them and a significant part of dedicated hardware goes exactly into that. It's not as trivial as you may think. – Joey Jan 26 '11 at 10:24
4

By "garbage values" I presume you mean uninitialized memory. You're not going to get good distribution, and more importantly you're going to get a lot of sequences of repeated values. Getting thousands of the same number in a row would be pretty useless for most applications that require random numbers.

For a number to be a "true random number", it would have to be non-deterministic. And since pretty much everything is (probably) deterministic, there really is no such thing as a random number. Mixing of atmospheric noise is probably the closest you can get at this point.

Gerald
  • 23,011
  • 10
  • 73
  • 102
1

Garbage values are unpredicted, and you can't make any assumptions on them.

If you want a true random number, your algorithm would have to involve some "real-world" variables (e.g, the CPU temperature, fan speed, environmental noise..). Otherwise, your "random" values, would be very predictable.

1

There is no known "true" random number generator (as of now), but we do have pseudo random number generators, which generate number which can act as random numbers for "practical" purposes.

Mahesh Velaga
  • 21,633
  • 5
  • 37
  • 59
  • You can't do it in software, but sampling thermal noise, or nuclear decay is random. So we have true hardware random number generators. – Douglas Leeder Sep 20 '09 at 11:56
  • There are certainly other sources of random numbers than pseudo random numbers. For cryptography you need random numbers that are not pseudo random. An interesting example of random numbers can be found at http://www.lavarnd.org/. – Martin Liversage Sep 20 '09 at 12:00
  • "Some physical phenomena, such as thermal noise in Zener diodes appear to be truly random and can be used as the basis for hardware random number generators. However, many mechanical phenomena feature asymmetries and systematic biases that make their outcomes not truly random."
    I was looking at the practically implementable things .. :)
    – Mahesh Velaga Sep 20 '09 at 12:06
  • Thanks for the link Martin, I was in security field, In my college I did my honors in security lab. In cryptography we use pseudo random generators which generate strings(which are practically indistinguishable from random string) from a seed. Correct me if I am wrong :) – Mahesh Velaga Sep 20 '09 at 12:11
1

Computers are deterministic and can only generate pseudorandom numbers, unless they rely on some external stochastic process.

A pseudorandom number generator forms a sequence, which sooner or later is going to repeat.

Of course, very long sequences may be practically indistinguishable from 'truly random' numbers.

A 'garbage value' might be used to seed a random number generator, but then the question would be 'what range of values are being used for a seed?

It may introduce predictability, since we know some pseudorandom number generators produce the same sequence when seeded identically.

pavium
  • 14,808
  • 4
  • 33
  • 50