**R on I Should Be Writing: The Musical**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Much has been said about how the game of Quidditch is ruined by the scoring system – specifically how it makes no sense that the snitch is worth 150 points *and* that catching it ends the game (1, 2, 3). Most of these arguments seem to revolve around the claim that it is nearly impossible to win a match of Quidditch without catching the snitch. Is this true? Let’s try and answer this question formally using statistics and R simulations:

What is the probability of winning a Quidditch match without catching the snitch?

*Victor Krum caught the snitch for Bulgaria, but Ireland still won (1994 World cup)*

## The Game, the Rules

Quidditch is a fictional team sport played on broomsticks, devised by author J. K. Rowling, that is played by wizards in the fantasy world of Harry Potter. Like any sport, the game of Quidditch has many rules, but I will summarize here only the ones pertinent to our discussion:

- 10 points are gained by throwing the Quaffle through one of the opponent team’s three hoops.
- 150 points are gained by catching the Golden Snitch, which can only be caught by the Seeker.
- The game ends when the Golden Snitch is caught.
- The winning team is the one has the most points at the end of the game.

Given these rules and game objectives, in order to estimate the probability of winning a match we must first estimate (1) how long does it take a seeker to catch the Snitch on average, which determines how long a game lasts and thus how much time is allotted for the teams to score goals, and (2) what is the rate of goal scoring.

### Estimating the Average Game Length

Unfortunately, not many pro-Quidditch matches are described in the books, so this is quite hard to estimate. On the one hand, the only game that is described in its entirety is the 1994 Quidditch World Cup final, and it was extremely short: only 15 minutes or so (4]); On the other hand, the longest game ever lasted 3 months (5]). So the average is somewhere between 15 minutes, and 130,000 minutes… great.

For the sake of our simulations, then, I will assume the average game lasts 90 minutes (assuming Rowling has soccer or rugby in mind). I will also assume that the length of a Quidditch game is exponentially distributed, since the probability of catching the Snitch remains constant (as opposed to it getting easier as the game progresses) – the Snitch’s ability to escape capture does not change (magic) and players are substituted throughout the game, so let’s assume an unchanging level of vigilance.

Together, the distribution of game lengths looks something like this:

This makes the 3 month long game very unlikely ( \(Pr(time>130,000)<10^{-600}\) ), but the 15 minute game rather probable ( \(Pr(time<15)=0.15\) ).

### Estimating the Rate of Goals Scored

Throughout the books, the final scores of several Quidditch games are mentioned, but since we don’t know their lengths, it is hard to estimate the rate of goals-per-minute (GPM). Going by the 15 minute world cup, in which the final score was 170-160, or 170-10 if only counting goal points, we can see that there were 18 goals in 15 minutes, or an average of 9 goals per 15 minutes per team, or a GPM of 0.6 (or 0.07 for Bulgaria, and 1.13 for Ireland). Though this is only one game, and a very short one at that, these numbers seem close to the averages seen in basketball, where GPM are around 40/48 = 0.83 (6). This is also in line with the game’s depiction in the films as a fast sport, with many goals scored quickly and in succession.

I will also assume that this rate is constant and unchanging throughout the game, regardless of the score (or fatigue of the players, see above), and so will assume GPM has a poisson distribution, with an average of 0.8, making the GPM distribution look something like this:

## Simulating the Games

(If you’re not that into reading raw code, you can just skip to the conclusions at the end.)

### R Setup

```
set.seed(1994)
sim_quidditch <- function(mean_game_durA, mean_game_durB, GPM_A, GPM_B,
snitch_points = 150, goal_points = 10,
n_sims = 1e6) {
# Sim game durations and snitch Points ------------------------------------
mean_game_dur_rateA <- 1/mean_game_durA
mean_game_dur_rateB <- 1/mean_game_durB
game_dursA <- rexp(n_sims, rate = mean_game_dur_rateA)
game_dursB <- rexp(n_sims, rate = mean_game_dur_rateB)
# Final game durations
game_durs <- ifelse(game_dursA < game_dursB, game_dursA, game_dursB)
# Who got the snitch (and the points)
got_snitch <- game_dursA < game_dursB
snitch_pointsA <- got_snitch * snitch_points
snitch_pointsB <- (1-got_snitch) * snitch_points
# Sim goals and goal points -----------------------------------------------
# Based on the length of the game
goal_pointsA <- rpois(n_sims,GPM_A*floor(game_durs)) * goal_points
goal_pointsB <- rpois(n_sims,GPM_B*floor(game_durs)) * goal_points
# Find Winner -------------------------------------------------------------
total_pointA <- snitch_pointsA + goal_pointsA
total_pointB <- snitch_pointsB + goal_pointsB
who_won <- rep(NA_character_,n_sims)
who_won[total_pointA > total_pointB] <- 'A'
who_won[total_pointA < total_pointB] <- 'B'
list(teamA_points = total_pointA,
teamB_points = total_pointB,
Winner = factor(who_won),
Got_snitch = factor(ifelse(got_snitch,'A','B')))
}
```

### Equal Teams

Let’s start by simulating 1 million games between two teams with equal GPMs and equally good seekers.

```
res <- sim_quidditch(mean_game_durA = 90, # in mins
mean_game_durB = 90,
GPM_A = 0.8,
GPM_B = 0.8)
with(res,{
table(Winner) /
length(Winner)
})
```

```
## Winner
## A B
## 0.497066 0.496060
```

Under these conditions, the probability of winning a game without catching the snitch is:

```
with(res, {
mean(Winner[!is.na(Winner)] != Got_snitch[!is.na(Winner)])
})
```

`## [1] 0.03747158`

3.75%! Hmm, that does seem quite unfair… Though it does put Fred and George’s gambling odds at around 1:20!

How many games were determined by the snitch – i.e., had the snitch been caught at the same time by the other team, they would have won?

```
with(res, {
(
sum(teamA_points[Winner == 'A'] - 150 < teamB_points[Winner == 'A'] + 150, na.rm = T) +
sum(teamA_points[Winner == 'B'] + 150 > teamB_points[Winner == 'B'] - 150, na.rm = T)
) / 1e6
})
```

`## [1] 0.94918`

94.9%! Not the best of odds…

### Unequal (but matched) Teams

But just like in real sports, different teams have different strengths… Let’s see what happens when we create two teams who have an equal probability of winning, but differ in terms of their seekers and GPMs.

After some trial and error, I found that if we have a team with a seeker who catches the snitch within 67 minutes on average and a GPM of 0.71, versus a team with a seeker who catches the snitch in within 113 minutes on average but with a GPM of 0.90, both teams have a 50% chance of winning.

```
res <- sim_quidditch(mean_game_durA = 67, # in mins
mean_game_durB = 113,
GPM_A = 0.71,
GPM_B = 0.90)
with(res,{
table(Winner)/length(Winner)
})
```

```
## Winner
## A B
## 0.497701 0.490796
```

So, what is the chance of winning without catching the snitch?

```
with(res,{
mean(Winner[!is.na(Winner)] != Got_snitch[!is.na(Winner)])
})
```

`## [1] 0.1213732`

12.2%! Still pretty low… very disappointing. Let’s explore each team separately:

```
with(res,{
table(Winner, Got_snitch)
})
```

```
## Got_snitch
## Winner A B
## A 497218 483
## B 119494 371302
```

It seems that 99.9% of team A’s wins were due to their better seeker…

…but that only 24.3% of team B’s wins were achieved by their weaker seeker T!

How many games were determined by the snitch?

```
with(res, {
(
sum(teamA_points[Winner == 'A'] - 150 < teamB_points[Winner == 'A'] + 150, na.rm = T) +
sum(teamA_points[Winner == 'B'] + 150 > teamB_points[Winner == 'B'] - 150, na.rm = T)
) / 1e6
})
```

`## [1] 0.901089`

90.1%!

## Conclusion

- If you’ve caught the snitch, you’ve probably won.
- If you’ve won, you probably caught the snitch.
- If you’ve lost, catching the snitch would have probably changed that.

But… the majority of points are non-snitch related. And it seems to me unlikely that you would have a seeker that was twice as good as the opposing team’s, and so compensating for a weaker seeker seems very likely given this simulation. SO it’s probably best to invest in a better chaser who can bring up your GPM and a better keeper who can lower your opponents’ GPM, than in a seeker who can shave 5 minutes off of his snitch catching time…

Also, maybe someone should change the rules? Perhaps the snitch should only be worth 30 points?

**leave a comment**for the author, please follow the link and comment on their blog:

**R on I Should Be Writing: The Musical**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.