**Freakonometrics - Tag - R-english**, and kindly contributed to R-bloggers)

Today, at lunch, Matthieu told us a nice story (or call it a paradox if you like) about the probability to find you seat empty when you get in a place.

- a plane full of nuns

Assume that you are in the line to get in the airplane, you are the 100th in the line. The first one is scatter brained, he has his head in the clouds, and when he get in the airplane, he cannot remember where he should seat. His strategy is then extremely simple: he seats randomly in the plane. So he picks up randomly a seat, and he waits.

Then come 98 nuns (one by one). And nuns are extremely polite: if there is someone in their seat (the one that is on the ticket they have) then they do not complain, and pick up another seat randomly (among those available, of course). Then you arrive. The question is simple: what is the probability that someone is seated at your seat ?

Any idea...?

Maybe I should give more time to do the maths... and tell another story...

- a plane full of Hells Angels

And the question is the same: you are the 100th person to get in the plane, what is the probability that someone is seated at your seat ?

Any idea....?

The important point is that the problem is exactly the same (at least from a mathematical point of view, maybe not for the stewardess, or from the guy who enter first in the plane). The point is that, at each time, there could be only one person (or less) seating in a seat which is not his or hers (in the sense that if we compare the list of the passenger at any time, and the list of seats taken, there should be only one - or less - difference). The difference in the two story is that in the first case, it will be a nun, while in the second one, it will be our shy guy.

- Let us run simulations

> set.seed(1)

> n=100; TEST=rep(NA,100000)

> for(s in 1:100000){

+ OCCUPIED=rep(FALSE,n)

+ OCCUPIED[sample(1:n,size=1)]=TRUE

+ for(j in 2:(n-1)){

+ FREE=which(OCCUPIED==FALSE)

+ if(OCCUPIED[j]==TRUE){OCCUPIED[sample(FREE,size=1)]=TRUE}

+ if(OCCUPIED[j]==FALSE){OCCUPIED[j]=TRUE}

+ }

+ TEST[s]=OCCUPIED[n]==TRUE

+ }

> mean(TEST)

[1] 0.49878

- an analytical expression

Consider the Hells Angels problem (for notations). Let denote the probability that, at time , our shy guy is sitting in *my* seat. When he gets in the plane, the probability that he gets to my seat is

Then,~~ the probability that, after ith passenger's entrance, our guy is sitting in my own seat is~~ (since the initial proof was not correct, I remove it, see below for a nice proof) One can get that

Hence, there is one chance out of two that my seat will be free... (which is what we got with Monte Carlo simulations).

But a faster proof is to observe that, in the Hells Angels case, our guy will be kicked out until he reaches either his seat, or mine. Since those two events are equiprobable, there is one chance out of two that he seats in my seat (and since no Hells Angel will seat in mine, only this first guy can). So the probability that someone is in my seat when I get in is one half.

Nice isn't it ? And thanks Matthieu for the problem (with his friend Claude's solution with the Hells Angels, and Olivier and Renaud for their comments) !

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

**Freakonometrics - Tag - R-english**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...