Has anyone looked for shakespeare in random digits?

While browsing the digits of pi will eventually get you to Hamlet, it’s often overlooked that before you get there you’ll have to read zillions of bastardized versions: a version where Hamlet poisons his mother, a version where Hamlet turns his back on Denmark and sails off to discover America, and even a version where after “To be or not”, Hamlet forgets his woes, and recites an essay about monkeys and typewriters.

Well, you really don’t know that all those versions would come before the canonical one, now do you? You might get lucky.

When my father was a student, his classroom had blackboards all around it, on all four walls. A fellow student asked the teacher what infinity was. The teacher started drawing a line on one blackboard and continued it around all four walls. When he got to a window, he threw the chalk out, and said “Infinity.”

I don’t think that’s a good explanation, but it’s given my father a good story to tell lo these past 60 years.

I think a more interesting thought experiment on the nature of randomness than monkeys with typewriters is this:

You could fairly easily write a computer program that would cycle each pixel on your monitor (well, technically in memory) through all the colours it can display, and write the images to a hard drive.

The hard drive would have to be huge. Also you’d want to have a fast computer and a lot of time, like a few billion years or something. But the number of possible images is unarguably finite.

By the time it reached the end of the program, it would have created all possible images that can be represented on your monitor. That is, it would have randomly generated every frame of every movie and TV show ever made, every work of art ever created, every page of every book ever written, and a high-resolution colour picture of you kissing Hitler on the lips while both of you are balancing on unicycles. And that same picture taken from 360 different angles.

You could reduce the scope of the project by producing only 8-bit colour or gray-scale or lower resolution images. Maybe you could finish it off in a few thousand years? You’d still have to take a look at all the saved images and see which ones are interesting and which ones are junk. You could probably have some software help with that too though.

Not to mention a bunch of old Pauly Shore scripts.

A few thousand years is such a huge underestimate of the time needed, even with those simplifications, that a comparison between it and the correct answer is inconceivable to human minds. And recognizing interesting images out of the output of this thing is exactly as difficult as producing interesting images from scratch.

Obligatory old computing joke…

source: alt.math.recreational

You are underestimating the scope of this project.

Let’s take a fairly low-resolution image, about 400x400 pixels, and 8-bit color. This is about 0.16 megapixels, with 256 possible colors for each pixel. Something like this, probably a little grainier.

The total number of possible images is 256^(400 * 400) = 256^160000 - there are 160,000 pixels, and each pixel can be one of 256 possible colors.

That is 2.48 × 10^385318 possible images. Even if you had a purpose-built computer that could produce one possible image per clock cycle (so about 3 billion images per second), it would take about 10^385300 years to generate every possible image. For comparison - a billion years is 10^9, and a trillion years is 10^12. We’re talking about a long time.

Even for a 100x100 image, in 4-bit grayscale (so, 16 possible shades of gray), which is a tiny, grainy little postage-stamp sized thing, it would still take about 16^(100*100) = 2 * 10^12000 years to iterate all possible images.

I was underestimating how much I was underestimating! We’d better get to work! Can you run the numbers again, but this time with 2 computers, working in tandem? :wink:

Maybe if we could get our hands on an infinite number of computers…

The “million monkeys typing Shakespeare” thought experiment is frequently used by Creationist types to “disprove” evolution, in the same way as the “tornado assembling a Boeing 747 in a junkyard” one: something as complex as a human (or a literary masterpiece or an aircraft) arising through pure chance is HIGHLY unlikely, therefore someone or some thing must have helped it along. Of course, the rebuttal to this is that life didn’t proceed randomly once it began - natural selection results in a lot of the “junk” getting tossed out pretty quickly, and the useful stuff sticking around much longer.

I believe the purpose of Jesse Anderson’s experiment was to illustrate this rebuttal - he showed that by keeping the “good” bits and tossing out the “junk” bits in a process that at least superficially models natural selection, the seemingly impossible task of reproducing Shakespeare from random strings of letters actually becomes pretty doable. Note that Anderson used units of 9-letter strings, which would correspond to the string of nucleotides necessary to code for a chain of 3 amino acids. It’s true he ignored spaces, punctuation, etc, but then again the genetic alphabet his experiment was analogous to only has 4 letters, each “word” is only 3 letters long and most “words” can be spelled several different ways. Also, there are only about 2 dozen “words” (20 AAs, plus the stop codon, poly-A tails, etc) in the language.

I’ll put on a pot of coffee then…

tdn writes:

> When my father was a student, his classroom had blackboards all around it, on
> all four walls. A fellow student asked the teacher what infinity was. The teacher
> started drawing a line on one blackboard and continued it around all four walls.
> When he got to a window, he threw the chalk out, and said “Infinity.”
>
> I don’t think that’s a good explanation, but it’s given my father a good story to
> tell lo these past 60 years.

Forty years ago or so someone at college told me approximately the same story. His story was that a student asked what infinity was. The teacher, without saying anything, started drawing a line which went around the room on the various blackboards and walls until he reached a window. He continued the line so that it went outside the window, stepping out of the window (on the ground floor) and then along the outside wall, where he continued the line around a corner and disappeared from the view of the students. He didn’t return during that class.

The next day scheduled for that class, a few minutes into the class period, he suddenly stepped back into the classroom through the window, continuing to draw that line on the other side of the window, so he could continue to draw on the blackboards until he reached the point where the line started. He stopped when he reached the beginning of the line. (The line hadn’t been erased in the meantime.) He threw down the chalk on the blackboard tray and said, “And if you did that forever, that would be infinity.”

In other words, I think this is an urban legend.

It only took a few quadrillion years after all, but this image, emailed to me from the far future, is the first one to resolve from the pi sequence as something recognizable. The search continues.

Astonishing!

For the sake of argument, let’s say we have the maximum number of computers possible in even the most extreme circumstances imaginable. How about if every single particle in the known universe was a computer running in parallel. Call it 10^87 computers, all running at 3 billion images per second as in Absolute’s example.

Even for the easiest problem, the 100 x 100 x 4-bit grayscale, your universe-wide parallel computer would still take around 2 * 10^11913 years.

Now I know what my PC is doing while I’m waiting for it to boot up. :stuck_out_tongue:

Some other more probable outputs. Which I think nicely illustrates the level of improbability we’re talking about.

FWIW reading the third item on that list makes me giggle like a schoolgirl.

I always consider 2[sup]80[/sup] to be nearly infinity. You’re never going to run thru all possible combinations of 80 bits on a feasible amount of hardware running at a feasible speed in a feasible amount of time. But you can take 2[sup]100[/sup] as being really, really close to infinity for all practical purposes if you want.

If you were to generate just lower case letters and nothing else, each letter being the equivalent of about 4.7 bits, then 17 letters is about the same as 80 bits (and 27+ letters as 100 bits).

You can’t even get a soliloquy in that few letters, let alone a whole play.

Trying to generate a significant chunk of Shakespeare randomly a letter at a time is ridiculous and then some.

So, you think it would take a while?

Typo: Make that last one 21+ letters.

Here are the first 5,000 digits of pi, expressed in base 26, under the substitution 0 -> A, 1 -> B, … 25 -> Z. (Thank you, Mathematica.) I wasn’t able to find any English words longer than four letters via quick inspection, but maybe other folks have sharper eyes than I do.