Who Needs Monkeys?


When you have Richard Dawkins...


Under Construction!


If you see nothing but text above this line, your browser probably doesn't support Java.

Richard Dawkins described this little experiment as an illustration of how the power of Natural Selection cuts across problems of great improbability. It is said that a monkey banging away on the keys of a typewriter, given sufficient time, would eventually reproduce all the works of Shakespeare. This is, of course, the case, as long as one had a sufficiently long-lived monkey and a reliable typewriter. The time involved, however, on balance of probabilities, would be prodigious.

Putting the problem in rather more modern terms, let's say any given character in a string of text can take a value between 0 and 255, with 52 of the values representing the letters of the English language in both upper- and lower case - this is actually exactly the case for the HTML you are reading, although many of the possible characters are gibberish. The probability of the monkey getting the first character of the Shakespearean phrase, "Methinks 'tis like a weasel" correct on the first hit are, therefore, 1/256. The probability of getting two consecutive characters correct in any two hits is the square of this value - (1/256)2.

In this fashion, the chances of getting any string of n characters right by random generation of characters is (1/256)n. n is known as the exponent, and as n increases, the probability diminishes very rapidly indeed. For our target phrase, 27 characters long, the probability of getting it right by chance are (1/256)27, or about 9.5 * 10-66. That's 65 zeroes after the decimal point before you start hitting numbers with any magnitude.

0.00000000000000000000000000000000000000000000000000000000000000000095

This is very, very unlikely indeed. In fact, were it to happen while we were watching, we might be forgiven for believing that our monkey was, in fact, a classicist. Or Richard Dawkins in a monkey suit. Something other than a random text generator, at any rate. Another way to look at it is that if the monkey could type fast enough to enter 27 characters every second, we'd expect him to get it right once in 3.34 * 1057 years. 3,340 followed by 54 zeroes - as against 20,000,000,000 years for current estimates of the age of the Universe. It's not very likely, okay? Stick to the lottery, trust me.

Arguments of mind-buggering improbability are traditionally used by creationists, bless 'em, to attack the idea of evolution as a workable theory. Characterising evolution by Natural Selection as "blind chance", it then becomes easy to convince the unbiased observer that a dog, cat or human could not possibly have arisen by such a process. Indeed, were the characterisation valid, the whole idea of evolution would, truly, be absurd.

Natural Selection, however, is the antithesis of pure chance. To the contrary, it is the means by which chance events are filtered into directional change. Chance mutation is additive, and provides variation on which Natural Selection works. Natural Selection is necessarily subtractive, providing direction via the biased nature of physical survival.

There is a weakness in the argument that Darwin himself recognised, and which creationists have always sought to exploit. This is the necessity for a continuous series of gradual, insensibly small changes between wherever life started out and what it looks like now. Darwin recognised that the necessity of invoking a "macromutation", or "saltation", rendered his theory pointless. If we are permitted hugely improbable jumps from one stage of evolution to another, then why not just postulate the chance assembly of advanced lifeforms in toto? This led him to point out in On the Origin of Species that the theory would collapse utterly if a single case could be identified of a biological structure which could not have arisen by a viable series of less complex structures. If a complex structure is irreducibly complex, in that a partly complete version is completely non-functional, then it cannot be considered to have arisen by natural selection, and we are forced to admit to intentional design.

Michael Behe, in Darwin's Black Box, claims that such structures do, in fact, exist in nature, and that Natural Selection cannot, therefore, explain the origin of complex life. Examples quoted include the flagellum and the immune system. Not being a biochemistry professional, I do not feel qualified to criticise his arguments, and have not in fact seen a convincing criticism from anyone. Therefore, I must admit to agnosticism. The power of Natural Selection as a theoretical mechanism is demonstrable using such gimmicks as my Applet, but if Behe is right about even a single example, then the evolutionists must necessarily be wrong. My money's currently on Darwin, but you never know.

A further point must be made about Natural Selection and probability. Creationists tend to point to the improbability of evolution producing a dog. Would they have remained silent had evolution instead generated a K'Twangi? Of course not. Whatever evolution had produced would look monstrously improbable in retrospect. Thus, my Applet omits a potent aspect of Natural Selection's power. It currently only assesses a candidate string's similarity to a single, preconceived target phrase. Shakespeare, however, wrote 34 entire plays, and that's just the one author. A more realistic example would be a program that selected strings resembling any phrase whatsoever, in any language. A future version will allow multiple target strings, to illustrate this aspect of the power of Natural Selection both to organise and to diversify.

How the Experiment Works

The Applet starts off with a random 'seed' of characters the same length as the target string. (You can enter your own and restart the Applet.) Each character in the string can take any value from 0 to 127 with equal probability (I'm having trouble with the Java byte type, which is interpreted as negative when it exceeds 127 - converting the values so that the differences are calculated correctly has proved so irritating that I decided to drop it for now and use only the positive range!). The Applet then generates 100 "children" from this seed. It does this by walking along the string for each child, and randomly changing a character here and there. The algorithm is such that in each child string, on average one character will be amended upwards and one downwards. This means that the character value is simply incremented or decremented. When all 100 strings have been generated, they are then examined for their deviation from the target string. A value for the deviation is then calculated by taking the sum of the differences between the values of each character. The string with the smallest deviation from the target is then taken as the seed for the next generation, and the process begins again. When a perfect match is found, the program terminates.

Even with the small "population" of children per generation, a match for "Methinks 'tis like a weasel." is typically found within about 800 generations.

More Darwinian Links...

The World of Richard Dawkins - not Dawkins' official site, but a first-rate resource about the man and about neo-Darwinism.

Biomorph Practical - a University practical assignment with some useful links.

Links2Go - a well-organised reference list.

COMPUTER MODELS OF EVOLUTION Another discussion of evolution and its relation to computing, including a large collection of links to related sites.

Evolvica: Evolutionary Algorithms with Mathematica - a University of Calgary page linking to examples of evolutionary algorithms from an IT perspective. Requires MathReader software to decode the algorithms described.

Dawkins' weasel revisited - First published in: Creation Ex Nihilo Technical Journal. A creationist (boo, hiss) site. Demonstrates the lack of understanding of the multiplicity of possible outcomes which I discuss above - the author actually seems to think that specifying a single outcome in advance biases the experiment in favour of natural selection for the target.

Dawkins' Mistake - more creationists! Once again, I believe this discussion misses the point of the Weasel demo, but the author deserves credit for building an Applet while claiming not to like programming! The point, I should add at this juncture, is simply that cumulative selection of slight random variation achieves prodigiously unlikely results, compared with pure chance.