### The Good, the Bad and the Weird: Duels and the Gentleman's Draw

As I mentioned in the previous article "The Good, the Bad and the Weird: Duels, Truels and Utility Functions", a classic probability puzzle involves a 3-way duel (called a "truel").
A, B and C are to fight a three-cornered pistol duel. All know that A's chance of hitting his target is 0.3, C's is 0.5, and B never misses. They are to fire at their choice of target in succession in the order A, B, C, cyclically (but a hit man loses further turns and is no longer shot at) until only one man is left unit. What should A's strategy be?
There's a subtle issue involved in these types of problems in that we don't know how each participant values each outcome. If we allow duelists to deliberately miss there are $$2^3-1=7$$ possible outcomes; each person may or may not be shot and at least one person will not be shot. Even if deliberate missing isn't allowed, there are still 3 possible outcomes. A, for example, could conceivably value B winning more than C winning.

The classic solution concludes that with the given hit probabilities the optimal strategy for the first trueler is to deliberately miss. My contention is that this is an incomplete solution; for some sets of utility values this may not be the first trueler's optimal strategy. Let's examine duels using utility values as the first step towards addressing truels.

Let the two duelers have hit probabilities $$p_i$$ for $$i=1,2$$, and also let the values each assigns to a dueling win, loss or tie be $$W_i, L_i, T_i$$. I'm assuming these values are all known to both duelers and that $$W_i > T_i > L_i$$. Note that a strategy that optimizes expected utility is preserved under a positive affine transformation, so under the assumption that all values are finite, we may assume $$W_i=1$$ and $$L_i=0$$ for all $$i$$.

We'll declare the duel a "gentleman's draw" if both duelers deliberately miss in a single round. Let the expected utility value for dueler $$i$$ be $$U_i$$.

Trivially, if the optimal strategy for dueler 1 is trying for a hit, the optimal strategy for dueler 2 must be to also try for a hit. Conversely, the optimal strategy for dueler 1 can be to deliberately miss if and only if the optimal strategy for dueler 2 is also to deliberately miss. Assume the draw is taken if there's indifference (they are, after all, gentlemen).

If dueler 1 deliberately misses, dueler 2 has two choices. If he deliberately misses, it's a gentleman's draw and $$U_2 = T_2$$; if he tries for a hit, both duelers will subsequently try to hit each other and $$U_2 = p_2 + q_2 q_1 U_2$$. Solving, we get $U_2 = \frac{p_2}{1-q_1 q_2}.$ It's therefore optimal for dueler 2 to take the gentleman's draw if and only if $T_2 \geq \frac{p_2}{1-q_1 q_2}.$ As a consequence, dueler 1 will not deliberately miss if $T_2 < \frac{p_2}{1-q_1 q_2}.$ If dueler 1 tries for a hit, both will subsequently try to hit each other and we have $$U_1 = p_1 + q_1 q_2 U_1$$. Solving, we get $U_1 = \frac{p_1}{1-q_1 q_2}.$ Thus, the optimal strategy for dueler 1 is to deliberately miss if and only if $T_1 \geq \frac{p_1}{1-q_1 q_2}$ and $T_2 \geq \frac{p_2}{1-q_1 q_2}.$ These are, as expected, precisely the conditions under which dueler 2 will deliberately miss.

For example, if $$p_1=p_2=1/2$$, it'll be a gentleman's draw if and only if $$T_1,T_2 \geq 2/3$$. Paradoxically, both will fire under these hit probabilities if $$T_1 = 4/5$$ and $$T_2 = 1/2$$, even though this results in lower expected utility for both duelers than if they had agreed to a draw. This is a type of prisoner's dilemma.

### 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…

### 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…

### Notes on Setting up a Titan V under Ubuntu 17.04

I recently purchased a Titan V GPU to use for machine and deep learning, and in the process of installing the latest Nvidia driver's hosed my Ubuntu 16.04 install. I was overdue for a fresh install of Linux, anyway, so I decided to upgrade some of my drives at the same time. Here are some of my notes for the process I went through to get the Titan V working perfectly with TensorFlow 1.5 under Ubuntu 17.04.

Old install:
Ubuntu 16.04
EVGA GeForce GTX Titan SuperClocked 6GB
2TB Seagate NAS HDD