3.2 Area under the curve, Part II. What percent of a standard normal distribution N(μ = 0, sigma = 1) is found in each region? Be sure to draw a graph.
# Giving credit to: http://shiny.stat.calpoly.edu/Prob_View/ for the images provided below. It is an app that allows me to plug in the numbers, which will then render the image.
1 - pnorm(-1.13, mean = 0, sd = 1)
## [1] 0.8707619
pnorm(0.18, mean = 0, sd = 1)
## [1] 0.5714237
pnorm(8, mean = 0, sd = 1, lower.tail = FALSE)
## [1] 6.220961e-16
pnorm(0.5, mean = 0, sd = 1) - pnorm(-0.5, mean = 0, sd = 1)
## [1] 0.3829249
Triathlon times, Part I.
In triathlons, it is common for racers to be placed into age and gender groups. Friends Leo and Mary both completed the Hermosa Beach Triathlon, where Leo competed in the Men, Ages 30 - 34 group while Mary competed in the Women, Ages 25 - 29 group. Leo completed the race in 1:22:28 (4948 seconds), while Mary completed the race in 1:31:53 (5513 seconds). Obviously Leo finished faster, but they are curious about how they did within their respective groups. Can you help them? Here is some information on the performance of their groups:
• The finishing times of the Men, Ages 30 - 34 group has a mean of 4313 seconds with a standard deviation of 583 seconds.
• The finishing times of the Women, Ages 25 - 29 group has a mean of 5261 seconds with a standard deviation of 807 seconds.
• The distributions of finishing times for both groups are approximately Normal. Remember: a better performance corresponds to a faster finish.
#For Men, Ages 30 - 34:
#N(mean = 4313, sd = 583)
#For Women, Ages 25 - 29:
#N(mean = 5261, sd = 807)
#Z score for Leo:
Z.Leo <- (4948 - 4313)/583
Z.Mary <- (5513 - 5261)/807
paste0("Z score for Leo: ", round(Z.Leo,2))
## [1] "Z score for Leo: 1.09"
paste0("Z score for Mary: ", round(Z.Mary,2))
## [1] "Z score for Mary: 0.31"
# This tell us that Leo scored 1.09 SD and Mary scored 0.31 SD above the mean, respectively.
# Mark had more "seconds" in time in his respective group compared to Mary's. He is 1.09 SD above the mean, whereas, Mary is 0.31 above the SD for her group. Therefore, Mark was slower in his respective group than Mary's.
#When calculating for these numbers for both Leo and Mary, we have to remember that these numbers are in length of time. Therefore, the higher the Z number, the slower the runner was running.
Percent.Leo <- (1 - pnorm(4948, mean = 4313, sd = 583)) * 100
paste0("Percentage of triathletes Leo finished faster than: ", round(Percent.Leo,2))
## [1] "Percentage of triathletes Leo finished faster than: 13.8"
Percent.Mary <- (1 - pnorm(5513, mean = 5261, sd = 807)) * 100
paste0("Percentage of triathletes Leo finished faster than: ", round(Percent.Mary,2))
## [1] "Percentage of triathletes Leo finished faster than: 37.74"
# Answer to part (b) would not change as Z-scores can be calculated for distributions that are not normal. However, we could not answer parts (d)-(e) since we cannot use the normal probability table to calculate probabilities and percentiles without a normal model.
3.18 eights of female college students. Below are heights of 25 female college students.
54, 55, 56, 56, 57, 58, 58, 59, 60, 60, 60, 61, 61, 62, 62, 63, 63, 63, 64, 65, 65, 67, 67, 69, 73
Female.Height <- c(54, 55, 56, 56, 57, 58, 58, 59, 60, 60, 60, 61, 61, 62, 62, 63, 63, 63, 64, 65, 65, 67, 67, 69, 73)
# Using the information provided above:
# 1SD approximately = 68%, which corresponds to data points falling between 84% and 16%.
Upper.Limit.SD1 <- qnorm(.84, mean = 61.52, sd = 4.58)
Lower.Limit.SD1 <- qnorm(.16, mean = 61.52, sd = 4.58)
paste("Upper Limit of 1 SD in Height: ", round(Upper.Limit.SD1, 2))
## [1] "Upper Limit of 1 SD in Height: 66.07"
paste("Lower Limit of 1 SD in Height: ", round(Lower.Limit.SD1, 2))
## [1] "Lower Limit of 1 SD in Height: 56.97"
# Now we find all the data points between the upper limit and lower limit and divide it by the entire length of the data.
Within.1SD <- Female.Height[Female.Height < Upper.Limit.SD1 & Female.Height > Lower.Limit.SD1]
Percent.1SD <- length(Within.1SD)/length(Female.Height)
paste("According to this data set, 1 Standard Deviation is approximately: ", round(Percent.1SD,2))
## [1] "According to this data set, 1 Standard Deviation is approximately: 0.68"
# Now we repeat this for 2SD and 3SD
Upper.Limit.SD2 <- qnorm(.975, mean = 61.52, sd = 4.58)
Lower.Limit.SD2 <- qnorm(.025, mean = 61.52, sd = 4.58)
paste("Upper Limit of 2 SD in Height: ", round(Upper.Limit.SD2, 2))
## [1] "Upper Limit of 2 SD in Height: 70.5"
paste("Lower Limit of 2 SD in Height: ", round(Lower.Limit.SD2, 2))
## [1] "Lower Limit of 2 SD in Height: 52.54"
Within.2SD <- Female.Height[Female.Height < Upper.Limit.SD2 & Female.Height > Lower.Limit.SD2]
Percent.2SD <- length(Within.2SD)/length(Female.Height)
paste("According to this data set, 2 Standard Deviation is approximately: ", round(Percent.2SD,2))
## [1] "According to this data set, 2 Standard Deviation is approximately: 0.96"
Upper.Limit.SD3 <- qnorm(.9985, mean = 61.52, sd = 4.58)
Lower.Limit.SD3 <- qnorm(.0015, mean = 61.52, sd = 4.58)
paste("Upper Limit of 3 SD in Height: ", round(Upper.Limit.SD3, 2))
## [1] "Upper Limit of 3 SD in Height: 75.11"
paste("Lower Limit of 3 SD in Height: ", round(Lower.Limit.SD3, 2))
## [1] "Lower Limit of 3 SD in Height: 47.93"
Within.3SD <- Female.Height[Female.Height < Upper.Limit.SD3 & Female.Height > Lower.Limit.SD3]
Percent.3SD <- length(Within.3SD)/length(Female.Height)
paste("According to this data set, 3 Standard Deviation is approximately: ", round(Percent.3SD,2))
## [1] "According to this data set, 3 Standard Deviation is approximately: 1"
# The answer is: Yes, the heights follow the approximation.
# The distribution is unimodal and symmetric. The superimposed normal curve seems to approximate the distribution pretty well. The points on the normal probability plot also seem to follow a straight line. There are some possible outlier on the higher and lower ends that is apparent, but it is not too extreme. We can say that the distribution is nearly normal.
qqnormsim <- function (dat)
{
par(mfrow = c(3, 3))
qqnorm(dat, main = "Normal QQ Plot (Data)")
qqline(dat)
for (i in 1:8) {
simnorm <- rnorm(n = length(dat), mean = mean(dat), sd = sd(dat))
qqnorm(simnorm, main = "Normal QQ Plot (Sim)")
qqline(simnorm)
}
par(mfrow = c(1, 1))
}
qqnormsim(Female.Height)
3.22 Defective rate. A machine that produces a special type of transistor (a component of computers) has a 2% defective rate. The production is considered a random process where each transistor is independent of the others.
(1-.02)^9 * (.02)
## [1] 0.01667496
(1-.02)^100
## [1] 0.1326196
paste("First defect: ",1/.02)
## [1] "First defect: 50"
paste("SD: ", sqrt((1-.02)/(.02)^2))
## [1] "SD: 49.4974746830583"
paste("On average, how many transistors would you expect to be produced with this machine before the first with a defect? ", 1/.05)
## [1] "On average, how many transistors would you expect to be produced with this machine before the first with a defect? 20"
paste("What is the standard deviation? ", sqrt((1-.05)/(.05)^2))
## [1] "What is the standard deviation? 19.4935886896179"
# When p is increased, the event is less rare, meaning the expected number of trials before a success and the standard deviation of the waiting time are lower.
3.38 Male children. While it is often assumed that the probabilities of having a boy or a girl are the same, the actual probability of having a boy is slightly higher at 0.51. Suppose a couple plans to have 3 kids.
# 3 choose 2 * (.51)^2 * (1 - .51)^2
choose(3,2) * (.51)^2 * (1-.51)^1
## [1] 0.382347
# another way to write this: factorial(3)/(factorial(2) * factorial(1)) * (.51)^2 * (1-.51)^1
# another way: dbinom(2, 3, prob = 0.51)
# 1: {B, B, G}
# 2: {B, G, B}
# 3: {G, B, B}
P2B1G <- (.51)^2 * (.49)
Total.P2B1G <- 3 * P2B1G
Total.P2B1G
## [1] 0.382347
Confirm that your answers from parts (a) and (b) match.
# Confirmed!
# Part A is a formula that we can simply plug in and calculate via R or by a calculator. If we performed the calcuation by part B, then we would need to figure out every possible combination and then calculate it by hand, making it significantly tedious.
3.42 Serving in volleyball. A not-so-skilled volleyball player has a 15% chance of making the serve, which involves hitting the ball so it passes over the net on a trajectory such that it will land in the opposing team’s court. Suppose that her serves are independent of each other.
# Using the negative binomial equation, given that the last serve is succesful.
# P(making serve) = .15, therefore, P(NOT making serve) = .85
choose((10-1),(3-1)) * (.15)^3 * (.85)^7
## [1] 0.03895012
# As stated in the question stem, all hits are independent of each other. Therefore, the probability that the 10th serve will be successful is 0.15.
# Part B talks about the 10th serve only, where the first 9 outcomes had already occurred. Given that this is independent, this is why the success rate is still 0.15. Whereas, in Part A, the first 9 attempts have NOT yet been attempted, and we do not know the outcomes of these events. Therefore, the calculations need to take into account for this, which is why we used the negative binomial equation.