# Bayes is playing Russian roulette

There was (once again) a nice puzzle inhttp://www.futilitycloset.com/. Bayes and a good friend are playing Russian roulette. The revolver has six chambers. He puts two bullets in two adjacent chambers, spin the cylinder, hold the gun to his friend’s head, and pull the trigger. It clicks. So it is now Bayes’s turn: he can choose either to spin the cylinder again or leave it as it is. Which is better? Hopefully, Bayes knows his theorem: if he does spin it, the probability of getting killed is 2 out of 6 (four empty chambers out of six), but if he does not, since his friend is still alive, then the hammer should be next to one of the four cylinders in red, below

So here, there is 3 chance out of 4 to survive, i.e. the probability of getting killed is 1 out of 4 (while it was 1 out of 3 when spinning). So Bayes should not spin. And as always, it is possible to see it is a more general result: more generally, in a revolver with  chambers, it there are  bullets in  adjacent chambers,  if the first player survives, the probability of getting killed is k over , when spinning, while it would be 1 over  if we don’t. Not spinning is better if and only if

i.e.

So you’d better not spin, unless there was one bullet in the revolver, i.e. … or  (in that case, it might not be a good idea actually to play the game).

# Playing with fire (or water)

A few days ago,http://www.futilitycloset.com/published a short post based on the fourth problem of the 1987 Canadian Mathematical Olympiad (from on a problem from the 6th All Soviet Union Mathematical Competition in Voronezh, 1966). The problem is simple (as always). It is about water pistol duels (with an odd number of players)

What puzzled me in this problem is the following: if we know, for sure, that at least one player won’t get wet, we don’t know exactly how many of them won’t get wet (assuming that if they shoot at the closest, they hit him for sure) ? It is simple to run simulations, e.g. assuming that players are uniformly distributed over a square,

```NOTWET=function(n){
x=runif(n)
y=runif(n)
(d=as.matrix(dist(cbind(x,y), method = "euclidean",upper=TRUE)))
diag(d)=999999
dmin=apply(d,2,which.min)
notwet=n-length(table(dmin))
return(notwet)}```

It is then rather simple to get the distribution of the number of player that did not get wet,

```N25=Vectorize(NOTWET)(n=rep(25,NSim))
T=table(N25)
plot(as.numeric(names(T)),T/NSim,type="b")```

The graph for different values for the total number of players is the following (based on 25,000 simulations)

If we investigate further, say with 51 players, we have a distribution for the total number of players that did not get wet which looks exactly like the Gaussian distribution,

```NSim=25000
N51=Vectorize(NOTWET)(n=rep(51,NSim))
T=table(N51)
plot(as.numeric(names(T)),T/NSim,type="b",col="blue")
u=seq(0,51,by=.1)
lines(u,dnorm(u,mean(N51),sd(N51)),col="red",lty=2)```

If anyone has an intuition (not to say a proof) for that, I’d be glad to hear it…

# When should I optimally shoot at my son ? (part 2)

Following my previous post of yesterday, online here, assume now that I do not know if my son came when I turned my back at time, and missed me… Then the payoff function is the one propose by Vincent, i.e.

In that particular case,

becomes

i.e.

If we draw those functions, on [0,1], the optimal value is solution of

i.e.  (we focus only on solutions in [0,1]). Because here the game is symmetric, my son should also shoot at time
Thus, the payoff is then

Since we consider here a  zero-sum game, this cannot be a solution of the game. So the game does not have pure strategy solution.

Assume that now I have a mixed strategy, i.e. a distribution of the optimal time to shot. My strategy has distribution , with density  (we assume here that the density exists, or we seek only solution that are differentiable). Assume further that there exists >0 such that the support of my optimal shooting time (the time to shoot is now a random variable) is (,1] (or [,1] since we assume that  is differentiable). There is a discussion at the end of Vincent’s post where he needs that assumption, at the end. Actually, I think we can make it now, since we can rationally assume that
I will not shot at time 0 (even on a neighborhood of 0 since I have zero chance to hit my son).
The expected payoff function, assuming that my son shoots at time y is

Since the zero-sum game is symmetric, again, the expected payoff should be zero. It comes that necessarily,

if . Hence, if we differentiate (with respect to y), we have

and if we differentiate one more time, it comes

i.e. a general solution should be of the form .
Here, we have the same solution as the one considered in Vincent’s blog. His solution is obtained as follows (with slightly different expressions) conditional to , my expected payoff is

i.e.

With a simple integration by parts,

where , i.e.

Thus,

So, if we want to be indifferent to ‘s strategy, , where

with ,

Consider solutions , then =1, i.e. either =1 and then  is constant, or =-1. This means that  is in proportional to .
If we substitute in the equation we had, initially, it comes that

i.e.

If we consider =a and =1, it comes that =1/3 while =1/4 (but we don’t really care about that normalizing constant).
It means that we should not start shooting before 1/3 of the tank is fulled. Actually, it makes sense, since

if <1/3 (while =0 if  >1/3).

# When should I optimally shoot at my son ? (part 1)

when playing with water guns ! It is not a reverse oedipal fantasy, it is simply a (stochastic) game. Actually, that game was mentioned here, in the context of a duel with laser guns, and the answer is there. Vincent (alias @Vicnent) presented the problem this way: consider a single combat between two single warriors (a duel) with laser guns. The probability to kill the other one is proportional to time  (duel started at time 0). Initially, the have no chance to kill the other one, and after one hour, they are certain to kill the other one. At time , they kill the other one with probability  (and miss him with probability ). What is the optimal time to shot ?

An alternative can be the following (yes, I prefer personal experience to science fiction): consider two warriors playing with water gun. We start with empty guns, and assume that both warriors fill their guns at two different tap water. The more water we have in guns, the more likely the other one will be wet. What is my optimal strategy to stop filling the gun, and start shooting at the other player ?
In order to formalize the game, assume that I will win 1 point if my son gets wet (and not me), I’ll get -1 if I am wet, and not him, and 0 if we are both wet (in Vincent’s game, we have the same payoff matrix, but I find odd to say that I have -1 if I die).
Let  and  denote time where players shoot. Vincent derived the following expected payoff function: for me (I shoot at time ) the payoff is

If we know that the other player shoot us, but missed us, it should be different: if I shot first, but missed my son, then he should wait until the end, and so, the payoff should be (thanks Jérôme)

Actually, we can consider a more general game, where probabilities are not proportional to , but functions  for me ( stands for dad), and  for the other player (here my son ). The expected payoff becomes,

Thus my best strategy is obtained by solving

that is

Let

If  and  are assumed to be continuous (we assume that water goes continuously into the tank of the gun), then there is  such that

If , then  and

and so . So

Similarly, if , then  and

and so . So

So finally, the optimal strategy is to shoot at the same time, .
In the game considered initially by Vincent, . Hence, =1/2.
But it is also possible that I did not hear my son coming, shooting at me (and missing me). So in that case, the payoff is different, and closer to what Vincent proposed… but that will be in another post…

# Quand il est optimal de ne rien faire…

Tous les bloggers d’économie se sentent régulièrement obligés de parler de ce film culte… et je n’y couperais par aujourd’hui.
Ce week end, en sortant de l’exposition sur les mammouths à Rennes avec mon fils, on est passé à la fête de la science, voir si on pouvait faire quelques casses têtes à un stand tenu par des collègues de Beaulieu. Et là, un petit problème de théorie des jeux m’a été soumis, et je ne pouvais pas passer à côté de l’occasion (surtout quand on connaît la morale) d’en parler ici.
Tout le monde connaît la scène du “duel à trois” où le bon, la brute et le truand se font face… Pour les besoin du jeu, on va faire quelques hypothèses (c’est le principe de base d’un jeu: il faut une règle),

• tout d’abord, on suppose que l’ordre dans lequel ils tirent a été fixé (et qu’ils vont s’y tenir, sans tricher (même Tuco): le bon, puis le truand, et enfin la brute,
• ils peuvent tirer (et doivent tirer) tant qu’ils ont des balles, et tant qu’ils sont en vie, le jeu s’arrêtant quand plus personne n’a de balle, ou qu’il n’y a qu’un survivant1
• on connaît les probabilités que chacun rate sa cible:  le bon (alias Blondin) est un peu nul (oui, il faut un peu d’imagination) car il a 1 chance sur 3 d’atteindre sa cible; le truand (Tuco) est un peu moins mauvais car il a 1 chance sur 2; enfin la brute (Sentenza) est super fort car il ne rate jamais sa cible.
• ah oui, et les personnages ne sont pas rancuniers… ce n’est pas parce que quelqu’un nous tire dessus qu’on voudra se venger quand ça sera notre tour (et si on a la chance d’être en vie)

..La question est simple “que doit faire Clint, alias Blondin ?“. Raisonnons simplement en étudiant les scénarios,

• s’il tire sur Tuco, il a 1 chance sur 3 de le tuer. S’il est chanceux, il le tue. Alors on retrouve avec un duel entre la brute et le bon. Et comme c’est à la brute de tirer et qu’il ne rate jamais son coup… ce n’est pas franchement malin,
• s’il tire sur la brute, supposons qu’il le tue. Alors c’est au truand de tirer, et il a 1 chance sur 2 de gagner le dual, alors que le bon a 1 chance sur 3… Bref, les probas ne sont pas franchement en sa faveur…

mais on a regarder ce qui se passait si, par malheur, Blondin tuait quelqu’un… peut être devrait on se demander ce qu’il se passait s’il rate son coup

• dans ce cas, peu importe qui a été visé car personne n’est rancunier. Dans ce cas, c’est à Tuco de tirer.S’il tire sur Clint, et qu’il le tue, ça sera à la brute de tirer, et alors il n’a aucune chance de s’en sortir vivant. Il est donc impératif que Tuco tire sur Sentenza.
• si Tuco rate son coup, alors la brute a tout intérêt à tuer d’abord le truand. En effet, il risque plus de mourir s’il laisse le truand en vie que la brute. Donc, le truand meurt car Sentenza est super fort….
• Moralité, après un tour, c’est au bon de tirer, il ne peut que tirer sur la brute et espérer réussir son coup. Sinon, c’en est fait de lui…

Bref, en ratant son premier tir, il augmente ses chances de gagner…. je laisse les personnes intéressées faire les maths, mais ce petite exemple montre clairement que, dans la vie, il est parfois optimal de ne rien faire !
1 a priori on peut supposer aussi un jeu à la roulette russe, avec une balle chacun, qui doit arriver à la même conclusion…