Showing posts with label rating. Show all posts
Showing posts with label rating. Show all posts

Sunday, February 4, 2007

The Reverend Bayes and tennis probability, Part II

For our Big Bayesian Experiment, let's take an example from 2005, which is the tennis-data spreadsheet I currently have open. Roger Federer* took on Andre Agassi in the semi-final of the Dubai Duty Free men's tournament on Feb. 26th. A little over a month earlier, they played in the quarter-finals of the Australian Open, which Federer won handily, 6-3, 6-4, 6-4.

I'm going to take a very simple model of tennis, one which could almost certainly be improved by taking into account strength of serve and the number of service breaks in each set - unfortunately, I have neither the data, the programming skill nor the patience to put that kind of model into effect for a short blog article. Anyway, contrary to all good sense, I'll assume that each game has an identical probability of each player winning, and that parameter carries forward to the next match.

And to begin with, let's also assume that we know nothing about Federer and Agassi - the chance of Federer being a Scottish no-hoper and having no chance of getting near Agassi (pF=0, pA=1) is the same as that of the roles being reversed (pF=1, pA=0) - all values of pF are equally likely. This is our prior distribution. We're looking for a posterior distribution of pF - how likely each value of the variable is.

There's some number-crunching to be done here. What we're going to do is examine every (well, almost) possible value of pF, find the probability for each of Federer winning the match with that score, and examine the distribution that comes out. Some examples:


.pF. P(6-3) P(6-4) P(6-3, 6-4, 6-4)
0.40 0.0493 0.0666 0.00022
0.50 0.1091 0.1228 0.00165
0.60 0.1670 0.1505 0.00378
0.70 0.1780 0.1204 0.00258


The highest of these is 0.60 (in fact, the most likely value for pF is the number of games he won - 18 - over the number played - 29 - or about 0.62). The number-crunching (combined with NeoOffice) give a nice graph of the likelihoods, which I reproduce here:




You can see that the peak of the PDF (I won't go into the terminology here, it's getting long) is indeed around 0.62 (0.6207, to be precise). But we're interested in a confidence range, for which we read off of the CDF the pF values for P at various levels. For instance, we're 95% certain that pF lies between the 0.025 level and the 0.975 level - i.e. between 0.4385 and 0.7734. We're 50% sure that it lies between the 0.25 and 0.75 levels - so between 0.5550 and 0.6734.

How does this help us? Well, it narrows down pF substantially - remember, we didn't have a clue what it was before. Now we can say with some certainty where it isn't - it's unlikely to be more than 0.7734 or less than 0.4385, eliminating almost two-thirds of the possible values at a stroke. It's as likely as not to be in the range [0.5550, 0.6734]. Can we translate this into a match probability for the next game? Of course. Again, it's a number-crunching exercise, but we get the following for our key values of pF:


..pF.. P(Set) P(2-0) P(2-1) P(Win)
0.4385 0.3307 0.1093 0.1464 0.2557
0.5550 0.6522 0.4253 0.2959 0.7217
0.6207 0.8075 0.6250 0.2510 0.8760
0.6734 0.8977 0.8058 0.1649 0.9707
0.7734 0.9825 0.9653 0.0338 0.9991


This tells us: the most likely probability of Federer beating Agassi in two sets is 87.6% (1.14), that it's as likely as not to be between 72.17% (1.39) and 97.07% (1.03), and 95% certain to be between 25.57 (3.91) and 0.9991 (1.001). In the event, the best available odds were 1.35 with Expekt - and depending on how much confidence-in-value we wanted, we would take those and reap the benefit of Federer's 6-3, 6-1 demolition job.

This system is, I have to stress, very basic and currently only works if the two players met in the recent past. In the next instalment, I might have a shot at a link function so we can rate players who haven't met recently - but have played a common opponent.

* easy to spell; difficult to stop spelling

Friday, January 26, 2007

ELO, Élö, it's good to be back

So far, I haven't said anything at all about sports or rating systems. The sports thing, well, that's only going to change tangentially. The thrust of this piece is going to describe one of the best-known rating systems, the Élö system. I'm going to get tired of the accents, which may not show up on all systems, so I'll revert to calling it Elo like everyone else.

Elo is primarily used for chess. The basic premise is to compare how well a player did over a given time frame - say the number of games he* won in a month - with how well he ought to have done, given his ranking and his opponents'. At the end of the time period, his rating is adjusted to take those games into account.

That description leaves at least two questions: how do we know how well he ought to have done? and, how do we adjust the rating afterwards?

How well the player ought to have done depends on who he's played - if he's played ten games against Deep Blue, he might be expected to win one, if he's really good. Against my girlfriend's cat Darwin? Probably seven, if Darwin's on form. In fact, the number of games he's expected to win is the sum of the probabilities of each individual game**.

All well and good. But how do we figure out the probabilities of each game, given the ratings? This, unavoidably, is going to require some maths. If you have a rating of, say, 1700, and Darwin (who's only just started playing chess) is ranked at 1500, you have a rating difference (D) of +200. From Darwin's point of view, it's -200. The probability of you beating him is 1/(1 + 10(-0.025 D))***. In this case, that's 1/(1 + 10-0.5), or 1/(1 + 0.32), about 0.76. For Darwin, if you'd like to do the sums, it's 1/(1 + 3.16), or 0.24. Note that the probabilities add up to one, as they ought to****. Over ten games, you'd expect to win 7.60, while Darwin makes do with 2.4. (Incidentally, he plays worse if you throw a ball for him to chase.)

So, let's say you played ten games against Deep Blue - we'll say it has an Elo rating of 2800 - (D = -1100 for you) your probability for each game is very small (0.18% - about one in 550). In ten games, you'd expect to win about 0.02. Let's say you did well against Darwin and picked him off eight times, and Deep Blue creamed you, as is its way. You won eight games (W=8), and your expected number of wins was E=7.62 - you did better than expected by 0.38 wins. Very good.

The last step of the process is to adjust your rating. A certain weighting (K) is given to your recent results - in chess, it's usually about K=12, but in later articles I'll hopefully determine what the best values for tennis are. In this case, your rating goes up by K(W-E), or 4.62 points. Your new rating would be 1705 (rounded off).



* or she. Take that as read pretty much everywhere in this blog.

** For the mathematicians: The expected number of wins is sum(p_i) +/- sqrt(sum(p_i . (1 - p_i))).

*** The 0.025 is arbitrary, but the only difference it makes (so far as I can see) is to the spacing of rankings.

**** ... so long as we exclude the draw as a possible result. Which we do, for simplicity's sake.