Thursday, 13 February 2014

How can an attacking team get close enough to expect a goal?

There's been some great work done in football analytics recently, looking at a team's scoring chances from different positions on the pitch, which has led to the calculation of various Expected Goals (ExpG) metrics. However it's calculated, in essence ExpG gives a player's chance of scoring from a shot, given his position on the pitch. Add up the probabilities for a group of shots and you can work out how many goals a team 'should' have scored from them. Have a look at Statsbomb if you'd like to read up on what's been available up to now.

I've managed to assemble a decent sized database of pass and shot locations from across the first half of the 2013-14 Premier League season and wanted to see if I could take Expected Goals a step further. As an indicator of shot success, Expected Goals typically paints a picture of the penalty area, with the six yard box as a hotspot and becoming colder the further out you move from goal. To a certain extent, its outputs are relatively obvious; if you shoot from closer in, you have a higher chance of scoring and shots from further out are less likely to be converted.

That's not to say Expected Goals isn't a useful metric - far from it - but it doesn't do a great deal for our understanding of how to create goals. We can quantify how much better it is to shoot from closer to the goal, but how do you get closer to the goal in the first place? If your attacks break down trying to reach the shot conversion hotspot, should you even try to get there, or just take your chances from range?

A couple of days ago, I tweeted an image of pass completion data, which we'll be building on in this post.


Pass success rate by destination


The image shows the probability of completing a pass into different areas of the pitch. We're not worried about where the ball is coming from for the moment, but are looking at the chances of passes into different areas being successful.

It's clear to see how - playing from left to right - passing accuracy starts to break down in the opposition half and then drops dramatically at the boundaries of their penalty area.

Even with half a season's worth of passes and shots, we're going to struggle with the number of data points available as this analysis progresses, so let's merge the granularity of that first image into some larger pitch areas.


Pass success rate by destination



We now have a picture of how difficult it is to pass into each area of a football pitch. What about shots?

From the same dataset, here's an average player's probability of scoring with shots from different pitch locations. Penalties are excluded and I've hidden squares with fewer than twenty shots to clean the data up a little.


Shot conversion rate by shot location



As a manager, you're on the horns of a dilemma. Scoring probability climbs to over 30% in the centre of the six yard box, but your chances of passing the ball into that location are slim.

What if we combine the two visualisations?

Pass success rate multiplied by scoring probability, gives an indication of the likely success of an attacking strategy. Pass to an easier area outside the box and shoot from there? Or attempt to work the ball closer, at the risk of losing possession?


Pass success probability * shot conversion rate


It turns out to be far from a clear cut-choice. There's a relatively large area, stretching from the edge of the six yard box, to well outside the area, where penetrating that area with the ball and then scoring once you have are quite evenly balanced at 2-3%. It's not as simple as 'closer to the goal is better' and the balance in one game is almost certainly dependent on passing quality of the individual teams and how well their opponents defend.

If we box out that 2-3% conversion area, we can move the analysis on another step.


Pass success probability * shot conversion rate


How should a team attempt to move the ball into that boxed-out shooting zone? There are three broad choices: Directly from the direction of the centre circle, diagonally, or from the wings.

David Moyes has come in for a lot of criticism this week following Manchester United's draw with Fulham, where his players hit over eighty crosses in ninety minutes. We should be able to show here whether crossing, or a direct approach, is the more successful strategy.


Probability of achieving a successful pass into shooting area


Note that I've changed the colour scale on the above image to peak at 75% rather than 100%, since the average success rate of these passes is lower than when considering the whole pitch. Squares are only shown if they've been the origin of at least twenty passes.

Once you move beyond the eighteen yard line, pass success probability drops off quickly. Touchline crosses from a 'chalk on his boots' classic winger have success rates as low as 30%. Other things being equal, the best chance of passing the ball into our key zone comes from a direct, or diagonal move.

If you're thinking "but that's not fair, most of the passes included here will be targeted at locations outside the box", then you're right. Let's tighten up our key shooting zone, to a central area of the eighteen yard box surrounding the penalty spot.


Probability of achieving a successful pass into close shooting area


Still want to hit crosses all day?

The probability of a pass from the wings finding a team mate in the shooting zone is 30-40%, while moving through the central area has a success rate of 40-50%.

This isn't the end of the story, but it's where I'll stop for now. There are many more factors to be considered, including absolute volume of passes and the fact that a successful pass isn't the same as creating a shooting chance. This analysis will provide a base to work from though and one that I'd like to extend next into different types of teams.

Ultimately, I hope that this type of analysis could answer question such as...

Should teams with worse passing shoot more often from long range? And vice versa, where is the optimal shooting area for a team that passes with a very high success rate?

How do optimal strategies change, based on specific opponents?

(using significantly more data) Can we identify hotspots where passes into the shooting zone have higher success rates? Versus specific opponents? When specific defenders are on the pitch?

Eventually, I believe an approach like this might be able to identify defensive weaknesses in a specific team and optimal attack strategies for their opponents.

Friday, 7 February 2014

24,000 tweets about #Sochi

Who's excited about the Winter Olympics? Happy about the games? Angry about their location?

Let's find out...

Searching Twitter for #Sochi yields 29,800 individual tweets.

Running those through TextBlob yields 24,000 tweets that can be analysed for sentiment - positive, negative, or neutral*.

And throwing the whole lot at Google Fusion Tables lets us map them.

Here they all are. Blue for neutral, green for positive and red for negative.



Or for bigger, go here.

Just the happy people?



And just the angry people.




That was fun.

Thanks to some brilliant people who make brilliant tools; Google for Fusion Tables, and the development teams behind TextBlob and Tweepy for their Python modules.



* Please note that automated sentiment analysis is far from perfect. Especially the way I've implemented it.

The three rules of business data visualisation

I love data visualisation; sometimes just for its own sake, but mostly when it makes life easier.

The Earth Wind Map is an example of the former. It's hypnotically beautiful.



This type of data visualisation isn't so good in business though, except to use as marketing material. If you want to build a stunning animation of your customers' behaviour to put on a big screen in the office, that's great, but watching it for five minutes every Monday morning is unlikely to help you identify problems with your website. If we want to gawp at something beautiful, we call up the Earth Wind Map; if we want to know whether to take an umbrella tomorrow, we go for a simpler forecast.

In business - and I count non-traditional businesses like sport within this too - data visualisation has two main purposes.
  • To help you understand the best strategy to adopt.
  • To get you to that strategy faster than you otherwise could have.

In order to achieve those ends, I work to three simple rules when visualising business data. The ideal business report, (visualisation, dashboard, call it whatever you like), should achieve these three things as quickly and as simply as possible. The higher up the management chain the report's audience, the simpler it needs to be and the more 'added extras' become a distraction rather than useful additions.

I'm not dismissing visualisations for inspiration, or for investigation, but in business the aim of communicating data is to make the right decision and to make it quickly. This is what reports are for and so I try to design reports to communicate these three things.


1. Where am I right now?

For the metrics that you know are important (you have identified those metrics, haven't you?) Where are they right now? This could mean yesterday, a total for the past seven days, a summary of the last fixture your sports team played, or any other - relatively short - time period that works for the business.

It's absolutely vital that you don't get carried away with which metrics you visualise here. I've written before:

"As analysts, we're often the ones selling dashboards, so lets be honest about what they do well. They show data. So to be useful, you have to be someone who needs to see that data - and I mean really needs to see it. Just the number. Not why the number, or where it came from, or what you might want to do about it."

Only visualise metrics where you fully understand what they mean and know at least some of the levers that you can pull to make them change. If sales drop, you know what that means. If some single number that's a complex blend of customer values, retention, acquisition, marketing ROI and God knows what else changes, what are you going to do about it? Simplicity is good. It's also much harder than complexity.

To divert into my football analytics sideline for a moment, this is why I'm not a big fan of numbers like PDO. The definition is complicated, the name is confusing and as a manager it's hard to know what to do about it, when it's not where you'd like it to be.

That's not to say there shouldn't be complicated metrics (for example to use as predictive tools) but I don't want them on my management visualisation.

Very often, the best way to communicate some simple KPI numbers is a simple table. Who says a data visualisation can't be 'just' a table? In the right place, tables are awesome.

Here's a visualisation of website metrics, that will work well provided you already know a bit about your website.




2. Is that good?

So now I know how much I sold last week and how much traffic we got to the website. But is that good? Put each number in context.

Context can mean a comparison with the past, or with a fixed target, or even vs. key competitors.

It doesn't matter how you do this - colour coding, text flags, Harvey Balls - as long as it communicates quickly and clearly. Personally, I'm quite partial to an old school traffic light, if only because even in the marketing industry, it's hard to find somebody who can get 'green is good' wrong.

Our weekly table of web traffic stats gains week-on-week or year-on-year comparisons and a set of traffic lights. Now you can instantly see if any of these numbers need attention.



3. Is it changing?

The last piece of the puzzle is to know if your metrics (otherwise known as KPIs - this isn't revolutionary stuff!) are changing.

Part one told us where we are.

Part two told us if where we are is good.

Part three tells us if the position is becoming better, or worse.

This section is where things can get overcomplicated if you're not careful. If you've got eight KPIs and you want to show a twelve week trend, then you've now got ninety six numbers to communicate. Tables just became a really bad idea.

Sparklines however, are fabulous.

Sparklines are mini charts designed only to communicate spikes and trends in data. All this section of the report is designed to do, is to give a manager a quick visual representation of 'going up', or 'going down' and how fast.

Our website report gains a set of twelve week sparklines and we're done. In one small report, we can see at a glance where we are, whether that's good and whether it's getting better, or worse.




I love data visualisation, but in business, we need to drop the pretty pictures and understand why we're visualising in the first place. Infographics are awful for communication. They're actually worse than writing down your report as long-hand text.

If a business visualisation doesn't help you to understand the best strategy to adopt and do it faster than a table of numbers would, then it's not worth having. Build infographics (if you must), learn D3 and build beautiful animations, but recognise that they're marketing collateral, not serious business tools.

In business, we need to know where we are, if that's good and if it's getting better or worse. The longer it takes to communicate that, the further behind your competitors you'll be.

Monday, 20 January 2014

Betting using my model of Premier League football

I've been getting some questions over the past few weeks about the betting calls I make using my EPL model, so this post will explain how the betting choices work. If you just like to see who the model thinks will win each week then maybe skip this one, but if you're one of the people who's been looking at the calls and thinking, "What? He can't do that!" then this should help to explain my methodology. This is also going to be more than usually geeky so Wallpapering Fog felt like a better home for it than the EPL Index site.

If you're thinking "what EPL model?", have a look on eplindex.com.

First, a bit of history on where the model came from. That journey is how we got to here...

I've said before that this model wasn't originally built as a tool for betting and it's true. I first found eplindex.com last season (back when you could access all of their Opta stats for a few pounds a month), subscribed to the Stats Centre and built the model mainly to see if it would work. I had a vague thought that if it did work, then it could be interesting for a football club to use to forecast match results based on picking different players, but also assumed that the bigger clubs would already have sophisticated models of their own to do this type of work.

The model churned out a set of results for the first half of the 2012/13 season and I needed something to compare them with. Was my model any good? Bookmakers' odds are an obvious place to look for alternative results predictions, with easily accessed historical data available (football-data.co.uk if you're looking.)

That first version of the model didn't quite equal the bookmakers, in terms of the results that it said were most likely to happen, actually happening. The bookies favourites won games slightly more often than the model's predicted most likely outcomes.

Despite this, the model was projected by that analysis to make a small return if you used it to bet. The model didn't say the bookies favourites would win all of the time, so picked up some wins at decent odds. Bookmakers also almost never say that a draw is the most likely outcome of a game and if you backed a draw when the model said its likelihood was over 25%, you made a healthy return.

I started to predict results on Wallpapering Fog ahead of the games being played.

For betting, the rules were simple. Back a draw if the draw likelihood was over 25%, otherwise back whoever the model said was most likely to win. That's backing winners with no regard whatsoever to the market odds on that game. You could be backing a long shot that the model likes a lot, or backing a very short odds favourite that the model gives only a 40% chance of winning. For draws, the odds are usually around 3.5 but again, I was paying them no attention when picking the bets.

This method has periodically upset more seasoned gamblers, who point out that you shouldn't make picks like that. I do understand why not and I'll come back to it. Please bear with me.

The method arises as a result of having a primary objective for the model of calling as many results correctly as possible, rather than trying to maximise betting profits. This objective is also why I've never looked at the potential returns from using my model to call correct scores, or accumulators, or both teams to score.

It works like this:

1. Get as many results right as possible.

2. See if the strategy that achieves point 1, also makes money.

It did make a profit last season and is winning this season too, so that 'most likely outcome' method isn't as naive as it might look.

For any readers who aren't seasoned gamblers, the issue with backing the most likely outcome regardless of what odds the bookies are offering, is that you could be backing a result you think is a very close call, when the bookies are offering a only poor return if you're right.

If I flip a coin then you know the chance of it coming up heads is 50%. If I offer you odds of 1.5 on a bet on heads (£5 profit if you bet £10), you'd be mad to take it. You might win once, but in the long term, you're guaranteed to lose.

It's time to share some data... If you run the latest version of my model over the first 200 fixtures of the 2013/14 season, betting £10 on the predicted most likely result of each game, or on a draw if the predicted chances are over 27% (it's gone up a little from a 25% draw line since that first version) then here's what happens.

Important note: The data I'm using here to populate the simulation is the data that we had after week 20 had been played. I also know the exact starting line-ups for each of these games, which I won't when I post on a Friday ahead of a weekend's fixtures.

This is very much a best case performance. The model's good. But it's not quite this good.




So betting on the most likely result, regardless of market odd seems to work. Part of the reason for this is that we're imposing quite a harsh line before an upset is picked as a bet. In its raw results, the model predicts too many upsets, so rather than just saying it has to like the underdog more than the bookies do, we have a rule that it must like the underdog enough to actually return a prediction that they will win the game.

Very probably a better gambling strategy would be avoid to betting on certain fixtures at all, but we come back to my bullet points above; I'm forcing myself to give a prediction for every game. There is also very likely a better gambling strategy to be found in this model, but I like the simplicity of betting on the predicted winner. It works.

If you'd like to come up with your own strategy, I've put a link to all of the data behind the first 200 games of this season at the end of this post.

Let's have a look at what happens with an alternative strategy of backing 'value'. What happens when we bet on whichever of the three results (home win, away win, or draw) gives the biggest difference between the model's simulated likelihoods and the bookies odds? If the model's got an 'edge', then this should work.

The 'value' strategy's cumulative profit is in red below, with my usual method remaining in blue.


So the value strategy is also predicted to work, but returns are more volatile, as you'd expect since you're backing more long-odds results. Using the value strategy, you also win 38% of bets, rather than the 56% you're predicted to win by backing the most likely result. Both strategies should work (provided you don't mix-and-match between them) but the 'most likely result' is less risky in terms of long, bad runs.

To recap, the strategy I'm currently following arises from:

1. A self imposed rule that I must bet on every game and stake the same amount on every bet.

2. There is a benefit of moderating the model, so an upset must be predicted as being very likely, before we back it.

3. Evidence (the above, plus last season and this season so far) that backing the most likely predicted result is effective.

If you'd like to dive into the data, see where these numbers come from and pick your own strategy based on the EPL Model's calls, it's all here.

Thursday, 5 December 2013

What analysis is good at

It should be an easy question to answer. It should be, but it's not.

What is statistical analysis consistently good at?

I'm talking here about it's real use to the Managing Director of a company, or to the Chairman of a professional sports team, or to a politician. To somebody who has choices to make and is looking for help to make the best choice that they can.

A sceptic can easily reel off a list of things that your analysis can't do. Your analysis probably can't account for human frailty, or random chance, or a whole host of things that it was never designed to measure in the first place.

Your analysis can't forecast the effect of something that's never been tried before.

Your analysis says 'trust my numbers', but offers no guarantees of success.

And your numbers can't spontaneously volunteer new ideas; only tune up the effectiveness of old ones.

When you come right down to it, complex statistical analysis is a waste of time and effort, right?

As an analyst, I hear some of these arguments a lot. It's true that statistical analysis can't come up with the perfect strategy on its own, but it's still a hugely important tool. Here's what I think statistical analysis is really good at.


Analytics will conclusively reject a multitude of bad strategies that you might otherwise employ.

Analytics stops you making avoidable bad decisions.


Does that sound a overly negative? It doesn't have to be.

This is the scientific method applied to business and its tremendously powerful. Scientists know that you can't ultimately prove the truth of anything; that there's always the possibility that you're wrong. What you can do is falsify what definitely isn't true. All of our scientific knowledge about the world is based on theories that we're only working with for now, until we prove that they're wrong. All of it. But just look at the progress we've made by rejecting ideas that don't work...

It's this scientific method that means we've found ways to cure many diseases, which were previously terminal. And it's the rejection of this evidence-based method that can kill people who believe strongly in homeopathy.

Do you reject analytics because the answers are obvious and it will just tell you what you already know? You're a corporate homeopath.

Rejecting ideas that don't work is real progress and a truly valuable exercise. It's how we learn; we try something, we reject it, we have a think and then we try something else until we find a method that works.

You can often spot a good analyst by the way that they approach problem solving. If you ask a good analyst why sales are declining, they'll come up with a whole host of different possibilities and then work with data to disprove them - one at a time - until they're left with the most plausible explanation. It's a process and it's the true value of analysis. It stops us from accepting hypotheses that aren't true; from blaming bad weather, or bad luck for under-performance, when really our business has systematic problems.

Sam Allardyce (the West Ham manager) talked this week about using statistical analysis in football and it's fantastic to see this type of discussion starting to gain real traction. Something that he said struck me as slightly jarring though.


"You can take out of it what you want. You can find your best performance in each area. You can find your best performance on fitness level, you can find your best performance in possession…"




It might just be throwaway phrasing from the interview, but that could also be heading firmly in the direction of confirmation bias. If you analyse your best performances, you'll find the occasions when what you tried appeared to work. Your worst performances are often a lot more valuable, because you're forced down a route of working out why they were bad and then coming up with ideas to fix them.

Very often, I find that analytics sceptics are those who are looking to confirm the effectiveness of the strategy that they're already employing. It's self-fulfilling then, that your analysis won't be able to teach you anything new. At best, analysis like this is an internal marketing tool; a way to 'prove' you're right and end any debate about other options and in the short term - until everybody works out that's what you're doing - it might be somewhat effective at that job. EMI was determinedly doing using analytics like that for the short time I was employed there. Before reality struck and it was broken up and sold.


Good analytics...

Proves conclusively that bad ideas aren't working

And so forces you to think up new ideas

Which you can then analyse to see if they're an improvement


Good analytics...

Gets you there faster. Of course you'll work out eventually that a bad idea isn't working, but wouldn't you rather know now, before it's too late?

And finally, good analytics will prompt new ideas, by giving you details about what went wrong with the old ones.


There are so many other benefits of taking an analytical approach to a problem, but this is the big one. This is what statistical analysis is really good at and this is my answer when faced with scepticism. Of course analytics can't solve every problem, but used correctly, it can solve a very, very big one.

Thursday, 26 September 2013

Off the corporate grid part 1: Cheerio Windows

I wrote a post a while ago about how I planned to try a little geek project of dropping myself off the corporate web. No more free GMail, other Google tools, or Microsoft Windows... and see how much I miss them. Is 'free' worth the price?

This post is part one - dumping Windows for Linux on an old laptop.

Tech skills needed:  4/10
Worth the effort:  8/10
Value for money: 10/10

I'm very much writing here from the point of view of somebody who'd like to give Linux a try, but ease of use is a major priority. I know that for many people, Linux is a rewarding investment of their time and some enjoy battling to make a piece of software work properly. Screw that. Day to day, using a computer should be easy. I've probably got some terminology wrong below and been floundering around with issues that an expert wouldn't even have noticed, but that's part of the point - can an average user get by without Windows?

Before starting this little exercise, I knew what Linux was - an Open Source (free) alternative to Windows - but I'd never used it, beyond a quick hack to get some files off a dead PC (of which more later). Of the few people I'd talked to about Linux, a couple are serious tech experts who are definitely up for some hardcore IT fettling, and one was annoyed that he'd bought a netbook with Linux on it, rather than Windows, and it wouldn't talk to a few of his other gadgets.

I suspect that along with a lot of other people, I had a vague feeling using Linux would involve battling with screens like this:


But don't worry, it doesn't.

As a new user, the biggest problem you face after deciding to maybe give it a go, is in working out what to install.

Google "install Linux" and the top link is to "Red hat enterprise Linux". This looks complicated. It's not what you want.

Then after a bit more reading, you find out Linux comes in distributions and that there are quite a few. Distributions are like different skins; they all use the Linux kernel as the central architecture that makes them work, but they behave in different ways, with alternative looks. You need to choose which distribution to install and now you find yourself on a website like this.


Oh, for Pete's sake.

I strongly suspect at this stage a lot of people say, "oh, sod it, I can't be bothered" and go back to Windows. I've certainly done that once before. This time I'd made a promise on my blog though, so pick a card... any card...

Linux Mint is top of the popularity list. Let's install that.

Wikipedia says Linux Mint

"is a Linux distribution for desktop computers, based on Ubuntu or Debian."


and that Ubuntu

"is an operating system based on the Linux kernel and the Linux distribution Debian, with Unity as its default desktop environment."


And I say if Linux wants more mainstream adoption (which I assume it does) then it needs to stop making things so bloody difficult.

Mint is easy to install and easy to use. You don't need to know what Debian or Unity are. I've only got a vague idea what they are. I might find out at some point but you really don't need to.

Mint has a nice clean homepage, with a prominent download button.

Unfortunately, when you click through to the downloads page, there are too many options for an IT novice. You thought you'd solved the problem of which distribution you want? Well Mint comes in several different flavours too. Somebody's doing this on purpose.

This page badly needs a big, fat, "Don't know what to install? You want this!" button. At least the one you want is at the top of the list: Linux Mint Cinnamon.

You've just done the hardest bit. I'm not kidding, the hardest bit of using Linux is working out what on earth to install in the first place.

Download Cinnamon (32 bit or 64 bit depending on your PC) and then you'll need to make a disk to install it with. It comes as an ISO file, which is the contents of a DVD, ripped onto a file. If you don't already know how to turn that into a DVD, then a quick Google will turn up lots of software, or you can follow this easy guide.

Congratulations, you've got an installation disk! That was definitely harder than buying a Windows installation disk, but it was quite a bit cheaper too.

You can actually use your disk straight away by putting it in the drive and then rebooting your PC. It should boot straight to the Mint desktop, which is bloody handy if your copy of Windows ever takes a dive and you need to get all of your files back. I've rescued videos and music from a laptop like this in the past, when Windows flatly refused to either boot, or reinstall.

You won't want to run Mint from CD all the time though, because it's slow and doesn't remember anything when you turn off your computer,

To install properly, you click on the desktop icon and it's easy from there, but you have a choice to make. Do you want to clear Windows off your laptop completely (copy your files somewhere first!), or do you want to 'dual boot' so that you'll be asked whether to start Windows or Mint when you turn on the PC?

We're just experimenting here and clearing Windows altogether feels a bit rash, so dual boot is probably best.

You'll need somewhere to put Mint, so you have to create a partition on your hard drive, using Windows. This guide explains how.

And now you can install it from the DVD you made.

And we're done. So what's it like?

Well it's like Windows. It looks like Windows and it acts pretty much like Windows too. It's even got a Start menu that pops up when you press the Start button. I'd be willing to bet that if I put it on my grandmother's laptop, she'd barely notice.


(don't worry, you can change the background image, just like Windows)

On an old laptop, you'll find it starts up faster and it doesn't do the special Windows boot thing of looking like it's ready, but keeping you waiting for another five minutes before you can actually open a program.

The web browser runs faster and doesn't hang all the time. (I know you can put Firefox on Windows too but it's an old laptop and it never really ran Windows Vista properly.)

I swear the laptop battery lasts longer.

These are all big ticks. Linux is a much lighter load on the PC, so if you've got a laptop that's getting on a bit and that is only really used for web browsing, you'll find it's a much faster, slicker experience.

Mint comes with Libre Office, which is a more than passable alternative to Microsoft Office and can still open all of your .doc and .xls files. If you don't need VBA macros and heavyweight Excel workbooks, it's great.

The best recommendation I can make for Mint is that since making our old laptop dual boot about a month ago, I've only touched Windows once, because I needed it to talk to a GPS and it has the drivers built in. My wife hasn't used Windows at all. Why would you? For simple tasks, Linux just works better. It's only more obscure gadgets that are an issue too - plugging in a digital camera or a USB thumb drive is fine.

I have found myself on a few forums, learning some more complicated bits and pieces when I wanted to push beyond simple web browsing and admittedly I wasn't able to make Google Picasa work properly, even though it's supposed to. All in all though, if you want basic features, Linux is brilliant. If you want more than basic features you can certainly have them, but you'll need to get your hands dirty.

The only real difficulty I found for Mint was that when it first started up, everything worked perfectly except wifi. This is because the wifi card needs a proprietary driver, which Mint had found, but didn't activate automatically. Easily fixed through a simple menu, but I'd have liked a pop up on the first boot, prompting me that Mint already knew how to make the card work and asking if I wanted it switched on. As it is, it's possible a less curious user would have just assumed Mint didn't work with their laptop.


In terms of dumping the corporate web, this one's a 'not quite', but well worth doing all the same. There's no way I could survive without Windows at work (no Excel, Tableau, SQL Server...? Not going to happen) and at home it would probably wind me up about once a month that something Windows is able to do, was difficult or impossible with Linux.

You can have the best of both worlds though. A slick, fast experience that's not beholden to Microsoft for 90% of the time and a quick boot into Windows when you have to. I'm impressed. This has been a really worthwhile little experiment and I'd thoroughly recommend it.

Wednesday, 18 September 2013

Luck in football part 2. Can you have a lucky season?


"It evens itself out over a season and that will never change. You get breaks here and there. Every club gets good breaks, bad breaks."

Sir Alex Ferguson


Does it though? Does luck even itself out across a season? This is a follow up to my post a couple of weeks ago, looking at how much luck there is in a single English Premier League result. The obvious next step is to try to extend that analysis to a thirty eight game season and see whether, over a larger number of games, most of the random chance in football then disappears.

Before we dive into the analysis, it's useful to think about what level of luck might feel right for an average team, in terms of the number of points that team finishes with, compared to how many points they 'should' get. Plus or minus a point across a season? That obviously could happen - you sneak one extra draw, or rattle the bar in the 90th minute at 1-0 down just once in the season and there's your extra point either way. One lucky won or lost game is also pretty easy to envisage, or maybe even two lucky wins or losses. Three lucky wins and nine points? For me that's within the bounds of possibility, but starting to feel more unlikely.

From a statistical point of view, thirty eight games per team isn't all that many, so some level of randomness is definitely going to creep in. The challenge is to work out how much randomness and whether it matters in the grand scheme of things. Whether the league table is random enough that the best team won't always win the title, or if an unlucky mid-table standard team can get relegated.

Working out random chance across a whole season is more difficult than working it out for a single game against the hypothetical 'average opponent' that we saw in my last blog post. In response to that previous post, a few people asked how you'd set up a team's chances against a specific opponent, rather than a generalised 'average' one, which illustrates one of the key problems. If you could predict goal scoring and concession rates against a specific opponent, then you could predict the final score. Then you'd be able to beat the bookies and make a lot of money. Which is hard. In essence this is what my prediction model tries to do and is too complex to form a base for this analysis.

For this post, I'm going to assume that bookmakers' odds are a fair representation of each team's chances in a game and use that as the basis to simulate a season. You can argue with that approach, but I have a suspicion it's going to cause fewer arguments than any other results prediction method that I might use.

At least everybody can see where these numbers have come from and as an added defence for this method, if the bookies odds were consistently wrong across a lot of teams, across the whole season, they'd be losing a fortune.


"There are known knowns. These are things we know that we know. There are known unknowns. That is to say, there are things that we know we don't know. But there are also unknown unknowns. There are things we don't know we don't know."

Donald Rumsfeld


OK, that's probably not very helpful. The reason for the quote is because the bookies odds aren't perfect and it is possible to predict better than they do, which might reduce the amount of 'luck' (can we call it random variation instead?) that we're about to measure. It's possible to consistently predict better than the bookies and there are also all of the factors about a game that neither we, nor the bookies know. If a manager plays his best striker - who's nursing an injury - and loses due to a poor performance, that's not bad luck, it's a bad call. But if we didn't know about the injury then it won't have been priced into the market odds.

What really matters for this post isn't that we have brilliant odds for each individual game, but that we have a fair representation of what a season looks like as a whole, so that we can run simulations. It's not about the individual teams, it's about having a realistic spread of probabilities across a season's 380 games and for this, betting odds should do a good job.

I'll come back to the definition of luck and the implications of using betting odds at the end of this post, but let's get stuck into some numbers. Here are Arsenal's odds for each game last season, taken from Bet365 and re-based to remove the bookmaker's margin so they sum to 100%. (data from www.football-data.co.uk/englandm.php)


If you run that fixture list ten thousand times with those odds, on average Arsenal will finish with seventy points. They scored seventy three points in 2012/13, so on that (huge!) sample of one season at least, the odds-based method seems sensible.

We get a distribution of points for Arsenal using our ten thousand simulated seasons, which looks like this.



Sometimes Arsenal will score fewer than seventy points and sometimes they'll score more, purely through random variation, or 'luck'. The standard deviation of Arsenal's final total is 7.5 points, which means that although the average is seventy, in any given season Arsenal are likely to do seven points better or worse than that. In 66% of seasons, their final total would fall between sixty five and seventy nine points.

One simulation in ten thousand, last season's Arsenal squad is ridiculously unlucky and gets relegated with less than the magic forty point total. This might sound far fetched until you consider that it's a one in ten thousand chance and there have only been 126 seasons of professional football in England, in total, ever. The chances of relegation happening to last season's Arsenal squad are vanishingly small.

Running the same ten thousand season simulation exercise for each team in last year's Premier League, gives you the following points distributions.



We've got a clear top two, a fairly well ordered top seven including Everton and then feasibly any team from eighth downwards could be relegated. Ouch.

We can translate those points totals into finishing positions for each team in each of the ten thousand simulated seasons, to get a likelihood of achieving different positions. Some of the randomness starts to disappear here, because for a team like Newcastle or Fulham to be relegated doesn't just need them to be unlucky. Other teams below them need to be lucky too.



And because I know you're going to want the raw percentages for those...



Were Newcastle unlucky to finish 16th last season? I'll leave that as a rhetorical question.

Picking on Liverpool, a team with their 2012/13 chances in each game (and please note how careful I'm being with my words here; not Liverpool, but a hypothetical team whose chances were exactly represented by the odds Bet365 gave Liverpool last season) would win the league by 'luck' one year in twenty (5%).

The analysis has turned up one more result and it's a result I found quite surprising. Before running any numbers, I'd hypothesised in an email exchange with @SimonGleave that good teams and bad teams would have less randomness in their points total, with average quality teams seeing the most random variation. The reasoning for this crudely being that good teams win a lot and bad teams get beaten a lot and both of those things reduce the space for luck to play a role.

I was wrong.

Here are the standard deviations of season points totals for each team in 2012/13.


Everybody scores plus or minus seven points. Weird.

What that does mean in effect though, is that teams higher up the table have less random chance as a proportion of their total points, than teams lower down, since seven is obviously a much larger proportion of forty points, than of ninety points.



We have a standard deviation 'luck' (I still don't like that word) measure varying from 9% of Man City and Man U's most likely points totals, through to 20% of Reading's.

My hypothesis about why seven appears to be the magic number for all teams is that every team has a number of peers - teams they're similar to and will share points with - and a number of teams that they're either much better or much worse than. This gives every team a similar number of games with fairly uncertain results, where points will be shared, compared with fairly certain ones, whether that's fairly certain to win or to lose.

I've linked to this piece of work before, but it's reassuring how close this result is to the key finding of plus or minus eight points in a post by James Grayson, which kicked off this whole thought process for me. My initial reaction to that number was that it felt too big, but now I'm coming to a very similar conclusion.

I do think we should be treating these numbers as a maximum level of random variation though, because in reality teams will react to their league position and try to change their chances. Teams with more financial resources will be able to react to an unlucky first half of the season by signing players and improving their odds in the second half.

Better predictions than bookmakers manage could also reduce the amount of measured luck, because we'd be more certain about which team should win each game, reducing the level of random variation in results. As I said earlier, the bookies aren't perfect (just annoyingly good) so this should definitely play a role in reducing the true standard deviation below seven.

Finally we're also back to the core question of what is luck? I'm not at all sure when most people say 'luck' that they intuitively mean 'random variation'. It's more nuanced than that. Steve Fenn (@SoccerStatHunt) tweeted a nice definition yesterday:



The key word here being 'unearned'. This got me thinking that you're lucky if:


So what's 'consistently'? I think this goes to the heart of what we'd intuitively define as lucky. In the simulations above, Manchester United had a 36% chance of winning the title, just about equal with Manchester City. If either of those teams win, are they lucky? They've got the best chances out of any team, but 36% isn't huge - it leaves a 64% chance that some other team wins it, which is much more likely.

By those percentages alone, you'd always need luck to win the title.

If you win a single game that you had a 49% chance of winning, were you lucky? After all, there was slightly more chance that you wouldn't win it.

What we mean by luck, seems to be lurking somewhere in an area of 'beating a team that played significantly better than we did'. For me, 'lucky' has an intrinsic element of fairness in its definition. Lucky wins are unfair. Things shouldn't have happened that way. Somebody else deserved the win.

That's why luck is so hard to define - because it's subjective. Your definition and mine could well be different. As a neutral, I'd say a non-league team with a 5% chance of beating a Premier League opponent in the FA Cup third round deserves everything they manage to achieve. A fan of the losing Premier League team, who's going to take a pasting in work on Monday, would probably call them lucky bastards.

What we have shown here, is that bookmakers' odds suggest we're watching a league where in any one single season, each team's points will swing plus or minus seven from their most likely total. That could well be enough to relegate an undeserving team. Of course, that's undeserving depending on whether you support that particular team and depending on where you, personally, draw the percentage line on 'unlucky'.