Calculating probabilities of binomial distributions in R
Just as with the normal distribution, we can also calculate probabilities according to the binomial distributions. Let's consider the example in the previous question. We had an exam with 25 questions and 0.2 probability of guessing a question correctly. In contrast to the normal distribution, when we have to deal with a binomial distribution we can calculate the probability of exactly answering say 5 questions correctly. This is because a binomial distribution is a discrete distribution.
When we want to calculate the probability of answering 5 questions correctly, we can use the dbinom
function. This function calculates an exact probability. If we would like to calculate an interval of probabilities, say the probability of answer 5 or more questions correctly, we can use the pbinom
function. We have already seen a similar function when we were dealing with the normal distribution: the pnorm()
function.
This exercise is part of the course
Basic Statistics
Exercise instructions
- Look at the documentation of the functions
dbinom()
andpbinom()
. Calculate the exact probability of answering 5 questions correctly and store this in the variablefive_correct
- Calculate the cumulative probability of answering at least 5 questions correctly and store this in the variable
atleast_five_correct
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# probability of answering 5 questions correctly
# probability of answering at least 5 questions correctly