Dicetributions – episode I
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Suppose the following game with two players:
In every round, the two players pick a random number, each. Instead of using a dice, they pick a number from an interval. Player A picks a number from [9,11] and player B from [8,12].
Variation 1. The greater number wins.
Who is more likely to win?
It is rather simple to prove that the two players have equal chances. One way to do it is to replace “greater” with “smaller”. Then the same interval should be best choice in both cases, since it’s like viewing the game from the front or the back side of the paper. Another way is to do it is a small breakdown: if B picks from [8,9], he loses, whilst if he picks from [11,12] he wins; both these two sub-cases have a probability of 1/4. If B picks from [9,11] he shares with A the same chance for winning. Hence, there is a tie in the overall game.
Variation 2. The winner of each round wins an amount of MU (Monetary Units) equal to his pick.
Let’s do some R here before addressing the problem theoretically.
n <- 10^7 x <- runif(n, min = 9, max=11) y <- runif(n, min = 8, max=12) wx <- x[x > y] wy <- y[y > x] print(c(mean(wx), mean(wy)))
[1] 10.16681 10.91634
So, player B wins more MU than A. How can we explain that effect? When they both pick from [9,11], which happens with probability 0.50, they share equal chances and expected gain. When B picks from [8,9], which occurs with probability 1/4, he loses the round. However, when he picks from [11,12], with probability 1/4, he wins the round as well as an amount of MU equal to the number he picked. So B finally earns better scores than A. Let’s take a look at the winning distributions:
png(filename = "dice1.png", width = 400, height = 300) mt = "distribution of scores" plot(density(wx), xlim=c(8,13), main=mt, xlab="scores", lwd=2) lines(density(wy), lwd=2, lty=3) legend(8, 0.7, c("A","B"), lty=c(1,3), lwd=rep(2,2)) dev.off()
One might ask here: why player A does not have an expected gain of 10, but slightly larger? The answer is that the outcomes of A are being “filtered” or “censored” by B, and only the “strong” survive. See the distribution of A-B:
png(filename = "dice2.png", width = 400, height = 300) mt = "distribution of differences" plot(density(x-y), xlim=c(-4,4), main=mt, xlab="A - B", lwd=2) lines(c(0,0), c(0,0.25), lty=2, col="gray", lwd=2) dev.off()
Can you prove theoretically that the expected scores for Variation 2 are 122/12 and 131/12 for A and B, respectively?
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.