Wednesday, 8 March 2017

Win the toss - bowl

Everyone bowls first if they win the toss in a test in New Zealand, but should they?

It seems to be established wisdom that bowling first in New Zealand is the right thing to do, but I’m interested to see if the numbers play that out. The first thing that people would want to look at is the results. I’ve first of all limited to the last 5 years, because that’s the period in which teams have always chosen to bowl first.

Bowl first

While the team bowling first has won 33% more often than the team, that’s only 2 out of 21 matches difference. We know that if we had a perfectly fair three sided coin (hard to imagine, but go with me) and we flipped it 21 times, it would actually be very unlikely for it to land exactly 7 times on each side. (Just under 4% probability). Given the data that we have, and assuming that it tells the story about all pitches in New Zealand, we can say that if you bowl first, the probability of winning is likely to be between 17.3% and 58.9%, while the probability of losing is between 9.3% and 47.9%. These are massive confidence intervals, and there’s no way that we can make a call statistically from them. We would need to see more than a difference of two before we could statistically say that there is a difference in the expected result based if you batted or bowled first.

So perhaps the issue is the small sample size.

I could extend to all tests in the last 40 years in New Zealand.

Bowl first

The difference in the experimental probability is 0.021, but the margin of error is much larger. We would need to have a difference of about 0.114 before we could say that there’s a difference statistically.

However this data also includes situations where teams have won the toss and chosen to bat. So eliminating those might make a difference…

Bowl first

At this point it’s pretty clear that winning or losing is not decided by the toss. Teams who have lost the toss and been sent in have won 28 as opposed to losing 29. We need to look deeper if we’re going to find anything.

I decided to look at what the normal score was in the first and second innings. If bowling first was the right move, then we’d expect the second innings to be more productive than the first.

It seems that it’s more the other way round. I’ve looked at batting average for the innings rather than score to account for declarations. (540/6 should be worth more than 550 all out).

In the first innings, we’d expect teams to get about 350 and in the second we’d expect them to get about 300. Interestingly, there’s actually a statistical difference here. We can say that teams tend to score more in the first innings than in the second innings.

This suggests that all the hype that says that teams should always bowl first in New Zealand is just that: hype. There’s no statistical evidence that says that bowling first is better than batting first, and – strangely – there is some that suggests batting first actually might be better.

Thursday, 28 July 2016

Flight, guile and Santner

Mitchell Santner ran in to bowl in his typically graceful manner. He bowled slightly short of a good length, and the ball skidded off the pitch. Hamilton Masakadza diffused it comfortably, playing it out into the off side.


In his reply to David Hume’s argument about miracles, CS Lewis added in a chapter titled “A Chapter Not Strictly Necessary.” The idea was that it was a chapter that wasn’t really needed for his argument, but it gave him pleasure to write it, and so he added it into his book. His chapter was about the aesthetic beauty of nature.

Mitchell Santner is a very good bower. The fact that he makes what he does look good is a bonus, it’s not really necessary. If he took ugly wickets, it would look the same in the scorebook.

Friday, 8 January 2016

A closer look at Guptill's innings vs Sri Lanka

Yesterday, I witnessed one of the most unusual innings I've seen. Martin Guptill hit 58 off 34 balls opening the batting against Sri Lanka at the Bay Oval in Mt Maunganui.

It wasn't a particularly fast innings, nor a particularly slow one. It was a little faster than the average 50 in T20 internationals. (The median strike rate for 50's by openers in T20 internationals is 151.3, Guptill scored at 170.6. The upper quartile is 171.4, so Guptill's innings is in the second quartile). Here's a graph showing his innings compared to all fifties in T20I's scored by openers.

We can see that Guptill's innings doesn't really stand out from the pack. So why was it so interesting?

Friday, 27 November 2015

Heads or Tails?

The start of a cricket game is actually 30 minutes before the first ball is bowled. The ritual of it has changed a few times over the years, but basically what happens is the captains walk out to the pitch wearing their blazers over their whites with an umpire and often a cameraman and commentator. The umpire gives the coin to the home captain who tosses the coin up in the air, and then the visiting captain calls heads or tails before the coin lands. The coin is left to land on the pitch, and then the captain who has won the toss is asked if he wants to bat or bowl.

It's an old tradition. Using a coin to make a decision has been done for at least 2000 years. Using it in cricket has dated back to at least the 1850's (The toss result was recorded in the match between Oxford and Cambridge Universities in 1858). And yet there is now some calls for it to be done away with. The ECB are going to experiment with removing the mandatory toss for the 2016 County Championship season.

There is a thought that the toss is too influential. There is a perception that there are too many matches where "if you win the toss, you win the match." Just over 50% of respondents wanted the toss to be done away with on an ABC poll.

I remember having a conversation with a friend who is a fan of most sports, but he was sick of cricket because "the toss of the coin has too much impact." As a cricket statistician, this is wonderful, as it's something that I can test. What is the impact of the toss on cricket matches. How much more often does the team that wins the toss win the match?

In all test matches, the team that has won the toss has won the match 749 times, and the team that lost the toss has won 671 times. These combined with 734 draws and 2 ties have meant that the team that wins the toss has won the match 34.7% of the time, and the team that lost the toss has won 31.1% of the time. This is a relative probability of 1.116. This means that the team that has won the toss has had a 11.6% higher chance of winning the test.

This is slightly lower than I would have expected, but it's still a statistically significant difference. (Statistically significant is a technical term that basically means that we can say that we have enough evidence that there is a difference, and that it's unlikely to be just because of randomness).

But if we delve deeper into these numbers, then some interesting things turn up. First lets break it up by home and away. This is an important distinction, as the home teams will generally be better at reading the conditions. I would have expected that winning the toss at home would provide a bigger difference than winning at home. It turns out to be so, but not by nearly as much as I expected.

When the home team has won the toss, they've won 41.8% of the time (467/1117 matches), when the home team has lost the toss, they've won 37.9% of the time (394/1039). This is a relative probability of 1.103, or a 10.3% increase in probability of winning. There are different methods of testing for significance, and this is right on the edge of being significant or not. In other words, while there's a 10% difference, if we randomly selected the results, it would be reasonably likely that we would get this sort of difference.

When the away team wins the toss, they've won 27.1% of matches (282/1039) vs 24.8% when losing the toss (277/1117). This is a relative probability of 1.094: away teams have won 9.4% more often when they've won the toss than when they've lost the toss. Again, there is a difference, but it's not statistically significant.

The reason why it can be significant with the full group, but not with any sub group is due to the smaller sample sizes.

The similarity can be represented fairly well graphically.

The result proportions for home and away are very similar, regardless of who won the toss.

Now at this point, I wondered if this was simply due to older tests, where perhaps there was less doctoring of pitches. It is an interesting idea that pitches are doctored more often now. I would have thought that if anything, the nature of pitches round the world is now more similar.

To look at this, I selected a completely arbitrary cut off point of the 1st of January 2000. Looking at matches that started after that date, I found these numbers:

Overall the team that has won the toss has won 260 out of 680, while the team that lost the toss has won 252. That's a relative probability of 1.032 ie. in the past 15 years, the team that won the toss has won 3.2% more often than the team that lost the toss.

That's an almost negligible difference.

Breaking it down to home/away it gets even closer.

When the home team won the toss they've won 46.9%, when they lost the toss, they've won 46.9%. The difference is so small that you have to go to the 4th significant figure to be able to measure it.

When the away team won the toss they've won 29.4%, when they lost the toss, they've won 27.4%. The relative probability is 1.072. Surprisingly this is much larger than the advantage for the home team, which suggests that the difference is just down to the effect of randomness rather than the effect of the toss.

Here it is visually:

Again the similarity is remarkable.

So, to assess our original question: does the toss have a major impact on the result of the match? No. Absolutely not. Winning the toss has historically only given teams an 11% higher chance of winning, and recently that's reduced to only 3.2% since the year 2000.

*picture of Bradman and Allen at the coin toss thanks to Wikimedia.

Sunday, 13 September 2015

Anderson or Neesham

An email dropped in my inbox on Friday from New Zealand cricket naming the squads for the test series with Australia and the NZA squads to play Sri Lanka A. There was a lot to talk about, with new players being named in the A squad and the prospect of a day-night test coming up. But over 1/4 of the press release focused on two players: Jimmy Neesham and Corey Anderson. When I got in the car to come home from work, I listened to a debate between Darcy Waldegrave and Goran Paladin about who should be picked, Anderson or Neesham.

A quick scroll through the different websites I check for cricket news found that this was the story that most writers picked up on:
Cricbuzz put down their Indiacentric blinkers to lead (briefly) with "James Neesham, Corey Anderson named in Test squad for Australia Tour".
Andrew Alderson's piece in the New Zealand Herald was Anderson v Neesham: Let the contest begin.
David Leggatt wrote a piece for the Otago Daily Times titled Cricket: Black Cap selectors face all-rounder quandry.
Mark Geenty went for the slightly more negative Concerns remain over Anderson, Neesham as recovery race heats up for Brisbane on
Wisden India went for Anderson, Neesham return for Australia Tests.

It was clear that this was the key talking point for most people.

And that's fair enough too. It's not often that a team has a genuine all rounder. To have two players who have the potential to develop into such players is remarkable. Given that neither are quite there as being both first choice batsmen and bowlers, to pick them both is unlikely, so a show down is likely.

Neesham is probably less aggressive than Anderson with the bat, which has led to him having more success in the few tests that he's played in. Anderson has really made his name in ODI cricket. Neesham, on the other hand, didn't make New Zealand's 15 man squad for the World Cup. With the ball, Anderson has been very effective in ODI cricket, but has not really performed as well in tests. Neesham has not taken a lot of test wickets, but has been quite effective at holding down an end. Anderson tends to rely on bounce and his left-arm angle, while Neesham has a good cutter, and tends to attack the batsman's body more.

There is quite a bit of debate about who is the better player, and so the prospect of them both being fit, and us seeing who Hesson opts for is tantalizing.

In the conversation on the radio, Waldegrave and Paladin both said that it was clear that Neesham had better statistics, and so he should be picked. My ears immediately pricked up.

The basic statistics do bear that out.



Neesham has the better batting and bowling average. He's scored more runs in less innings, and has taken roughly the same number of wickets in roughly half the innings.

Here's a graphical representation of their batting scores so far:

A quarter of Anderson's innings have been scores of 2 or less, which is certainly not ideal. Neesham, on the other hand, has a quarter of his at 78 or higher.

Bowling innings are not so easy to show in a graph, but I felt that it was useful to see the difference. I've graphed their average vs the number of overs bowled.

We can see the trends in the numbers - Anderson's average is increasing, while Neesham's is decreasing. When Anderson had bowled the same number of overs as Neesham has now, their averages were similar, but Anderson's averages have risen fairly steadily since then.

However, straight summary stats can be misleading. I was interested to see if Neesham truly did have better statistics to the point where we could be confident that he would perform better.

I'm finding that more and more I distrust cricket basic statistics to tell me about players. That is an odd thing for a stats blog to say, but please hear me out.

Firstly a batsman's previous innings is not actually the full list of what he was capable of doing. It is effectively a sample. Of all the times that he could have played, he only actually played a few of them. (They have both batted on about 40 days, over the space of 3 years). Treating their previous results as population data, where we can compare summary statistics directly is dangerous, because these are effectively actually a sample of what their careers will eventually be. (Assuming here that they will play more). They are also only a sample of the scores that they were capable of throughout their careers. Perhaps they would have scored more if the last series they played in had been longer, or if there was an extra tests added into the last tour that they were on.

When we compare samples, we need to use statistical techniques in order to be able to account for sampling variation. Sampling variation is basically caused by not having enough information. There are a range of techniques to do this. If we have reason to believe that our population is normally distributed, we can create confidence intervals using descriptive statistics. However, we know that cricket scores are not normally distributed. Scores tend to be skewed to the right - ie the majority of scores are below the average. (Some examples Graham Dowling scored less than his average in 68% of his innings, Graham Smith scored below his average in 73% of innings, Gordon Greenidge scored less than his average in 68% of his innings and Don Bradman scored less than his average in 64% of his innings - if scores were normally distributed, then most players would score their average in roughly half their innings).

Another technique that can be used is a technique called bootstrapping. This is where a confidence interval is created by resampling with replacement. This is almost black magic, in that it uses just the variation in the sample to describe the variation in the population, and, despite it seeming illogical at first, it actually tends to work remarkably well. (For example, the bootstrap confidence intervals for the first 25 innings for Graham Smith, Sir Don Bradman and Gordon Greenidge all include their final career average. It even worked for Sir Frank Worrell, who had an amazing start to his career followed by a poor end)

The easy interval to construct was the batting scores. Here I randomly selected their batting innings, and calculated the average of each batsman. Then I subtracted Anderson's resampled average from Neesham's resampled average. If a number came out positive, then it meant that Neesham's average was higher, if it was negative, it meant Anderson's was higher. After taking 1000 resamples, I then looked at the central 95%. If it is all positive or all negative, it implies that there is a true statistical difference.

Here's the graph of the results

The red line in this graph indicates the confidence interval. Here we can see that the interval includes both positive and negative numbers. This means that we cannot make a call based on the start of their careers as to who is statistically the best. They are too close to call.

Bowling is harder to compare. There are so many things to compare that it can be really difficult. The way that I chose to compare the bowling was to think about what the job is that they are going to be asked to do. in the media conference Mike Hesson was actually quite clear about what role he expected Neesham or Anderson to do. They were to be an additional support bowler, in the same way that they have been used throughout the recent games. I looked at all the matches since McCullum has been captain, and the median overs bowled by the 4th seamer (or 3rd seamer when 2 spinners were picked) was 11. (For this I ignored a few innings where McCullum bowled himself for an over or 2, but I included the innings where he actually bowled 2 full spells)

As a result I normalised each bowling innings by Neesham or Anderson to 11 overs. To do this I added on a percentage to the run rates for situations where a bowler had only bowled a few overs. This meant that 0/25 off 5 became 0/65 off 11 and 2/12 off 6.1 became 3/25 off 11. There are obviously issues with this, but I felt that it was fairer than any other method that I could think of.

After normalizing we can see that the runs distribution is similar, but Neesham took more wickets more often.

The bootstrap results looked like this:

Again there is not enough evidence to actually say who is statistically better.

A third way to look at it is to compare the contribution in individual matches. For this I selected batting innings and bowling innings randomly from each player. I added Neesham's batting to Anderson's bowling, then subtracted Neesham's bolwing and Anderson's batting. If the result was positive then Neesham had made the bigger impact, if it was negative, then it was Anderson.

The result of this was as follows:

Again, there is not enough evidence to make a call.

However, all this data is from some very small samples. This is why the confidence intervals are so wide. To try and make any sort of call from such a small sample is really sketchy. To be able to make a valid comparison, I needed more data. Accordingly, I decided to look at their first class records. This time they both had more than 50 innings, and so the data was a little more useful.

However, the results were similar, despite the intervals being smaller. In every case the outcome included both positive and negative numbers, meaning that we could not make a call statistically who was the better player.

What does this mean in the context of selection?

Quite simply it means that the selectors need to rely on what they notice, rather than on the statistics. Who do they think will be successful, given their experience in the game, and their intuition for knowing which players are likely to do well.

Selection is not an exact science. In this case there is not a compelling statistical argument for either Neesham or Anderson, and so it really should come down to who the selectors feel would be most effective on the pitches that they are playing on.

Statistics can tell you a lot of things. But it cannot tell you everything. It is a tool for finding patterns, rather than a crystal ball for divining the future perfectly.

Sunday, 29 March 2015

New Zealand vs Australia: Head-to-Head

I've heard a number of commentators say that man-for-man, Australia have better players, but New Zealand is a better team. This strikes me as a peculiar thing to say, given that there's often no analysis included of individual head-to-head.

So I've decided to do it myself, in order to see if there actually is a clear difference, man-for-man.

I've tried to line up the players by role. Both teams have players that do similar roles generally, with only a couple of exceptions.

I'm looking at their world cup so far, as well as their numbers since 1 Jan 2013 in New Zealand and Australia.

Role 1 - Slower opener

WC Average76.0040.00
WC S/R108.7993.64
2 year Average43.0037.00
2 year S/R85.0887.13

Guptill is in better form, but the 2 year numbers are very close. These are two players of similar ability who are both playing good cricket. Both tend to be slow to start, but are capable of increasing their scoring rate once established.

Role 2 - Fast opener

WC Average41.0050.00
WC S/R191.81124.48
2 year Average38.0040.75
2 year S/R135.02104.21

Again the numbers are very close. Warner has the higher average, but McCullum scores faster. Both are remarkably good at both scoring boundaries and finding singles, but both are prone to hitting bad balls straight to fielders. McCullum has shown a weakness against left-arm spin, so there's a chance that Clarke might bring himself on to bowl early on.

Role 3 - First drop

WC Average37.0057.66
WC S/R83.1494.02
2 year Average51.0860.92
2 year S/R85.6494.77

These two players are the best batsman for their team in recent times. Smith is ahead on these numbers, but it's wrong to say that Williamson is a weakness in the New Zealand side. Both manage to score at a good rate without looking like they're trying. Both also have a big impact on their team's chances of succeeding. New Zealand win 45% of the time when Williamson scores under 40 and 62% when he scores 40+. Australia have won 53% of the time when Smith's scored under 40 and 86% when he's scored 40+.

Role 4 - Innings builder

WC Average30.1629.00
WC S/R63.0692.94
2 year Average46.8223.66
2 year S/R79.3080.49

Clarke's had a slightly better world cup, but Taylor has produced more quality innings' over the past 2 years, averaging almost twice what Clarke has. These two are both great players, who often play roles that allow others to shine. As a result, their numbers don't truly tell the story of their contributions. Both players' numbers are also a reflection of their battle with injuries.

Role 5 - rebuild or launch

WC Average37.8341.20
WC S/R107.07107.85
2 year Average44.7636.82
2 year S/R94.6394.70

A really interesting role in modern cricket is the number 5 batsman. Their role is sometimes to steady a rocking ship, and other times it's their role to attack, and build on the foundation of the players above them. It is difficult to separate the ability of Watson and Elliott to do this role.

They also both have a role to play with the ball as the extra bowler:

WC Average34.0074.00
WC E/R8.5.06.72
2 year Average25.88101.50
2 year E/R6.566.37

Elliott has been more expensive, but has also broken partnerships quite regularly.

Overall, it's really difficult to separate these two with bat and ball. I'd probably back Elliott as a batsman, but Watson with the ball, despite his numbers not being as good.

Role 6 - Agressive batsman

WC Average38.5064.80
WC S/R109.47182.02
2 year Average41.7733.42
2 year S/R125.96125.13

One of the dangers of comparing players like Anderson and Maxwell based on statistics is that they are often asked to do different jobs. Against South Africa, Anderson's job was not to come in and score at a massive strike rate. His job was to play sensibly and carry the innings through. Over a longer term it's difficult to separate Anderson and Maxwell. Both are capable of being absolutely breathtaking with the bat.

Both play quite different roles with the ball, so I'll look at them later.

Role 7 - Wicket-keeper batsman.

WC Average14.6042.00
WC S/R125.86157.50
2 year Average38.8841.11
2 year S/R128.84111.11

Haddin has had a much better world cup, but it would not be difficult to argue that Ronchi has been the most effective death batsman in the world in the past couple of years.

They're also difficult to separate with the gloves. Both are solid keepers who have made a couple of key mistakes, but in general, they've done the job required of them sufficiently.

Role 8 - Bowler who bats

WC Average41.0014.66
WC S/R164.00176.00
2 year Average15.6644.25
2 year S/R123.68114.56

Faulkner and Vettori have very different styles, but can both be very effective. Vettori has rediscovered his batting form of 2008-2012 in this world cup, during which time he was one of New Zealand's best batsmen as well as being an outstanding bowler. Contrastingly, Faulkner hasn't found his rhythm since returning from injury.

Role 9 - Right arm opening bowler

WC Average27.1320.85
WC E/R5.574.19
2 year Average28.9720.44
2 year E/R5.534.37

Hazlewood has the advantage here numerically, but some of that is due to Southee having a role bowling at the death. I don't think many selectors would pick Hazlewood over Southee, regardless of the difference in their stats.

Role 10 - left arm opening bowlers

WC Average15.7610.20
WC E/R4.413.65
2 year Average22.0914.37
2 year E/R4.584.34

Starc and Boult probably been the two best bowlers in the tournament. They both offer different things. Starc bowls into the pitch with a high arm action that causes the ball to bounce higher, but it also gets less movement and arrives to the batsman later, despite the quicker speed through the air. Boult bowls over his front foot and tends to bowl more deliveries along the wicket than into the wicket. As a result, the ball swings more and arrives at the batsman faster. (Ed Cowan, after facing both, commented that Starc might bowl 5-10km/h faster but you have a lot more time to face the ball. Boult certainly feels faster.)

It's difficult to separate them, but not impossible. Starc has been the premier white ball bowler in the world recently.

Role 11 - 3rd seamer

WC Average-24.66
WC E/R5.005.43
2 year Average19.0025.15
2 year E/R4.265.04

Henry has only bowled 8 overs this world cup, as he wasn't even in New Zealand's original squad. His first 5 overs included 2 maidens and conceded only 9 runs against South Africa. He went the distance in his next 3 overs, but even then, a large proportion of his runs came through edges and mis-hits. Johnson is a master with the red ball, but hasn't had the success recently with the white ball that he had earlier in his career. It's still difficult to complain about an average of 25 and taking a wicket every 5 overs.

Role 12 - 4th seamer

WC Average16.2123.00
WC E/R6.454.90
2 year Average22.6926.57
2 year E/R6.425.45

This is a slightly more difficult comparison, as Anderson generally bowls at the death. His economy rate here is outstanding, and he's taken a lot of wickets. However, taking wickets with bad balls isn't necessarily a trait that is repeatable. Faulkner looks like a better bowler, despite his numbers not being quite as dramatic as Anderson's.

Role 13 - Spinner

WC Average18.8036.20
WC E/R3.985.83
2 year Average35.1232.91
2 year E/R4.105.24

Vettori is in a different class here. It's probably the only place where there's a clear difference in quality between players doing similar roles in the two teams.

Overall it's really difficult to separate the two teams. Both have a team full of good players in good form. They have players doing similar jobs, often in similar ways.

I don't think I can honestly say at this point which team has better players. The more you look at this match, the more mouth-watering it becomes.

Tuesday, 10 March 2015

Updated QF prediction chart

In my previous post I ran a simulation to find out potential quarter-final places. I received some criticism for having England so low, and Bangladesh so high, but events over the past 48 hours have shown that the respective probabilities of the two teams qualifying may not have been so far off.

The program that I wrote to do the simulation was corrupted when my computer crashed and I foolishly hadn't saved it, so I've written a different one to re-calculate. This time I made a couple of modifications. I moved from an additive model for run rates to a multiplicative one, as that seemed to be more sensible (teams are realistically a % better than other teams, rather than a fixed number of runs better. We would expect the margins to blow out more in terms of runs on better batting pitches than on difficult tracks).

I also slightly reduced the standard deviation of the simulation by moving it to one quarter of the mean rather than one third. This again made the results seem more sensible. There were too many teams scoring over 400 or under 100 previously.

Here are the new results. This table shows the probability of each team qualifying in position 1, 2, 3 or 4 in their group, and then the total probability of qualifying. Again I have not factored rain into this, and with Cyclone Pam heading towards New Zealand that may be a little optimistic.

New Zealand10001
Sri Lanka00.0240.97250.00351
South Africa00.9760.02401
West Indies0000.7430.743

The potential group results look like this:

Group A
NZ Aus SL Ban0.9725
NZ SL Aus Ban0.024
NZ Aus Ban SL0.0035

Group B
Ind SA Pak WI0.5295
Ind SA Ire WI0.1985
Ind SA Pak Ire0.1345
Ind SA Ire Pak0.1135
Ind Pak SA WI0.011
Ind Pak SA Ire0.006
Ind Ire SA WI0.004
Ind Ire SA Pak0.003

The three interesting potential quarter final match-ups to watch for here are

SA vs Aus4.7%
Ind vs SL0.35%
Ire vs Ban0.02%

In reality the probabilities of Ireland vs Bangladesh and Australia vs South Africa are higher, as they are both much more likely if rain starts to fall.