### The Infamous Monty Hall

A (Brief) History:

The Monty Hall problem is arguably the most infamous probability puzzle in recent history. It was originally proposed in its current form in 1975, but only really surged into the public spotlight in 1990 when in appeared in a Parade column written by Marilyn vos Savant. For more details on the history of this problem see Wikipedia: Monty Hall problem.

The Original:

As given in Marilyn's column the problem read:
Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1 [but the door is not opened], and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says to you, "Do you want to pick door No. 2?" Is it to your advantage to switch your choice?
The phrasing here is ambiguous. Does Monty always show you a goat? Does he only show you a goat when switching would lead to a win? Does he only show you a goat when switching would lead to a loss? In fact, Monty could assign you any probability $$p$$ of winning when switching that he wanted. All Monty needs to do is with probability $$p$$ only show you a goat if switching wins; otherwise, he'd only show you a goat if switching loses. Some of the unstated assumptions undoubtedly led to additional confusion in what's already a conceptually difficult problem for many people.

Unambiguous Phrasing (Krauss and Wang 2003):
Suppose you're on a game show and you're given the choice of three doors [and will win what is behind the chosen door]. Behind one door is a car; behind the others, goats [unwanted booby prizes]. The car and the goats were placed randomly behind the doors before the show. The rules of the game show are as follows: After you have chosen a door, the door remains closed for the time being. The game show host, Monty Hall, who knows what is behind the doors, now has to open one of the two remaining doors, and the door he opens must have a goat behind it. If both remaining doors have goats behind them, he chooses one [uniformly] at random. After Monty Hall opens a door with a goat, he will ask you to decide whether you want to stay with your first choice or to switch to the last remaining door. Imagine that you chose Door 1 and the host opens Door 3, which has a goat. He then asks you "Do you want to switch to Door Number 2?" Is it to your advantage to change your choice?
Solution:

Standing, of course, gives us a $$1/3$$ probability of winning. But what if we switch? Well, the car is behind one of the doors, and if it's behind Door 1 with probability $$1/3$$ it must be behind one of the remaining two doors with probability $$2/3$$. But it's not behind Door 3 because Monty just showed us a goat. Aha, so the probability that the prize is behind Door 2 must be $$2/3$$ now, so we should switch! Another way of seeing that this is correct is to pretend that you close your eyes and cover your ears right before Monty Hall reveals the goat. Now by switching you'll win the prize if it's behind either Door 2 or Door 3, so your probability of winning increases from $$1/3$$ to $$2/3$$ by switching.

My next entry will be a solution using Bayes' Theorem.

### A Bayes' Solution to Monty Hall

For any problem involving conditional probabilities one of your greatest allies is Bayes' Theorem. Bayes' Theorem says that for two events A and B, the probability of A given B is related to the probability of B given A in a specific way.

Standard notation:

probability of A given B is written $$\Pr(A \mid B)$$
probability of B is written $$\Pr(B)$$

Bayes' Theorem:

Using the notation above, Bayes' Theorem can be written: $\Pr(A \mid B) = \frac{\Pr(B \mid A)\times \Pr(A)}{\Pr(B)}$Let's apply Bayes' Theorem to the Monty Hall problem. If you recall, we're told that behind three doors there are two goats and one car, all randomly placed. We initially choose a door, and then Monty, who knows what's behind the doors, always shows us a goat behind one of the remaining doors. He can always do this as there are two goats; if we chose the car initially, Monty picks one of the two doors with a goat behind it at random.

Assume we pick Door 1 and then Monty sho…

### What's the Value of a Win?

In a previous entry I demonstrated one simple way to estimate an exponent for the Pythagorean win expectation. Another nice consequence of a Pythagorean win expectation formula is that it also makes it simple to estimate the run value of a win in baseball, the point value of a win in basketball, the goal value of a win in hockey etc.

Let our Pythagorean win expectation formula be $w=\frac{P^e}{P^e+1},$ where $$w$$ is the win fraction expectation, $$P$$ is runs/allowed (or similar) and $$e$$ is the Pythagorean exponent. How do we get an estimate for the run value of a win? The expected number of games won in a season with $$g$$ games is $W = g\cdot w = g\cdot \frac{P^e}{P^e+1},$ so for one estimate we only need to compute the value of the partial derivative $$\frac{\partial W}{\partial P}$$ at $$P=1$$. Note that $W = g\left( 1-\frac{1}{P^e+1}\right),$ and so $\frac{\partial W}{\partial P} = g\frac{eP^{e-1}}{(P^e+1)^2}$ and it follows \[ \frac{\partial W}{\partial P}(P=1) = …

### Mixed Models in R - Bigger, Faster, Stronger

When you start doing more advanced sports analytics you'll eventually starting working with what are known as hierarchical, nested or mixed effects models. These are models that contain both fixed and random effects. There are multiple ways of defining fixed vs random random effects, but one way I find particularly useful is that random effects are being "predicted" rather than "estimated", and this in turn involves some "shrinkage" towards the mean.

Here's some R code for NCAA ice hockey power rankings using a nested Poisson model (which can be found in my hockey GitHub repository):
model <- gs ~ year+field+d_div+o_div+game_length+(1|offense)+(1|defense)+(1|game_id) fit <- glmer(model, data=g, verbose=TRUE, family=poisson(link=log) ) The fixed effects are year, field (home/away/neutral), d_div (NCAA division of the defense), o_div (NCAA division of the offense) and game_length (number of overtime periods); off…