This project will demonstrate your understanding of the normal and binomial probability distributions in R and RStudio.
Assume IQ scores are normally distributed with a mean of 100 and a standard deviation of 15. If a person is randomly selected, find each of the requested probabilities. Here, x, denotes the IQ of the randomly selected person.
# pnorm calculates the probability of a value being less than the one you input.
pnorm(65, 100, 15)
## [1] 0.009815329
# We do not need to know the probability of a value being less than 65, we need to know the probability of a value being more than 65. Therefore, I found the compliment of the probability of a value being on the left to find the probability of a value being on the right.
1-0.009815329
## [1] 0.9901847
There is a 99% chance that a randomly selected person will have an IQ score higher than (greater than) 65.
# pnorm calculates the probability of a value being less than the one you input.
pnorm(150, 100, 15)
## [1] 0.9995709
There is a 99.96% chance that a randomly selected person will have an IQ score lower than (less than) 150.
Assume the same mean and standard deviation of IQ scores that were described in question 2.
# qnorm is the quantile function
qnorm(0.95, 100, 15)
## [1] 124.6728
The minimum qualifying IQ score is 124.67 for the special program at this high school.
# pnorm calculates the probability of a value being less than the one you input.
pnorm(125, 100, 15)
## [1] 0.9522096
# We do not need to know the probability of a value being less than 125, we need to know the probability of a value being more than 125. Therefore, I found the compliment of the left side's probability to give me the right side's probability.
1-0.9522096
## [1] 0.0477904
The probability of randomly selecting a person with an IQ score of more than 125 is 4.78% which means not very likely.
# The z-score is the data value minus the mean, then divided by the standard deviation.
(140-100)/15
## [1] 2.666667
The z-score for an IQ of 140 is 2.66.
Yes, an IQ of 140 is very “unusual” because the average IQ is 100 so 140 is well above average. In fact, a score of 140 is almost 3 standard deviations from the mean (well, 2.66) making it very rare.
# pnorm calculates the probability of a value being less than the one you input.
pnorm(140, 100, 15)
## [1] 0.9961696
# We do not need to know the probability of a value being less than 140, we need to know the probability of a value being more than 140. Therefore, I found the compliment of the left side's probability to give me the right side's probability.
1-0.9961696
## [1] 0.0038304
The probability of getting an IQ score that is greater than 140 is 0.38% which is not even 1% which is BEYOND rare.
You are taking a 15-question multiple choice quiz and each question has 5 options (a,b,c,d,e) and you randomly guess every question.
# mean=n*p
15*0.20
## [1] 3
I expect to answer three questions correctly based on this scenario.
# dbinom is used to find the probability that exactly x number of successes will occur in a binomial experiment.
dbinom(15, 15, 0.20)
## [1] 3.2768e-11
The probability of me getting every question correct in this scenario is 0.000000000032768, so in other words, it’s not going to happen.
# dbinom is used to find the probability that exactly x number of successes will occur in a binomial experiment.
dbinom(0, 15, 0.20)
## [1] 0.03518437
The probability that I answer every question incorrectly is 0.03518 which is the same as 3.5%.
Consider still the 15-question multiple choice quiz that each question has 5 options (a,b,c,d,e) and you randomly guess every question.
# Here I cross-multiplied.
# 60/100=x/15
# 100x=900
# x=9
In order to recieve exactly a 60% on this quiz, you need to answer exactly 9 questions correctly.
# pbinom calculates the probability of x or fewer successes occuring (in this case, getting 9 or less answers correct).
pbinom(9, 15, 0.20)
## [1] 0.9998868
The probability of me failing this quiz is 99.98%. In other words, I’m going to fail it.
# Here I cross-multiplied.
# 80/100=x/15
# 100x=1200
# x=12
pbinom(11, 15, 0.20)
## [1] 0.999999
# Now I will find the compliment of 11 or less to give me 12 or more.
1-0.999999
## [1] 1e-06
The probability of me maintaining that passing grade is 0.000001. In other words, it’s not going to happen.
Suppose you own a catering company. You hire local college students as servers. Not being the most reliable employees, there is an 80% chance that any one server will actually show up for a scheduled event. For a wedding scheduled on Saturday, you need at least 5 servers.
# dbinom is used to find the probability that exactly x number of successes will occur in a binomial experiment.
dbinom(5, 5, 0.8)
## [1] 0.32768
The probability that all five people actually come to work is 32.77%.
# Here I used dbinom
dbinom(5, 7, 0.8)
## [1] 0.2752512
dbinom(6, 7, 0.8)
## [1] 0.3670016
dbinom(7, 7, 0.8)
## [1] 0.2097152
0.2752512+0.3670016+0.2097152
## [1] 0.851968
# Here I used pbinom just to check my answer
pbinom(4, 7, 0.8, lower.tail = FALSE)
## [1] 0.851968
The probability that at least five people come to work is 85.19%.
# Knowing that scheduling 7 people only gives us about an 85% chance of having five people show up and knowing I need that 85 to be a 99, I tried a few more numbers. For example, what if we schedule 8, 9, or 10 people?
pbinom(4, 8, 0.8, lower.tail = FALSE)
## [1] 0.9437184
pbinom(4, 9, 0.8, lower.tail = FALSE)
## [1] 0.9804186
pbinom(4, 10, 0.8, lower.tail = FALSE)
## [1] 0.9936306
In order to be 99% confident that at least five people show up, ten employees will have to be scheduled.