# An almighty coincidence

Issue 45
December 2007

Coincidences can crop up in the strangest places. While Peter Hughes, an accountant from Birkenhead, was at a church service, his eye fell on the board showing the list of hymn numbers for the service. They were 16, 37, 428 and 590.

Mathematicians naturally look on numbers as a goldmine for distraction, maybe seeking to combine them to form an equation, or noting how many are primes. In this case, Peter observed something particularly curious: all ten digits appear exactly once! How likely is that, he wondered? His initial back-of-the-envelope estimate indicated that the chance might be about 1 in 6,000. He then sought our comments.

This is a nice example of a coincidence from everyday life. Whenever you attempt to work out the chance of such a coincidence, it's necessary to make a number of common sense assumptions, and then to build a mathematical model to come up with a sensible answer. Here, the chance will depend on how many hymns are available, how many are chosen, and what the selection process is. Hymns are generally numbered consecutively from to . Let's suppose for simplicity that was about 1,000; in fact it helps the calculations below if we take , and we know that, on this occasion, exactly four hymns were chosen for the service.

That latter condition is central: fewer than four hymns makes Peter's observation impossible if , while more than four hymns would make it overwhelmingly likely that they would contain more than ten digits. So it was fortunate that Peter was at a four-hymn service, or he might never have happened upon this coincidence at all — though as we'll see, what he witnessed was still exceptionally unusual.

### Do the calculations

The hymn lottery — what are the odds?

Now for the calculations. First, we need to estimate the chance that the four hymn numbers contain exactly ten digits. Then we need to work out the chance that every digit is different.

In our book of 999 hymns, every number will have either one, two or three digits. The only combinations that give a total of ten digits are and . If the hymns are chosen at random, the chances of a hymn number having 1, 2 or 3 digits will be 9/999, 90/999 and 900/999 respectively. Swallow hard, assume all four selections are made independently, and it emerges that the two combinations noted have respective chances 0.0263 and 0.0395, meaning that the overall chance of exactly ten digits is around 0.066, about 1 in 15. (Got stuck? Find out how this was worked out).

Given the hymns have ten digits in total, what is the chance they are all different? If all digits were equally likely, the chance of them all being different would be , where stands for . This is approximately equal to 0.00036. (Stuck again? Here's the answer.) We'll call this quantity , so . Putting the two calculations together, our first estimate for the overall chance is , in round figures in . So Peter's back-of-the-envelope figure looks like a substantial underestimate!

### Refining the model

Our simple model has obvious deficiencies. For example:

1. The number zero will arise less frequently than other digits, maybe 2/3 as often;
2. Some hymns are far more, or less, popular than others;
3. Christmas carols, doubtless numbered consecutively in a hymnbook, will never be selected for most of the year. Other blocks of hymns will be used only at baptisms, Easter, Harvest etc.;
4. For hymnbooks in which , the frequencies of 1, 2 or 3 digit numbers will be different from those assumed;
5. The numbers chosen can't be completely independent, as they are drawn from a finite population without replacement — and other factors may affect the independence assumption too.

Point 3 is a reminder that we should explicitly assume that the service in question is a standard Sunday service, and not at Christmas, for example.

The impacts of these refinements do not all work in the same direction! Whenever the digits are not all equally likely, that reduces the chance that they are all different. For example, as well as there being fewer zeros, if the carols are numbered (say) 425 to 488, then removing them from the selection available to the vicar would dramatically decrease the frequency of digit 4. On the other hand, if there are fewer than 999 hymns, or if that block of carol numbers is cast aside, the frequency of three-digit numbers will decrease, making it more likely that four hymns will have exactly ten digits. Selecting all the hymns from one short section of the book would make Peter's observation virtually impossible, but deliberately spreading them uniformly over the book would increase the chance.

So suppose the true frequency that digit is selected is . Then each number lies between 0 and 1, and the sum to 1. To make our calculations easier, we write , where the numbers sum to .

Now, selecting ten digits independently, the chance they are all different is

which we write as After a bit of manipulation this approximates well to which we will write as

How much does it affect the answer if the ten digits are not equally likely? Take and assume hymn numbers are chosen at random. For each digit, calculate its frequency among numbers with one, two or three digits respectively, and weight these appropriately: for all digits except zero, the frequency is

while for zero we have (Here is some help on this.) Thus , and for , so that , reducing the estimate of the chance we seek by some . The impact of zero being less frequent than the other digits is much less than you might suppose!

What's Christmas times Easter minus baptism?

Now suppose that 100 of the three-digit numbers are eliminated, either because they are carols or hymns for other special occasions like Easter or baptism, or because the book has fewer than 999 hymns. The chances of the hymn numbers having 1, 2 or 3 digits are then , and which leads to the chances of the two combinations having exactly ten digits, on the same assumptions as before, being increased to and . The overall chance of four hymns having ten digits is estimated as , about higher than before!

Overall, unless the number of hymns is radically different from 1000, or a substantial number of them would be selected only on special occasions, the joint impact of these refinements is very little: we still offer 1 in 40,000 as the ball-park chance of Peter's observation for a random Sunday.

### Simulations

There is another way of estimating the chance of a coincidence such as this one, namely to do a computer simulation. Select four hymns at random with the carols deleted, and repeat the exercise ten million times.

We chose the Methodist Hymnbook (1933), which has hymns, with the Carols numbered 117 to 143; and on just 245 occasions in that simulation, all ten digits appeared exactly once. So our estimate of the chance from this simulation is about 1 in 40,800, gratifyingly close to the earlier calculations.

This suggests that, if you attend 40 "ordinary" services per year, you might expect to wait about 1000 years before sharing Peter's experience. That's a heck of a lot of sermons to sit through!

### More coincidences

There's bound to be a coincidence in here, somewhere.

There is a different way of looking at coincidence questions such as this one. Peter's email would have seemed just as interesting if he had said: "All four hymns were prime numbers" (the chance of this is actually about 1 in 1,000, depending on the hymnbook). And it might have been even more interesting if the hymn numbers had been 11, 22, 111 and 222 for example. So while the chance of one particular interesting coincidence was 1 in 40,000, the chance of some unspecified interesting coincidence in the numbers will be considerably higher, and impossible to calculate.

Indeed, as David Wells' famous Dictionary of curious and interesting numbers makes clear, the vast majority of numbers between 1 and 1,000 are curious or interesting in their different ways, making the chance of a mathematician finding something of interest in next Sunday's hymn list something close to 100%!