Naked Science Forum

General Science => General Science => Topic started by: thedoc on 17/05/2013 09:25:18

Title: How can we prove a number is really random?
Post by: thedoc 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 (http://www.thenakedscientists.com/HTML/podcasts/specials/show/20130517/)

or 

If you want to discuss this show, or ask a question, this is the place to do it.
Title: Re: How can we prove that a number's really random?
Post by: damocles 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.
Title: Re: How can we prove that a number's really random?
Post by: evan_au on 03/05/2013 12:05:45
John von Neumann (http://en.wikiquote.org/wiki/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 (http://en.wikipedia.org/wiki/Hardware_random_number_generator), such as:
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 (http://en.wikipedia.org/wiki/Linear_congruential_generator) 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 (http://en.wikipedia.org/wiki/Linear_congruential_generator#Parameters_in_common_use).

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 (http://en.wikipedia.org/wiki/Randomness_extractor)" process may give the illusion that it is still working properly.
Title: Re: How can we prove that a number's really random?
Post by: chris 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"
Title: Re: How can we prove that a number's really random?
Post by: distimpson 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!
Title: Re: How can we prove that a number's really random?
Post by: RD 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.]
Title: Re: How can we prove that a number's really random?
Post by: chris 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?
Title: Re: How can we prove that a number's really random?
Post by: wolfekeeper 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.
Title: Re: How can we prove that a number's really random?
Post by: evan_au on 05/05/2013 11:59:08
The toughest application of pseudo-random number generators is probably in cryptography.
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:
See: http://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator
Title: Re: How can we prove that a number's really random?
Post by: AndroidNeox 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.
Title: Re: How can we prove that a number's really random?
Post by: damocles 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.
Title: Re: How can we prove that a number's really random?
Post by: CliffordK on 13/05/2013 06:21:32
It might take a fair amount of computing power to calculate something like bf114e6777058e1164c870d68d563ee8.gif 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.
Title: Re: How can we prove that a number's really random?
Post by: dlorde 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... ;)
Title: Re: How can we prove that a number's really random?
Post by: confusious says 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.
Title: Re: How can we prove that a number's really random?
Post by: dlorde 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 (http://www.learner.org/courses/learningmath/data/pdfs/session6/numbers.pdf)).
Title: Re: How can we prove that a number's really random?
Post by: confusious says on 16/05/2013 11:50:48
Interesting, I looked at the link you gave. 8D
Title: Re: How can we prove that a number's really random?
Post by: dlorde 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 (http://telescoper.wordpress.com/2009/04/04/points-and-poisson-davril/)). 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?
Title: Re: How can we prove that a number's really random?
Post by: chris 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
Title: Re: How can we prove that a number's really random?
Post by: AndroidNeox 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.
Title: Re: How can we prove a number is really random?
Post by: damocles 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".
Title: Re: How can we prove a number is really random?
Post by: AndroidNeox 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.

Database Error

Please try again. If you come back to this error screen, report the error to an administrator.
Back