A Probability Puzzle
Introudction
From this Quora post, we can read
Suppose you are at a dinner party. The host wants to give out a door prize that is wrapped in a box. Everyone (including the host) sits around a circular table and each person is given a fair coin. Initially the host is holding the box. He flips his coin. If it is heads, he passes to the right. If it is tails, he passes to the left. The process is repeated by whichever guest is holding the box. (Heads, they pass right; tails, they pass left.) The game ends when the last person to receive the box finally gets it for the first time. That person gets to keep the box as the winner of the game.
Where should you sit to maximize your chance of winning?
Michael Lamar gives the answer, which is the chance is the same regardless where you sit. In this note, I will do a simulation study to verify the answer.
A simulation study
my_exp <- function(n = 11)
{the_set <- 1:(n - 1)
change_value <- 0
while(TRUE) {
toss <- (runif(1, min = 0, max = 1) > 0.5)
if(toss == TRUE) {
change_value <- (change_value + 1) %% n
} else {
change_value <- (change_value - 1 + n) %% n
}
if(change_value == 0) next
the_set <- setdiff(the_set, change_value)
if(length(the_set) == 0) break
}
return(change_value)
}
set.seed(123456)
N <- 10000
# example 1
the_data <- replicate(n = N, my_exp(n = 11))
(table(the_data) / N)
## the_data
## 1 2 3 4 5 6 7 8 9 10
## 0.0989 0.0949 0.1080 0.1010 0.0997 0.0978 0.0963 0.1036 0.1066 0.0932
# example 2
the_data <- replicate(n = N, my_exp(n = 4))
(table(the_data) / N)
## the_data
## 1 2 3
## 0.3360 0.3343 0.3297
# example 3
the_data <- replicate(n = N, my_exp(n = 3))
(table(the_data) / N)
## the_data
## 1 2
## 0.5086 0.4914