\documentclass{article}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{slide-article-tom}

\ifx\pdfoutput\undefined
     \usepackage[dvips]{graphicx}
\else
     \usepackage[pdftex]{graphicx}
     \pdfcompresslevel9

\fi

\usepackage{hyperref}

\hypersetup{colorlinks,
            linkcolor=blue,
            %pdfpagemode=FullScreen
            pdfpagemode=None
            }

\def\tthdump#1{#1}

\tthdump{\def\sectionhead#1{\begin{center}{\LARGE\hypertarget{#1}
     {#1}\hyperlink{Our general topics:}{\hfil$\leftarrow$}}\end{center}}}
     
%%tth:\def\sectionhead#1{{\LARGE#1\hypertarget{#1}{#1}}
%%tth:     \special{html: <A NAME="#1"></A><a href="\#Top of file">       Top</a>}}

\tthdump{\def\quotesection#1{\begin{center}{\LARGE\hypertarget{#1}
     {#1}\hyperlink{The quotes}{\hfil$\twoheadleftarrow$}}\end{center}}}
     
%%tth:\def\quotesection#1{{\LARGE#1\hypertarget{#1}{#1}}
%%tth:     \special{html: <A NAME="#1"></A><a href="\#The quotes">       <-</a>}}

%%tth:\def\makehyperlink#1{\special{html: <a href="\##1">}{\large#1}\special{html: </a>}}


\def\pagedone{\newpage}



\begin{document}
\raggedright

\pagestyle{myfooters}
%\pagestyle{plain}

\thispagestyle{empty}

%Slide 1
\title{{\LARGE\bf Most Random Number (just for fun \ldots )} \\
 \dots \\
 \dots \\
  Complex Systems Summer School, Santa Fe}
\author{Tom Carter
\newline
\newline
http://astarte.csustan.edu/\~\ tom/}
\date{June, 2004}


\maketitle



%Slide 2
\sectionhead{Here's a somewhat strange question:}

\begin{center}
     { \Large

                 What is the most random number between 1 and 1000?
}
\end{center}


{
%\large

Okay.  Let me give a little context for this :-)

One of the things I've done over the years is listen to Grateful Dead music, and collect tapes (and now CDs) of live concerts they have played (partly for the weekly live/dead radio show I co-host).

Well, about 15 years ago, I was a participant in a GDead listserv.  One of the members (from Boston) happened to wander by a garage sale, and picked up a box of ``used'' reel-to-reel tapes.  They turned out to be soundboard tapes from Dead shows (in Europe in 1972)!

\pagedone

He, being a bit lazy (but kind), decided to offer to make copies of the tapes for some lucky person (who could then make copies for others, who could make copies, etc.).  So, he announced a contest.

He ``chose a random number'' between 1 and 1000 (as he put it).  Listserv members would have a week to guess the number, and the closest to the number would win.  I, of course, wanted to win the contest.  Hence, my task:

I wanted to maximize my chance of winning.  Thus, what I needed to do was to develop a probability distribution function (pdf) over the numbers from 1 to 1000 that would match his idea of ``random,'' and then just submit the number with the highest probability under my pdf!

Pause for reflection \ldots  Is ``random'' a property a number can have?  Why or why not?  Is there a difference between ``choosing a number at random'' and ``choosing a random number?''


%\thepage
\pagedone

%Slide 3
\sectionhead{How to proceed?}

In essence, what I needed to do was build a ``model'' of his thinking about the world (in particular, of his ideas about ``randomness'').  I only had three pieces of information about him.

\begin{enumerate}

   \item He liked the Grateful Dead (perhaps not much help, but \ldots)
   
   \item His email address (which ended with mail.mit.edu \ldots)
    
   \item He was a late 20th century American (hmmmm \ldots)
  
\end{enumerate}

So.  He was reasonably smart (after all, he liked the Grateful Dead :-).  He was probably relatively ``mathematically literate'' (MIT, and all \ldots).  But, he probably hadn't thought too terribly deeply about questions like ``what does `random' really mean?'' (being a 20th century American, and all :-)  There would likely be a fair amount of unexamined ``everybody knows'' stuff included.

Where to start?  Well, everybody knows (I'll quit with all the scare-quotes -- but remember that they are all through the rest of this :-) that basically everything is normally distributed.  So our initial distribution should be normal.  But, what mean and standard deviation?  Clearly, m = 500, and since basically everything is within about 3 standard deviations of the mean, we should use SD = 167.

\pagedone

Thus, our first attempt looks like this:

\vspace{1cm}

       \centerline{\includegraphics[width = 7in]{normal-500-167}}
       \begin{center}
         Normal distribution (gaussian) with M=500, SD=167
         (normpdf(x, 500, 167))
       \end{center}
       
  That's a start.  But using this pdf, I would just guess 500.  That can't be right \ldots

\pagedone

  After all, anybody who has done any lab work knows that you never hit the value right on, there are always errors!  There is a dark error force in the universe that always keeps you a little away from the actual value.  So we should overlay an error-force distribution:

\vspace{0.5cm}

       \centerline{\includegraphics[width = 7in]{error-force}}
     %  \begin{center}
         (1 - \newline
         normpdf(x, 500, 70)/normpdf(500,500,70))
     %  \end{center}

\pagedone

If we combine these two distributions, we get something like this:

\vspace{1cm}

       \centerline{\includegraphics[width = 7in]{normal-w-error-force}}
    %   \begin{center}
        normpdf(x, 500, 167) \newline
        * (1 - \newline
         normpdf(x, 500, 70)/normpdf(500,500,70)) \newline
          
     %  \end{center}

\pagedone

OK! Now we're getting somewhere :-)

But, we now have two (equal) maxima, so we don't know what to guess.  There must be a bias in one direction or the other, mustn't there?

Aha!  We forgot about Benford's law on the distributions of significant digits.  Benford's law was allegedly discovered by a researcher carrying a book of logarithms (spine down) who noticed that the early pages were dirtier than the later pages -- as though people looked up logarithms of numbers starting with the digits 1 or 2 more often than those starting with 8 or 9.  A general form of Benford's law is that the proportion of numbers starting with the digit $d$ or less will be approximately $log_{10}(d + 1)$ for $d = 1, 2, \ldots , 9.$  Phrased differently, one could say that the probability distribution over first digits looks roughly like $1/(d + 1)$.  (Hmmm.  Is it just a coincidence that we end up with a $1/f$ power law distribution???  Is everything in the universe power law distributed???)

Note:  you can check Benford's law for yourself.  Pick your favorite journal.  Look for numbers representing data.  Tally first significan digits.  See what distribution you get.  (Exercise:  Why does Benford's law hold?) 

Although our deadhead friend may not have studied Benford's law, he probably was fairly observant, and had noticed (possibly unconsciously \ldots) the ``bias'' toward numbers starting with smaller first digits.

So, let's overlay another distribution -- this time a power law, say of the form $1/((x/100) + 1)$ (dividing by 100 to approximately pull out the first digit).
\pagedone

The power law will look like:
\vspace{1cm}

       \centerline{\includegraphics[width = 7in]{first-digit-dist}}
       \begin{center}
        1/((x/100 + 1)
       \end{center}
       
\pagedone

When we overlay, our new distribution will look like:

\vspace{1cm}

       \centerline{\includegraphics[width = 7in]{mrn}}
    %   \begin{center}
        (1/(x/100 + 1)) \newline
        * normpdf(x, 500, 167) \newline
        * (1 - \newline
         normpdf(x, 500, 70)/normpdf(500,500,70)) \newline
          
     %  \end{center}

\pagedone

Well!  We're nearly there \ldots  We (again) have a distribution with a unique maximum (but not the simplistic 500).

Just to be sure, we should do one more thing.  As everybody knows, random numbers don't have any special properties (they're just regular, everyday numbers).  In particular, they probably won't be evenly divisible by a small prime (like 2 or 3 or 5).

So, now let's write some little MatLab functions to put all of this together, and see what we get.

\begin{verbatim}
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);
\end{verbatim}

\pagedone

\begin{verbatim}

function r = maxrn
% search for "most random number" using mrn(x)
maxval = 0;
maxrn = 0;
for n = 1:1000
    if rem(n,2) ~= 0
        if rem(n,3) ~= 0
            if rem(n,5) ~= 0
                if mrn(n) > maxval
                    maxval = mrn(n);
                    maxrn = n;
                end
            end
        end
    end
end
r = maxrn;
\end{verbatim}

\pagedone

So now all we have to do is fire up MatLab, and see what it says:

\begin{verbatim}
>> maxrn

ans =

   347
\end{verbatim}

And there you have it!  The most random number between 1 and 1000 is 347.

But, you ask, how did the contest come out?

Well, I went through the general thought process described above.  Not having Matlab at the time, I just did rough estimates for the various pieces, and did come up with 347.  I submitted that as my entry (less than an hour after the contest started).

About fifteen minutes later, he announced that the contest was ending early, because there was a winner.  I had ``guessed'' his number exactly!

(And the tapes were quite nice :-)


(Exercise:  What can we learn about modeling and probability distributions and the real world from all this, if anything???   :-)

\pagedone

While we're at it, can we extend this to other ranges than 1 to 1000?  Sure, why not.  Here's some MatLab for a more general version:

\begin{verbatim}
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);
\end{verbatim}

\pagedone

\begin{verbatim}

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
        if rem(n,3) ~= 0
            if rem(n,5) ~= 0
                if mrng(n,maxn) > maxval
                    maxval = mrng(n,maxn);
                    maxrn = n;
                end
            end
       end
   end
end
r = maxrn;
\end{verbatim}

\pagedone

We can ask MatLab for some of these values:

\begin{verbatim}
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
\end{verbatim}

*  Interestingly, 17 is also known in some circles as the ``least random number'' \ldots
 
}
\end{document}
