Exercise 2:
Let \(S_{200}\) be the number of heads that turn up in 200 tosses of a fair coin.
Estimate:
Answer:
Since there are only two possible outcomes (heads and tails) this is a Bernoulli trial. Therefore, the following formula applies:
\[ \binom{n}{k}p^k(1-p)^{n-k} \]
In R we can use the dbinom() function for this, with x = the # of heads, size = the # of tosses; and prob = the probability of each outcome
# Use the dbinom function to calculate the probability
a <- dbinom(x = 100, size = 200, prob = .5)
b <- dbinom(x = 90, size = 200, prob = .5)
c <- dbinom(x = 80, size = 200, prob = .5)
cat("\nWith fair coin and 200 tosses:\n",
"\nAnswer A: Probability of 100 =",round(a*100,1),"%",
"\nAnswer B: Probability of 90 =",round(b*100,1),"%",
"\nAnswer C: Probability of 80 =",round(c*100,1),"%")
##
## With fair coin and 200 tosses:
##
## Answer A: Probability of 100 = 5.6 %
## Answer B: Probability of 90 = 2.1 %
## Answer C: Probability of 80 = 0.1 %
For reference here is the probability density distribution scaled to show the probability of getting between 80 and 120 heads:
# Create sequence from 80 to 120 for X axis
x <- seq(80,120,by = 2)
# Create the binomial distribution using the above range
y <- dbinom(x,200,0.5)
# Plot the distribution
plot(x,y)