# The Naked Scientists Forum

### Author Topic: How can we prove a number is really random?  (Read 9953 times)

#### thedoc

• Sr. Member
• Posts: 502
• Thanked: 11 times
##### How can we prove a number is really random?
« on: 17/05/2013 09:25:18 »
We were discussing on the radio today how random numbers are generated, and how could it be proved - to the satisfaction of a mathematician - that the number really is random? Evan Stanbury explains...
Listen to this Show

or

If you want to discuss this show, or ask a question, this is the place to do it.
« Last Edit: 17/05/2013 10:26:28 by chris »

#### damocles

• Hero Member
• Posts: 756
• Thanked: 1 times
##### Re: How can we prove that a number's really random?
« Reply #1 on: 03/05/2013 11:48:19 »
Truly random numbers can only be generated by radioactive decay or some such mechanism. The computer algorithms only produce pseudo-random numbers. These are tested for randomness -- an equal probability for each number, within a statistically determined variance, and no theoretical reason why any particular sequence should be absent. Some computer algorithms even allow you to set the first seed, so that you can reproduce the same pseudo-random sequence again, but it is more usual to use a clock reading as the first seed.

#### evan_au

• Neilep Level Member
• Posts: 3942
• Thanked: 226 times
##### Re: How can we prove that a number's really random?
« Reply #2 on: 03/05/2013 12:05:45 »
John von Neumann, computer pioneer said:
Quote
Any one who considers arithmetical methods of producing random digits is, of course, in a state of sin.

Using predictable circuits (such as we want to use in a computer) always produces a predictable result - if you know the program and the inputs to the program.

To generate "truly" random numbers you need a "non-predictable" hardware circuit, such as:
• measuring the voltage of a Zener diode, which generates random noise
• quantum effects like measuring the rate of radioactive decay
• using a number of unstable circuits, like a ring oscillator
• measuring the "shot noise" as single electrons travel through a semiconductor
• recording the instants in time that someone types a character on a computer keyboard
• recording the instants in time that a computer disk returns data to memory
Some operating systems collect a pool of random numbers from operating system events that people can dip into when they need to generate an unknown encryption key for a new https: session, or are running a simulation, for example. The risk is that if users demand a lot of randomness (eg for running a large simulation) but are contributing little randomness, the pool will run dry. So many applications dip into the pool for a "seed", but then generate their own random numbers.

Some new computer chips have hardware to generate random numbers built in (like 3 above), which will help them generate an unlimited supply of random numbers for these purposes.

Most computer languages have a built-in random number generator which is purely software. This depends on having a "random" seed, and then repeatedly applying a program which modifies it to produce a new number which looks quite different from the previous number (and which can be mathematically proved to be randomly different in every bit position). A good random number generator will not generate the same sequence of numbers for a very long time.

One of the more traditional arithmetic methods takes a starting seed number X0, and applies the formula Xn+1=(Xn*A + C) modulo M
By carefully selecting the numbers A, C and M (eg they must be relatively prime), it is possible to quickly generate a sequence which does not repeat for billions of numbers, and passes many tests for randomness - unless you happen to know A, C and M.

There are schemes which combine two or more random number generators in a table of numbers to make a sequence which will not repeat within the lifetime of the Earth.

To ensure that the numbers collected from many sources appear more random, some schemes scramble the numbers they generate. Unfortunately, if the random number generator source suddenly stops generating new random numbers (eg your Zener diode short-circuits), this "whitening" process may give the illusion that it is still working properly.
« Last Edit: 04/05/2013 02:07:04 by evan_au »

#### chris

• Neilep Level Member
• Posts: 5293
• Thanked: 61 times
• The Naked Scientist
##### Re: How can we prove that a number's really random?
« Reply #3 on: 03/05/2013 12:59:29 »
A reply sent to me from the programme in question by Reenen Laurie:

"In terms of random numbers… It is a whole field of study, and random numbers are never truly random*.  Even rolling dice in theory could be deterministic, if you can account for all the physics. Similarly computerised random numbers are called pseudo-random, as most random number generators works with a seed, meaning that if you insert the same seed, you will have the exact same sequence.

Measuring if they are “random enough” is done just by rolling your dice several million times, and seeing if you have a fairly (but not perfect) even distribution among your results.

*: a very simple almost truly random way is to take the current time at nano second level (or lower) and take that as your number between 0-1, other more sophisticated ways include listening to radio static, thermal noise etc. though those could have a bias depending on the surrounding environment.

Regards,
-Reenen"

#### distimpson

• Sr. Member
• Posts: 118
##### Re: How can we prove that a number's really random?
« Reply #4 on: 03/05/2013 22:27:31 »
A very deep question, lot of great answers here. I've done a few simulations using computer generated “pseudo-random” numbers and the Monte Carlo method at Los Alamos many years ago. We needed a random number with a Gaussian distribution and we had a uniform random number generator over the region 0 to 1. So we added 6 of these together to get an approximation to a Gaussian distribution by way of the central limit theorem. The ends of the distribution are cut off at 0 and 6 but for many purposes it worked just fine.  It was easy enough to test the numbers for mean, standard deviation, correlation or whatever parameters might be important in the simulation and insure they were “random enough” for the problem at hand. Of course there are built in functions in many math packages that do this now, yes I am that old, started out using punch cards. Thought this might be of interest here, my rather old 2 cents worth!

#### RD

• Neilep Level Member
• Posts: 8085
• Thanked: 51 times
##### Re: How can we prove that a number's really random?
« Reply #5 on: 04/05/2013 04:28:50 »
There's an app for that ...

http://www.fourmilab.ch/hotbits/

http://www.random.org/

http://www.random.org/randomness/

[ "random" = outcome is determined by unfathomably complex mechanism.]
« Last Edit: 04/05/2013 04:40:42 by RD »

#### chris

• Neilep Level Member
• Posts: 5293
• Thanked: 61 times
• The Naked Scientist
##### Re: How can we prove that a number's really random?
« Reply #6 on: 04/05/2013 10:41:14 »
Thanks for the great answers so far.

I'm now looking for someone to record me a short answer for the radio to explain this and also to demonstrate who we can prove, to the satisfaction of a mathematician, that a generated number sequence really is random.

Can anyone help or volunteer?

#### wolfekeeper

• Neilep Level Member
• Posts: 1092
• Thanked: 10 times
##### Re: How can we prove that a number's really random?
« Reply #7 on: 04/05/2013 16:35:06 »
It's very difficult.

One notable test is Kolmogorov randomness:

http://en.wikipedia.org/wiki/Kolmogorov_complexity#Kolmogorov_randomness

Pretty sure you can never prove numbers to be random, the best you can do is find a pattern in the numbers that prove they aren't!

(That's basically what the Kolmogorov complexity test is for, if you can write a short program to generate the numbers then you've found a pattern and it's not random.)

Also compression, if you can compress it, then it's not random.

And of course for any finite length, occasionally a random sequence will appear to be non random!

(But that gets less likely for longer sequences.)

Incidentally, it's theorised that quantum mechanical processes can give truly random results, but extreme care needs to be exerted to avoiding accidentally biasing the number, and to exclude external interference from radio and similar.
« Last Edit: 04/05/2013 16:39:49 by wolfekeeper »

#### evan_au

• Neilep Level Member
• Posts: 3942
• Thanked: 226 times
##### Re: How can we prove that a number's really random?
« Reply #8 on: 05/05/2013 11:59:08 »
The toughest application of pseudo-random number generators is probably in cryptography.
• "Alice" has to use a sequence of apparently random numbers to modify a message that has to be transmitted securely, often using the Exclusive-Or (XOR) function.
• The receiver, "Bob" has to use exactly the same sequence of numbers in the same sequence to modify the message back into readable form, using XOR.
• In this case, the numbers used by Alice can't be truly random, as Bob needs exactly the same numbers, so a pseudo-random number sequence is actually desirable.
An intruder reading this message sees it as an incomprehensible sequence of random numbers. However, if they know the algorithm generating the numbers, and the starting seed, they will be able to read the message too. If they think that the message is valuable, they will spend a lot of money and computing time on "cracking" the code, and trying many possible seeds.

This produces some tougher requirements on pseudo-random number generators:
• The sequence of pseudo-random numbers must be at least as long as the sum of all possible messages without repeating, as any repeats in the number sequence helps in breaking the code.
• There must not be any detectable patterns in the number sequence, as this helps in cracking the code
• It may be possible to determine part of the pseudo-random sequence by sending a known file over an encrypted link. However, knowing this part of the number sequence must not allow determination of the internal state of the algorithm, or the next or previous numbers in the sequence.
• You should assume that any intruder knows the encryption algorithm (or can get a copy by reading the computer hard disk or stealing a device which implements the algorithm)
• Installing spyware on a computer may allow determining the internal state of the algorithm and all future states, but should not allow determining any previous states.
See: http://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator
« Last Edit: 05/05/2013 12:13:21 by evan_au »

#### AndroidNeox

• Sr. Member
• Posts: 240
• Thanked: 1 times
##### Re: How can we prove that a number's really random?
« Reply #9 on: 12/05/2013 23:37:26 »
Whether randomness exists is a metaphysical question that I've yet to see addressed, convincingly. The best we can do is unpredictable sequences of maximal entropy (no identifiable pattern). Even perfectly well defined sequences can be effectively random. E.g. if you started listing the digits of pi, beginning with the 100 trillionth digit... the sequence would appear random to anyone who didn't realize the source of the info.

#### damocles

• Hero Member
• Posts: 756
• Thanked: 1 times
##### Re: How can we prove that a number's really random?
« Reply #10 on: 13/05/2013 05:22:14 »
Whether randomness exists is a metaphysical question that I've yet to see addressed, convincingly. The best we can do is unpredictable sequences of maximal entropy (no identifiable pattern). Even perfectly well defined sequences can be effectively random. E.g. if you started listing the digits of pi, beginning with the 100 trillionth digit... the sequence would appear random to anyone who didn't realize the source of the info.

I think you are very close to answering your own question, Android. Take the example of the 100 trillionth digit of pi and work from there. For anyone who did not know the secret of how the random sequence was generated, it would appear "random". But in fact it is highly ordered. On the other hand if you came up with a random sequence of digits (of finite size) then you might think that it is not truly random because you recognize a sequence of digits from the decimal expansion of pi beginning with the 66,542,013,278,934th. So ultimately the question is an epistemological one rather than a metaphysical one. Of course there are metaphysical aspects in the generation of random numbers -- it would be difficult to argue against the fact that the last digit of the microsecond timer of reception of a gamma ray from the decay of U-238 was not properly random, for theoretical reasons.

#### CliffordK

• Neilep Level Member
• Posts: 6321
• Thanked: 3 times
• Site Moderator
##### Re: How can we prove that a number's really random?
« Reply #11 on: 13/05/2013 06:21:32 »
It might take a fair amount of computing power to calculate something like to the some very long digit sequence.  But there would be no shortage of irrational numbers that one could calculate to a long digit sequence.  Perhaps a bit more complex if one wanted multi-digit numbers, although I suppose with zeros in the sequence, one could just say take 10 digit blocks from your decimal expansion of your favorite irrational number.

Now, the original question was:
"How can we prove that a number's really random?"

There is no random test for a single number.

I've heard a single random number be compared to an uninteresting number.

Say you wanted to find the first uninteresting number between 0 and 1000.
Certainly one would exclude 0, 1, 2, & 3.
Perhaps exclude all prime numbers.
Exclude all multiples of 5 & 10.
Also exclude multiples of 11.

Anyway, once you find the first uninteresting number....
Well, being the first uninteresting number is something, isn't it?
Better exclude that one too.

As far as random numbers, the number ONE could be just as valid of a random number as any other number in the range.  The only way to demonstrate randomness then would be with a sequence, and not a specific number.  And, if you exclude certain numbers because they just don't look random, then you are introducing a bias into the system, something that could be very bad with something like the lottery.

#### dlorde

• Neilep Level Member
• Posts: 1441
• Thanked: 9 times
• ex human-biologist & software developer
##### Re: How can we prove that a number's really random?
« Reply #12 on: 13/05/2013 14:36:46 »
Anyway, once you find the first uninteresting number....
Well, being the first uninteresting number is something, isn't it?
Better exclude that one too.
That way, we end up with no uninteresting numbers at all, which is interesting... ;)

#### confusious says

• Jr. Member
• Posts: 38
##### Re: How can we prove that a number's really random?
« Reply #13 on: 14/05/2013 21:20:00 »
You cannot prove that a number is really random, if someone picks out a numbered card from a pack, that is not random, because whoever shuffled the pack, left them in a certain order, however chaotic, and the person picking out a card does this in some kind of order, wether it be the top, the bottom, the middle or somewhere inbetween. A computer cannot randomly select a number, because it has to start it's next random shuffle from a set point, which is the point it stopped at on the previous random selection. I suppose the more random tries before a random selection might allow you to gaining a more random number, but in reality it is still not random.

#### dlorde

• Neilep Level Member
• Posts: 1441
• Thanked: 9 times
• ex human-biologist & software developer
##### Re: How can we prove that a number's really random?
« Reply #14 on: 14/05/2013 21:44:41 »
You cannot prove that a number is really random, if someone picks out a numbered card from a pack, that is not random, because whoever shuffled the pack, left them in a certain order, however chaotic, and the person picking out a card does this in some kind of order, wether it be the top, the bottom, the middle or somewhere inbetween. A computer cannot randomly select a number, because it has to start it's next random shuffle from a set point, which is the point it stopped at on the previous random selection. I suppose the more random tries before a random selection might allow you to gaining a more random number, but in reality it is still not random.
You could equally well say that since a random number can take any value, all the methods you mention give as-good-as-random numbers.

Which suggests that randomness is more to do with sequences. There's no way to tell one number is random, but you can estimate the probability of a sequence being random by looking at value frequency, distribution, etc. People seem to be poor intuitive judges of of it, preferring homogeneity over the sequences and duplications of genuine randomness (see Perceived & Real Randomness).

#### confusious says

• Jr. Member
• Posts: 38
##### Re: How can we prove that a number's really random?
« Reply #15 on: 16/05/2013 11:50:48 »
Interesting, I looked at the link you gave. 8D

#### dlorde

• Neilep Level Member
• Posts: 1441
• Thanked: 9 times
• ex human-biologist & software developer
##### Re: How can we prove that a number's really random?
« Reply #16 on: 16/05/2013 15:28:36 »
There's quite a few articles like that out there. One shows two squares, one scattered with dots at random, and one with correlations between the dots that make them appear relatively smooth and homogeneous. Most people, when asked to select the random square, see the clumps and squiggles of dots in the random one and so pick the square with the smoother distribution insead (see Points & Poisson). The author says "The point about random processes, even simpler ones like repeated tossing of a coin, is that coincidences happen much more frequently than one might suppose". This goes some way to explaining why so many people believe the coincidences they encounter in daily life have paranormal significance - they seriously underestimate the expected frequency of those coincidences.

What're we like, eh?
« Last Edit: 16/05/2013 15:36:52 by dlorde »

#### chris

• Neilep Level Member
• Posts: 5293
• Thanked: 61 times
• The Naked Scientist
##### Re: How can we prove that a number's really random?
« Reply #17 on: 17/05/2013 09:10:17 »
Thanks to Evan, who submitted a lovely piece of audio to make his case.

I played this on 702 / 567 CapeTalk in South Africa this morning, and we've published it as a "specials" podcast out today - http://www.thenakedscientists.com/HTML/podcasts/specials/show/20130517/

Chris

#### AndroidNeox

• Sr. Member
• Posts: 240
• Thanked: 1 times
##### Re: How can we prove that a number's really random?
« Reply #18 on: 24/06/2013 00:36:55 »
So ultimately the question is an epistemological one rather than a metaphysical one.

Isn't metaphysics concerned with the nature of causality? If reality is perfectly causal then there are no random numbers... merely unpredictable sequences.

#### damocles

• Hero Member
• Posts: 756
• Thanked: 1 times
##### Re: How can we prove a number is really random?
« Reply #19 on: 24/06/2013 03:32:26 »
So ultimately the question is an epistemological one rather than a metaphysical one.

Isn't metaphysics concerned with the nature of causality? If reality is perfectly causal then there are no random numbers... merely unpredictable sequences.

If by "perfectly causal" you mean that physical laws may only be definitive rather than probabilistic, then you are quite correct. You are, however, flying in the face of the usual Copenhagen view of quantum theory. I guess that in interpreting it as an epistemological question my emphasis was more on the word "unpredictable".

#### AndroidNeox

• Sr. Member
• Posts: 240
• Thanked: 1 times
##### Re: How can we prove a number is really random?
« Reply #20 on: 24/06/2013 20:06:29 »
The Copenhagen Interpretation is dependent upon concepts, like simultaneity, that have no physical reality (action at a distance). Also, all science is dependent upon the assumption of causality... when physics discarded causality we should have realized we'd gotten off track. We should have realized that observation doesn't alter the observed. Observation alters the observer. All physics is local. All observable reality is purely causal.

It's probably time we discard the Copenhagen Interpretation. Quantum mechanics is our first scientific theory developed without any physical model. It's was intended as a means to calculate the probability of observing a specific outcome. To get that, the result had to be normalized, forced to to yield a probability. I have often wondered if the pre-normalized result describes populations of outcomes rather than probability of one outcome.

All the problems/weirdness of QM and its incompatibility with relativity can be eliminated by multiverse cosmologies. They explain all the observations of QM in terms of local processes... no instantaneous effects over distance.

#### The Naked Scientists Forum

##### Re: How can we prove a number is really random?
« Reply #20 on: 24/06/2013 20:06:29 »