1 / 17

Most Random Number

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

vida
Download Presentation

Most Random Number

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Most Random Number • Tom Carter • CSSS • 2004

  2. Here’s a somewhat strange question . . . • What is the most random number between 1 and 1000?

  3. How to go at it? • Let’s try to develop a “probability distribution function” representing some general notion of a “randomness” property for numbers . . . :-)

  4. First guess: everything is normal, right?

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

  6. Error dark-force

  7. Overlay the dark-force on the normal distribution:

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

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

  10. 1/(x/100 + 1)

  11. Normal, with dark-forceand digit overlay

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

  13. 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; end end r = maxrn;

  14. Now we run our function, and there it is, the most random number between 1 and 1000: >> maxrn ans = 347

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

  16. 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; end end r = maxrn;

  17. Summary of most random numbers: • 1 to 10: 7 • 1 to 50: 17 • 1 to 100: 37 • 1 to 500: 173 • 1 to 1000: 347 • 1 to 10,000: 3,479 • 1 to 100,000: 34,799 • 1 to 1,000,000: 347,971

More Related