Most Random Number
description
Transcript of Most Random Number
Most Random Number
Tom CarterCSSS2004
Here’s a somewhat strange question . . .
What is the most random number between 1 and 1000?
How to go at it?
Let’s try to develop a “probability distribution function” representing some general notion of a “randomness” property for numbers . . . :-)
First guess: everything is normal, right?
Too simple. We do get a unique maximum at 500, but that can’t be right.
As everybody knows, you never get the actual data value. There are always “errors” that push you away from the real value.
So, we should overlay a repelling “error dark-force” on top.
Error dark-force
Overlay the dark-force on the normal distribution:
Now we’re getting somewhere!
But, we don’t have a unique maximum any more.
There must be a bias in one direction or the other, mustn’t there?
Aha! We forgot about Benford’s law on the distribution of significant digits.
One form of Benford’s law says that on average, the proportion of numbers having first digit less than d will be about log(d+1) for d = 1, 2, . . ., 9.
Another way to say this is that the distribution will be approximately 1/(d+1), so we’ll overlay a power law
1/(x/100 + 1)
Normal, with dark-forceand digit overlay
Now we’re almost done. We have a single maximum, and it is not the simplistic 500.
One more piece. Random numbers must not have “special properties,” right?
So, they probably won’t be divisible by small primes like 2 or 3 or 5.
Let’s write a couple of small MatLab functions for all this.
function r = mrn(x)%"most random number" function :-)r = (1/((x/100) + 1)) * (1 - normpdf(x, 500, 70) normpdf(500,500,70)) * normpdf(x, 500, 167);
function r = maxrn% search for "most random number" using mrn(x)maxval = 0;maxrn = 0;for n = 1:1000 if rem(n,2) ~= 0 & rem(n,3) ~= 0 & rem(n,5) ~= 0 & mrn(n) > maxval maxval = mrn(n); maxrn = n; endendr = maxrn;
Now we run our function, and there it is, the most random number between 1 and 1000:
>> maxrnans = 347
What about more general versions of this?
In other words, what about the most random number between 1 and 10, 1 and 100, 1 and 10000, etc.?
function r = mrng(x,maxn)%"most random number" function :-)r = (1/((10*x/maxn) + 1)) * (1 - normpdf(x, maxn/2, 0.07*maxn)/normpdf(maxn/2,maxn/2,0.07*maxn)) * normpdf(x, maxn/2, maxn/6);
function r = maxrng(maxn)% search for "most random number" using mrng(x,maxn)maxval = 0;maxrn = 0;for n = 1:maxn if rem(n,2) ~= 0 & rem(n,3) ~= 0 & rem(n,5) ~= 0 & mrng(n,maxn) > maxval maxval = mrng(n,maxn); maxrn = n; endendr = maxrn;
Summary of most random numbers:
1 to 10: 71 to 50: 171 to 100: 371 to 500: 1731 to 1000: 3471 to 10,000: 3,4791 to 100,000: 34,7991 to 1,000,000: 347,971