$E \sim \text{Binom}(n, .5)$ and $F \sim \text{Binom}(n+1, .5).$ What is $P(F > E)?$

90 Views Asked by At

Erica tosses a fair coin $n$ times and, independently, Fred tosses a fair coin $n+1$ times. What is the probability Fred gets more heads than Erica?

I have been able to solve this problem theoretically, and found that the probability is $1/2.$ The next step is to code it in R, and I am not sure where to begin.

1

There are 1 best solutions below

1
On

If you want R code for a simulation, here is about the simplest possible version. I used a million iterations with $n = 9.$ With a million iterations, you can expect about three place accuracy.

m = 10^6;  n = 9
erica = rbinom(m,n,.5); fred = rbinom(m,n+1,.5)
mean(fred > erica)   # mean of logical vector is proportion of TRUEs
## 0.500542          # aprx P(F > E) = 1/2

Extras:

MAT = cbind(fred, erica)
head(MAT)            # first 6 rows of m x 2 matrix
     fred erica
[1,]    3     4
[2,]    4     4
[3,]    3     3
[4,]    3     5
[5,]    5     6
[6,]    5     3

mean(fred);  mean(erica)
## 4.999831          # aprx 5 = 10(.5)
## 4.498146          # aprx 4.5 = 9(.5)

d = fred - erica
summary(d)
    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-9.0000 -1.0000  1.0000  0.5017  2.0000 10.0000 
sd(d)
## 2.178673

hist(d, br=(-10:10)+.5, prob=T, col="skyblue2")
abline(v=mean(d), col="red", lty="dashed", lwd=2)
curve(dnorm(x, mean(d), sd(d)), col="blue", lwd=2, add=T)

enter image description here