Stick a monkey on a typewriter, let him hit keys all day, and what will you get? Gibberish, probably. But what if you’re prepared to wait longer than a day? Much longer than a day. Infinitely long, say. In that case, the monkey will produce the complete works of Shakespeare. And indeed any and every other work of literature that’s ever been written.

This is from Wikipedia:

The infinite monkey theorem states that a monkey hitting keys at random on a typewriter keyboard for an infinite amount of time will almost surely type any given text, such as the complete works of William Shakespeare.

Infinity is a tricky but important concept in mathematics generally. We saw the appearance of infinity in a recent post, where we looked at the infinite sequence of numbers

1, 1/2, 1/4, 1/8,….

and asked what their sum would be. And it turned out to be 2. In practice, you can never really add infinitely many numbers, but you can add more and more terms in the sequence, and the more you add the closer you will get to 2. Moreover, you can get as close to 2 as you like by adding sufficiently many terms in the sequence. It’s in this sense that the sum of the infinite sequence is 2.

In Statistics the concept of infinity and infinite sums is equally important, as we’ll discuss in a future post. But meantime… the infinite monkey theorem. What this basically says is that if something can happen in an experiment, and you repeat that experiment often enough, then eventually it will happen.

Sort of. There’s still a possibility that it won’t – the monkey could, by chance, just keep hitting the letter ‘a’ totally at random forever, for example – but that possibility has zero probability. That’s the ‘almost surely’ bit in the Wikipedia definition. On the other hand, with probability 1 – which is to say complete certainty – the monkey will eventually produce the complete works of Shakespeare.

Let’s look at the calculations, which are very similar to those in another recent post.

There are roughly 50 keys on a keyboard, so assuming the monkey is just hitting keys at random, the probability that the first key stroke matches the first letter of Shakespeare’s works is 1/50. Similarly, the probability the second letter matches is also 1/50. So to get the first two matching it’s

$1/50 \times 1/50$

Our monkey keeps hitting keys and at each new key stroke, the probability that the match-up continues is multiplied by 1/50. This probability gets small very, very quickly. But it never gets to zero.

Now, if the monkey has to hit N keys to have produced a text as long as the works of Shakespeare, by this argument he’ll get a perfect match with probability

$p=(1/50)^N$

This will be a phenomenally small number. Virtually zero. But, crucially, not zero. Because if our tireless monkey repeats that exercise a large number of times, let’s say M times, then the probability he’ll produces Shakespeare’s works at least once is

$Q = 1-(1-p)^M$

And since p is bigger than zero – albeit only slightly bigger than zero –  then Q gets bigger with N. And just as the sum of the numbers 1, 1/2, 1/4, … gets closer and closer to 2 as the number of terms increases, so Q can be made as close to 1 as we like by choosing M large enough.

Loosely speaking, when M is infinity, the probability is 1. And even more loosely: given an infinite amount of time our monkey is bound to produce the complete works of Shakespeare.

Obviously, both the monkey and the works of Shakespeare are just metaphors, and the idea has been expressed in many different forms in popular culture.  Here’s Eminem’s take on it, for example:

# A day in the life

Over the next few weeks I’m planning to include a couple of posts looking at the way Statistics gets used – and often misused – in the media.

First though, I want to emphasise the extent to which Statistics pervades news stories. It’s everywhere. But we’re so accustomed to this fact, we hardly pay attention. So, I chose a day randomly last year – when I first planned this post – and made a note of all the articles that I came across which were based one way or another on Statistics.

In no particular order….

Article 1: An analysis of the ways the economy had been affected to date since the Brexit referendum.

Article 2: A report in your super soaraway Sun about research which shows 40% of the British population don’t hold cutlery correctly. (!)

Article 3: A BBC report about a study into heart defects and regeneration rates in Mexican tetra fish which may offer clues to help reduce heart disease rates in humans.

Article 4: A report showing that children’s school performance may be affected by their exact age on entry.

Article 5: A report into the rates of prescriptions of anti-depressants to children and the possible consequences of this.

Article 6: A survey of the number of teenage gamblers.

Article 7: A report on projections of the numbers of people who could be affected by future insulin shortages.

Article 8: A report on a study that suggests children’s weights are not driven by patterns of parental feeding, but rather the opposite: parents tend to adapt feeding patterns to the natural weight of their children.

Article 9: A comparison of football teams in terms of performance this season relative to last season.

Article 10: Not really about statistics exactly, but a report showing that the UK’s top-paid boss is Denise Coates, the co-founder of Bet365, who has just had a pay-rise of ￡265. Inludes a nice graphic showing how her salary has risen year-on-year.

Article 11: Report on a study showing failure rates of cars in MOT tests due to excessive emission rates.

Article 12: A report into an increase in the rate of anti-depressant prescriptions following the EU referendum.

Article 13: A report on rates of ice-melt in Antartica that suggest a sub-surface radioactive source.

Article 14: A report suggesting rats are getting bigger and what the implications might be.

Article 15: An explanation of algorithms that can distinguish between human and bot conversations.

Article 16: A report suggesting that global internet growth is slowing.

So that’s 16 articles in the papers I happened to look at on a random day. Pretty sure I could have picked any day and any set of papers and it would have been a similar story.

Now here’s a challenge: choose your own day and scan the papers (even just the online versions) to see how many stories have an underlying statistical content. And if you find something that’s suitable for the blog, please pass it on to me – that would be a great bonus.

When I was a kid I went on a school exchange trip to Germany. For some reason we had a lesson with our German hosts in which we were asked to explain the meaning of the Beatles’ ‘A Day in the Life’….

Embarrassingly, I think I tried to give a  literal word-by-word interpretation. But if I’d known then what I know about Statistics now, I think I could probably have made a better effort.

Here are the lyrics from one of the verses…

Ah I read the news today, oh boy
Four thousand holes in Blackburn, Lancashire
And though the holes were rather small
They had to count them all
Now they know how many holes it takes to fill the Albert Hall

# Nul Points

No doubt you’re already well-aware of, and eagerly anticipating, this year’s Eurovision song contest final to be held in Tel Aviv between the 14th and 18th May. But just in case you don’t know, the Eurovision song contest is an annual competition to choose the ‘best’ song entered between the various participating European countries. And Australia!

Quite possibly the world would never have heard of Abba if they hadn’t won Eurovision. Nor Conchita Wurst.

The voting rules have changed over the years, but the structure has remained pretty much the same. Judges from each participating country rank their favourite 10  songs – excluding that of their own country, which they cannot vote for – and points are awarded on the basis of preference. In the current scheme, the first choice gets 12 points, the second choice 10 points, the third choice 8 points, then down to the tenth choice which gets a single point.

A country’s total score is the sum awarded by each of the other countries, and the country with the highest score wins the competition. In most years the scoring system has made it possible for a song to receive zero points – nul points – as a total, and there’s a kind of anti-roll-of-honour dedicated to countries that have accomplished this feat. Special congratulations to Austria and Norway who, despite their deep contemporary musical roots, have each scored nul points on four occasions.

Anyway, here’s the thing. Although the UK gave the world The Beatles, The Rolling Stones, Pink Floyd, Led Zeppelin, David Bowie, Joy Division and Radiohead. And Adele. It hasn’t done very well in recent years in the Eurovision Song Contest.  It’s true that by 1997 the UK had won the competition a respectable 5 times – admittedly with a bit of gratuitous sexism involving the removal of women’s clothing to distract judges from the paucity of the music. But since then, nothing. Indeed, since 2000 the UK has finished in last place on 3 occasions, and has only twice been in the top 10.

Now, there are two possible explanations for this.

1. Our songs have been terrible. (Well, even more terrible than the others).
2. There’s a stitch-up in the voting process, with countries penalising England for reasons that have nothing to do with the quality of the songs.

But how can we objectively distinguish between these two possibilities? The poor results for the UK will be the same in either case, so we can’t use the UK’s data alone to unravel things.

Well, one way is to hypothesise a system by which votes are cast that is independent of song quality, and to see if the data support that hypothesis. One such hypothesis is a kind of ‘bloc’ voting system, where countries tend to award higher votes for countries of a similar geographical or political background to their own.

This article carries out an informal statistical analysis of exactly this type. Though the explanations in the article are sketchy, a summary of the results is given in the following figure. Rather than pre-defining the blocs, the authors use the data on voting patterns themselves to identify 3 blocs of countries whose voting patterns are similar. They are colour-coded in the figure, which shows (in some vague, undefined sense) the tendency for countries on the left to favour countries on the right in voting. Broadly speaking there’s a northern Europe group in blue, which includes the UK, an ex-Yugoslavian bloc in green and a rest-of-Europe bloc in red. But whereas the fair-minded north Europeans tend to spread their results every across all countries, the other two blocs tend to give highest votes to other member countries within the same bloc.

But does this mean the votes are based on non-musical criteria? Well, not necessarily. It’s quite likely that cultural differences – including musical ones – are also smaller within geographically homogeneous blocs than across them. In other words, Romania and Moldavia might vote for each other at a much higher than average rate, but this could just as easily be because they have similar musical roots and tastes as because they are friends scratching each other’s backs.

Another study finding similar conclusions about geo-political bloc voting is contained in this Telegraph article, which makes similar findings, but concludes:

Comforting as it might be to blame bloc voting for the UK’s endless poor record, it’s not the only reason we don’t do well.

In other words, in a more detailed analysis which models performance after allowing for bloc-voting effects, England is still doing badly.

This whole issue has also been studied in much greater detail in the academic literature using complex statistical models, and the conclusions are similar, though the authors report language and cultural similarities as being more important than geographical factors.

The techniques used in these various different studies are actually extremely important in other areas of application. In genetic studies, for example, they are used to identify groups of markers for certain disease types. And even in sports modelling they can be relevant for identifying teams or players that have similar styles of play.

But if Eurovision floats your boat, you can carry out your own analysis of the data based on the complete database of results available here.

Update: Thanks to Susie.Bruck@smartodds.co.uk for pointing me to this. So not only did the UK finish last this year, they also had their points score reduced retrospectively. If ever you needed evidence of an anti-UK conspiracy… 😉

# Picture this

You can’t help but be amazed at the recent release of the first ever genuine image of a black hole. The picture itself, and the knowledge of what it represents, are extraordinary enough, but the sheer feat of human endeavour that led to this image is equally breathtaking.

Now, as far as I can see from the list of collaborators that are credited with the image, actual designated statisticians didn’t really contribute. But, from what I’ve read about the process of the image’s creation, Statistics is central to the underlying methodology. I don’t understand the details, but the outline is something like this…

Although black holes are extremely big, they’re also a long way away. This one, for example, has a diameter that’s bigger than our entire solar system. But it’s also at the heart of the Messier 87 galaxy, some 55 million light years away from Earth. Which means that when looking towards it from Earth, it occupies a very small part of space. The analogy that’s been given is that capturing the black hole’s image in space would be equivalent to trying to photograph a piece of fruit on the surface of the moon. And the laws of optics imply this would require a telescope the size of our whole planet.

To get round this limitation, the Event Horizon Telescope (EHT) program uses simultaneous signals collected from a network of eight powerful telescopes stationed around the Earth. However, the result, naturally, is a sparse grid of signals rather than a complete image. The rotation of the earth means that with repeat measurements this grid gets filled-out a little. But still, there’s a lot of blank space that needs to be filled-in to complete the image. So, how is that done?

In principle, the idea is simple enough. This video was made some years ago by Katie Bouman, who’s now got worldwide fame for leading the EHT program to produce the black hole image:

The point of the video is that to recognise the song, you don’t need the whole keyboard to be functioning. You just need a few of the keys to be working – and they don’t even have to be 100% precise – to be able to identify the whole song. I have to admit that the efficacy of this video was offset for me by the fact that I got the song wrong, but in the YouTube description of the video, Katie explains this is a common mistake, and uses the point to illustrate that with insufficient data you might get the wrong answer. (I got the wrong answer with complete data though!)

In the case of the music video, it’s our brain that fills in the gaps to give us the whole tune. In the case of the black hole data, it’s sophisticated and clever picture imaging techniques, that rely on the known physics of light transmission and a library of the patterns found in images of many different types. From this combination of physics and library of image templates, it’s possible to extrapolate from the observed data to build proposal images, and for each one find a score of how plausible that image is. The final image is then the one that has the greatest plausibility score. Engineers call this image reconstruction; but the algorithm is fundamentally statistical.

At least, that’s how I understood things. But here’s Katie again giving a much  better explanation in a Ted talk:

Ok, so much for black holes. Now, think of:

1. Telescopes as football matches;
2. Image data as match results;
3. The black hole as a picture that contains information about how good football teams really are;
4. Astrophysics as the rules by which football matches are played;
5. The templates that describe how an image changes from one pixel to the next as a rule for saying how team performances might change from one game to the next.

And you can maybe see that in a very general sense, the problem of reconstructing an image of a black hole has the same elements as that of estimating the abilities of football teams. Admittedly, our football models are rather less sophisticated, and we don’t need to wait for the end of the Antarctic winter to ship half a tonne of hard drives containing data back to the lab for processing. But the principles of Statistics are generally the same in all applications, from black hole imaging to sports modelling, and everything in between.

# It’s just not cricket

I’ve written a couple of posts now – here and here – where I’ve mentioned the Duckworth-Lewis method. As I explained in the first of those posts, this is a  statistical approach to the problem of setting runs targets in cricket matches that are interrupted by rain. And at some point, I might write a post discussing a little about the detail of this method.

But you don’t want me to spoil your post-xmas-party hangover with some heavy statistics, right? You’d much prefer it if I spoilt it with some terrible music.

So, ladies and gentleman, I give you…

The Duckworth Lewis method (band)

Really!

If you follow the link to their webpage you will find details of past tours as well as their recent album, Sticky Wickets, which I presume is a cricket-based play on words referring to the Rolling Stones’s Sticky Fingers. The comparison stops there though!

As you might have guessed from both the name of the band and their album title, their songs are mostly – if not all – cricket-related. So if you’re feeling especially brave, and promise not to hold me responsible, try the following.

It’s just not cricket…

# Enjoy the universe while you can

I’ve mentioned in the past that one of the great things about Statistics is the way it’s a very connected subject. A technique learnt for one type of application often turns out to be relevant for something completely different. But sometimes the connections are just for fun.

Here’s a case in point. A while back I wrote a post making fun of Professor Brian Cox, world renowned astrophysicist, who seemed to be struggling to get to grips with the intricacies of the Duckworth-Lewis method for adjusting runs targets in cricket matches that have been shortened due to poor weather conditions. You probably know, but I forgot to mention, that in his younger days Brian was the keyboard player for D:Ream. You’ll have heard their music even if you don’t recognise the name. Try this for example:

Anyway, shortly after preparing that earlier post, I received the following in my twitter feed:

I very much doubt it’s true, but I love the idea that the original version of

Things can only get better

was going to be

Things inexorably get worse, there’s a statistical certainty that the universe will fall to bits and die

Might not have had the same musical finesse, but is perhaps a better statement on the times we live in. Or as Professor Cox put it in his reply: