A common problem for binomial distributions involves finding the probability of k number of heads or tails in n number of tosses of a fair coin. For example, if we want to find the probability of 3 tails in 5 tosses we can use the dbinom() function in R to find the answer using the syntax dbinom(k,n,p).
p = dbinom(3, 5, .5)
print(paste0
("The probability of getting tails 3 times out of 5 tosses of a fair coin is ", p))
## [1] "The probability of getting tails 3 times out of 5 tosses of a fair coin is 0.3125"
If we wanted to find the probability of at least 3 tails in 5 coin tosses, we can use the cumulative binomial distribution function pbinom with the syntax pbinom(k,n,p).
x = pbinom(3, 5, .5)
print(paste0
("The probability of getting tails at least 3 times out of 5 tosses of a fair coin is ", x))
## [1] "The probability of getting tails at least 3 times out of 5 tosses of a fair coin is 0.8125"