Tag Archives: statistics

Book Review: The Simpsons and Their Mathematical Secrets by Simon Singh

First he studied quarks. Then he battled quacks. Now he looks at quirks.

From the outset, one gets the impression that this was great fun to write. Maybe it was even more fun to write than it was to read. The basic premise is that a lot of the scriptwriters of The Simpsons are highly scientifically literate and that throughout the many years that the show has been broadcast there have been a number of gags that rely on an understanding of maths.

Singh has spoken to a number of the creators of The Simpsons in order to ascertain whether the theories of some of the earliest discussion boards on the internet, like some UseNet groups were right when they analyzed various episodes, as well as to get an insight into the creative process that goes into creating one of the most successful television programmes of the last 25 years.

What then proceeds is an exploration of some of the more fun aspects of maths. Those who have read a lot of recreational maths may struggle to find much that is new here, but what is presented is done so clearly, with great humour and evident enthusiasm. One will not be surprised to find discussions here on prime numbers, pi and Fermat’s last theorem. To those familiar with the concepts, this is like meeting an old friend in a bar. You may have heard their stories before, but they are fun to be around nonetheless.

For me, one of the most interesting chapters was on sports statistics. I’ve been aware for some time that some sports teams have used statisticians to try to bolster their results, but have had little more insight than that. Singh gives us a nice overview of the subject here, under the heading of ‘sabermetrics‘.

Some of the links between the maths and The Simpsons can be a bit tenuous at times. Some other reviewers have commented on this, but I wouldn’t be too critical on this point. The book is more about maths than The Simpsons, with the latter being a springboard from which Singh dives; and rather elegantly at that.

Yet The Simpsons isn’t the only springboard used. Approximately 2/3rds of the way through, we start to look at another of Matt Groening’s creations, Futurama. The book, though, keeps the same format and uses this to look at a greater range of issues, which was possible because Futurama was ostensibly more sci-fi than The Simpsons.

In this part of the book, we get treated to one of my favourite tales from the history of modern maths: the meeting of G. H. Hardy and Srinivasa Ramanujan, talking about 1,729 (though Singh fails to note that if you get hold of a mathematician’s debit or credit card, 1729 would be a good guess for the PIN!). If you haven’t heard of those two people or the number 1,729 means nothing to you, then please do buy this book.

Although the book is excellent, it does have a few flaws. It triggers one of my pet hates of using what is euphemistically known as ‘American spelling’ or in more plain terms, it is littered with typos. Though the subject is an American show, it is written by an English author with an English publisher, so one would have hoped for correct spellings. Though that might be levelled at the book’s editor, there is one critique for the author, and that is a bizarre dichotomy he tries to draw between science and maths, as though the two were somehow different disciplines. One might demonstrate with this quote from page 45: “…scientists have to cope with reality and all its imperfections and demands, whereas mathematicians practice their craft in an ideal abstract world.” As a mathematician, this is a view I profoundly disagree with, not least given the very simple fact that mathematics departments are typically located with the faculty of science at any university. It was certainly was at my alma mater, where I recall Simon Singh once gave a guest lecture while I was an undergraduate.

I’ve followed the fortunes of Simon Singh for a few years now. His books on Fermat’s Last Theorem (which crops up here) and on code breaking have both proved popular and critical successes. In recent years though he has been the subject of libel proceedings and has become something of a world-weary figure after his long legal battle with the British Chiropractic Association and his subsequent work in libel reform. Early on in the book I got the impression that this was a book to signal that he had moved on and was now back to enjoying work and that this was a breath of fresh air. This impression was deepened after a sly reference at the start of the book notably using the word ‘bogus’ that had gotten him into so much trouble in the first place. If there was any doubt, though, it would be thoroughly dispelled in the acknowledgements at the end of the book where he takes time and space to thank those who have supported him and his campaigns.

It’s a coda which indicates the more serious aspects of science to which the main content of the book is the joyous, trivial flipside. I look forward to seeing what he writes next. If it is as good as The Simpsons and their Mathematical Secrets, it will be well worth a read.

Friday fun: Am I any good at playing Hearts?

As it’s Friday, I decided to take a bit of a break from the relatively serious blog posts I’ve been turning out of late and take a light look at probability and games. Games, after all, are a great arena for testing out ideas in combinatorics and statistics.

The question posed might seem to be an obvious ‘yes’ but just because something might seem obvious doesn’t always mean it’s true. I’ve had my current laptop now for a little over two years. In that time, I’ve played 345 games of Hearts on that computer. I will assume most of you have either played it, or at least know how to play. If not, here’s a quick guide.

Given that there are 4 players, if the game were entirely random, one would expect, over time, to win roughly a quarter of the games played. If your win percentage was higher, you might be justified in thinking that you’re better than the computer. If your win percentage was lower, you might think you were worse, though most people would quickly move on from that thought to trying to find an excuse.

So, how many games do you think I’ve won? Is it not 345/4 = 86.25? Obviously not, because I can only have won a discrete number. So should my expected number of wins be 86 or 87? Obvious rounding would say 86. Though since 87 is so close, that would also seem a reasonable number to have won. What about 90, though? That still seems to be within the realms of possibility. 100, perhaps? How about 120? That might seem less likely, as that would mean I’ve won over a third of the games, yet I only expect to win a quarter.

The answer is in fact 188, giving me a win percentage of just over 54%. Does that really prove that I’m good at Hearts? To try to give it some meaning, I’d like to know what the probability is of winning 188 games out 345 and compare this to the odds of winning 86 time out of 345. But there might be a snag. We would expect that the odds of winning 86 times would be the highest, but there are 345 different possible outcomes. So is one really much more likely to win 86 times than 87? Instinctively, it seems not, but we need to quantify to this to make much sense of this, and confirm or deny what “feels” right.

How do we work out the probability?

I’ll start off with a simple case, where we have only played 2 games. If it were random, we would expect to win 25% of the games. i.e. the probability of winning any given game is 0.25. Similarly, we would expect to lose 75% of the games i.e. a probability of 0.75.

As each game is independent, we need to multiply the probabilities together. So the odds of winning:

  • 0 games out of 2 would be 0.75*0.75 = 0.5625
  • 1 game out of 2 would be 0.25*0.75 = 0.1875
  • 2 games out of 2 would be 0.25*0.75 = 0.0625

But there’s a problem. Add them all up and you should achieve certainty, a probability of 1. But instead, our total is 0.8125. It falls short of 1 by 0.1875. It’s no coincidence that that matches the probability of winning 1 game out of 2. That’s because there are 2 ways we would that single game: we could win the first and lose the second, or lose the second and win the first. So we have to multiply that by the number of ways you can choose 1 ‘slot’ given 2 ‘slots’ to choose from.

How about we try it with 5 games now (to 4 decimal places):

  • 0 games out 5 would be (0.25^0)*(0.75^5) = 0.2373
  • 1 game out 5 would be (0.25^1)*(0.75^4) = 0.0791
  • 2 games out 5 would be (0.25^2)*(0.75^3) = 0.0264
  • 3 games out 5 would be (0.25^3)*(0.75^2) = 0.0088
  • 4 games out 5 would be (0.25^4)*(0.75^1) = 0.0029
  • 5 games out 5 would be (0.25^5)*(0.75^0) = 0.0010

Again, we have undercounted. With the 0 and 5 cases, there is only one arrangement each by which you can win or lose all 5 games. But to win 1 game (or to lose 1 game) there are 5 ways to do this. So we need to multiply the 1 & 4 cases by 5.

But what about 2? How many ways are there to choose 2 games to win (or to lose) from 5 opportunities? Without going into all the detail it is 5!/((5-2)!)*2!) = 120/(2*6) = 10

So to take into account the multipliers, we get the probabilities:

  • 0 out of 5 = 1*0.2373 = 0.2373
  • 1 out of 5 = 5*0.0791 = 0.3955
  • 2 out of 5 = 10*0.0264 = 0.2637
  • 3 out of 5 = 10*0.0088 = 0.0879
  • 4 out of 5 = 10*0.0029 = 0.0146
  • 5 out of 5 = 1*0.0010 = 0.0010

Adding up, we get back to our reassurance that the sum of all probabilities is 1.

What about 345 games then? Well, we just extend the pattern. The odds of winning 188 games are:

(345!/((188!)*((345-188)!)))*(0.25^188)*(0.75^(345-188)) = well, something very small indeed.

A standard calculator won’t be able to do the calculation, but with a little help from a more powerful computer (aka Excel on my laptop), the answer is roughly 0.00000000000000000000000000000012063

That seems pretty darn small. But there are a lot of options (345 to be precise) and most look pretty small. What about our expected figure of 86?

The odds for that (which I leave to you check) are 0.049574108. It is the highest probability for any number of wins, but it may surprise some that the odds of getting 25% of the wins given the odds of winning are 25% are in fact slightly worse than 1 in 20, or 19/1 against. Suddenly, the idea of a direct comparison doesn’t seem so sensible anymore.

Though our odds of winning 86 games are about 410,937,214,868,030,000,000,000,000,000 greater than winning 188 games, I’m still sceptical. What we need to do is look at some kind of spread around our two values of 86 and 188.

Let’s look at each plus or minus 20 (arbitrarily chosen, I admit, please feel free to suggest or try alternatives). So what are the odds of winning between 66 and 106 games? And what are the odds of winning between 168 and 208 games?

For that, I refer back to the working spreadsheet (which I can send you if you don’t believe me and can’t figure out how to design it yourself) and we get the former to be a quite reasonable 0.992543. In other words, if there was no skill in Hearts than you would have more than a 99% probability of winning between 66 and 108 games out of 345.

The latter turns out to be 0.00000000000000000000230188 or 1 in 434,427,345,316,048,000,000.

It is not impossible that my winning so many games is a fluke of the probabilities and that I have hit upon a streak that no one else in the history of the universe will have ever likely encountered before. It just seems very very very very very unlikely.

Maybe, then, it’s not just luck. Maybe I am more skilled at playing the game than the computer is. I’d certainly like to think so, though ‘liking to think so’ can be the downfall of anyone look at statistics…