Area under the curve, Part I. (4.1, p. 142) What percent of a standard normal distribution \(N(\mu=0, \sigma=1)\) is found in each region? Be sure to draw a graph.
mu <- 0
sd <- 1
#option a
Z <- -1.35
x <- Z * sd + mu
# prob of x < -1.35
1-pnorm(x, mean = 0, sd = 1)
## [1] 0.911492
#option b
Z <- 1.48
x <- Z * sd + mu
# prob of x > 1.48
pnorm(x, mean = 0, sd = 1)
## [1] 0.9305634
Z1 <- -0.4
Z2 <- 1.5
xn1 <- Z1 * sd + mu
xn2 <- Z2 * sd + mu
# prob of |x| < 0.5 = -x < 0.5 < x
x1 <- pnorm(xn1, mean = 0, sd = 1)
x2 <- pnorm(xn2, mean = 0, sd = 1)
x2 - x1
## [1] 0.5886145
#option d
Z <- 2
x <- Z * sd + mu
# prob of |x| > 2 = -x < 2 < x
x1 <- pnorm(-x, mean = 0, sd = 1)
x2 <- pnorm(x, mean = 0, sd = 1)
x2 - x1
## [1] 0.9544997
library(fastGraph)
mean <- 0
SD <- 1
x <- seq(-4, 4, length = 10000)
y <- dnorm(x, mean, SD)
par(mfrow=c(2,2))
shadeDist(-1.35, lower.tail = FALSE, col = c("blue", "light green"))
shadeDist(1.48, col = c("blue", "light green"))
shadeDist(c(-0.4,1.5), lower.tail = FALSE, col = c("blue", "light green"))
shadeDist(c(-2,2), lower.tail = FALSE, col = c("blue", "light green"))
Triathlon times, Part I (4.4, p. 142) 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:
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
paste0("Z score for Leo: ", round(Z.Leo,2))
## [1] "Z score for Leo: 1.09"
This tell us that Leo scored 1.09 SD and Mary scored 0.31 SD above the mean, respectively.
#Z score for Mary:
Z.Mary <- (5513 - 5261)/807
paste0("Z score for Mary: ", round(Z.Mary,2))
## [1] "Z score for Mary: 0.31"
Ans: Mary ranks better that Mark their respective group. MArk had more “seconds” in time in his respective group as compared to Mary’s. Mark is 1.09 SD above the mean, whereas, Mary is 0.31 above the SD for her group.
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"
Ans: The z-scores won’t change, but the probabilities associated with these z-scores will be affected because Z-scores are calculated based on normal distribution.
Heights of female college students Below are heights of 25 female college students.
\[ \stackrel{1}{54}, \stackrel{2}{55}, \stackrel{3}{56}, \stackrel{4}{56}, \stackrel{5}{57}, \stackrel{6}{58}, \stackrel{7}{58}, \stackrel{8}{59}, \stackrel{9}{60}, \stackrel{10}{60}, \stackrel{11}{60}, \stackrel{12}{61}, \stackrel{13}{61}, \stackrel{14}{62}, \stackrel{15}{62}, \stackrel{16}{63}, \stackrel{17}{63}, \stackrel{18}{63}, \stackrel{19}{64}, \stackrel{20}{65}, \stackrel{21}{65}, \stackrel{22}{67}, \stackrel{23}{67}, \stackrel{24}{69}, \stackrel{25}{73} \]
library(openintro)
heights <- 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)
par(mar=c(3.7,2.2,1,1), las=1, mgp=c(2.5,0.7,0), mfrow = c(1,1), cex.lab = 1.5, cex.axis = 1.5)
histPlot(heights, col = COL[1], xlab = "Heights", ylab = "", probability = TRUE, axes = FALSE, ylim = c(0,0.085))
axis(1)
x <- heights
xfit <- seq(min(x)-5, max(x)+5, length = 400)
yfit <- dnorm(xfit, mean = mean(x), sd = sd(x))
lines(xfit, yfit, col = COL[4], lwd = 2)
par(mar=c(3.7,3.7,1,1), las=1, mgp=c(2.5,0.7,0), mfrow = c(1,1), cex.lab = 1.5, cex.axis = 1.5)
qqnorm(heights, col = COL[1], pch = 19, main = "", axes = FALSE)
axis(1)
axis(2)
qqline(heights, col = COL[1])
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 1st SD in Height: ", round(Upper.Limit.SD1, 2))
## [1] "Upper Limit of 1st SD in Height: 66.07"
# Use the DATA606::qqnormsim function
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(heights)
Defective rate. (4.14, p. 148) 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"
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.
choose(3,2) * (.51)^2 * (1-.51)^1
## [1] 0.382347
# 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
Ans: 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.
Serving in volleyball. (4.30, p. 162) 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
#Ans: 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 or 15% of chance.
#Ans: Part B indicates 10th serve only, where the first 9 outcomes had already occurred with probability of 10th serve with 15% of chance. Whereas, in Part A, the first 9 attempts have NOT yet been attempted, and we do not know the outcomes of these events. Thats the main reason why we used negative binomial equation.