17
Most Random Number Tom Carter CSSS 2004

Most Random Number

Embed Size (px)

DESCRIPTION

Most Random Number. Tom Carter CSSS 2004. Here’s a somewhat strange question. What is the most random number between 1 and 1000?. How to go at it?. - PowerPoint PPT Presentation

Citation preview

Page 1: Most Random Number

Most Random Number

Tom CarterCSSS2004

Page 2: Most Random Number

Here’s a somewhat strange question . . .

What is the most random number between 1 and 1000?

Page 3: Most Random Number

How to go at it?

Let’s try to develop a “probability distribution function” representing some general notion of a “randomness” property for numbers . . . :-)

Page 4: Most Random Number

First guess: everything is normal, right?

Page 5: Most Random Number

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.

Page 6: Most Random Number

Error dark-force

Page 7: Most Random Number

Overlay the dark-force on the normal distribution:

Page 8: Most Random Number

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?

Page 9: Most Random Number

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

Page 10: Most Random Number

1/(x/100 + 1)

Page 11: Most Random Number

Normal, with dark-forceand digit overlay

Page 12: Most Random Number

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.

Page 13: Most Random Number

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;

Page 14: Most Random Number

Now we run our function, and there it is, the most random number between 1 and 1000:

>> maxrnans = 347

Page 15: Most Random Number

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.?

Page 16: Most Random Number

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;

Page 17: Most Random Number

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