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.
(a) \(Z < -1.35\)
## [1] -1.35
Since we have Z < -1.35, we can find propbability P(x < -1.35) as
pnorm(x, mean = mu, sd = sigma)
## [1] 0.08850799
library(DATA606)
## Loading required package: shiny
## Loading required package: openintro
## Please visit openintro.org for free statistics materials
##
## Attaching package: 'openintro'
## The following objects are masked from 'package:datasets':
##
## cars, trees
## Loading required package: OIdata
## Loading required package: RCurl
## Loading required package: bitops
## Loading required package: maps
## Loading required package: ggplot2
##
## Attaching package: 'ggplot2'
## The following object is masked from 'package:openintro':
##
## diamonds
## Loading required package: markdown
##
## Welcome to CUNY DATA606 Statistics and Probability for Data Analytics
## This package is designed to support this course. The text book used
## is OpenIntro Statistics, 3rd Edition. You can read this by typing
## vignette('os3') or visit www.OpenIntro.org.
##
## The getLabs() function will return a list of the labs available.
##
## The demo(package='DATA606') will list the demos that are available.
##
## Attaching package: 'DATA606'
## The following object is masked from 'package:utils':
##
## demo
normalPlot(mean = mu, sd = sigma, bounds = c(-Inf, x), tails = FALSE)
8.85% percent of a standard normal distribution found.
(b) \(Z > 1.48\)
## [1] 1.48
Since we have Z < 1.48, we can find propbability P(x > 1.48) as
1 - pnorm(x, mean = mu, sd = sigma)
## [1] 0.06943662
normalPlot(mean = mu, sd = sigma, bounds = c(x, Inf), tails = FALSE)
6.94% percent of a standard normal distribution found.
(c) \(-0.4 < Z < 1.5\)
Since we have -0.4 < Z < 1.5, we can find propbability P(-0.4 < x < 1.5) as
p1 <- pnorm(x1, mean = mu, sd = sigma)
p2 <- pnorm(x2, mean = mu, sd = sigma)
p2 - p1
## [1] 0.5886145
normalPlot(mean = mu, sd = sigma, bounds = c(x1, x2), tails = FALSE)
58.86% percent of a standard normal distribution found.
(d) \(|Z| > 2\)
Since we have |Z| > 2, we can find propbability P(x < -2 or x > 2) as
p1 <- pnorm(x1, mean = mu, sd = sigma)
p2 <- 1 - pnorm(x2, mean = mu, sd = sigma)
p1 + p2
## [1] 0.04550026
normalPlot(mean = mu, sd = sigma, bounds = c(x1, x2), tails = TRUE)
4.56% percent of a standard normal distribution found.
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.
Men, Ages 30 - 34: \(N(\mu=4313, \sigma=583)\)
Women, Ages 25 - 29: \(N(\mu=5261, \sigma=807)\)
mean_m <- 4313
sd_m <- 583
leo_x <- 4948
leo_z <- (leo_x - mean_m) / sd_m
leo_z
## [1] 1.089194
mean_w <- 5261
sd_w <- 807
mary_x <- 5513
mary_z <- (mary_x - mean_w) / sd_w
mary_z
## [1] 0.3122677
The Z-score of an observation is the number of standard deviations it falls above or below the mean Leo’s z-score suggests his time was 1.09 standard deviations above the mean. Mary’s z-score suggests her time was 0.31 standard deviations above the mean.
Given the two z-scores, Mary is closer to her group mean. So Mary ranks better in her group.
pnorm(leo_x, mean = mean_m, sd = sd_m)
## [1] 0.8619658
Leo finished faster than 86.20% triathletes in his group.
pnorm(mary_x, mean = mean_w, sd = sd_w)
## [1] 0.6225814
Mary finished faster than 62.26% triathletes in her group.
If the distributions of finishing times are not nearly normal, z-scores will still be the same but answers to questions (d) and (e) would be different.
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} \]
fhgt <- 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)
summary(fhgt)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 54.00 58.00 61.00 61.52 64.00 73.00
mean_fhgt <- 61.52
sd_fhgt <- 4.58
normalPlot(mean = 61.52, sd = 4.58, bounds = c((mean_fhgt-sd_fhgt), (mean_fhgt+sd_fhgt)), tails = FALSE)
normalPlot(mean = 61.52, sd = 4.58, bounds = c((mean_fhgt-2*sd_fhgt), (mean_fhgt+2*sd_fhgt)), tails = FALSE)
normalPlot(mean = 61.52, sd = 4.58, bounds = c((mean_fhgt-3*sd_fhgt), (mean_fhgt+3*sd_fhgt)), tails = FALSE)
Seeing all 3 above plots for 1, 2 and 3 standard deviations from mean, it appears heights approximately follow the 68-95-99.7% Rule
# Use the DATA606::qqnormsim function
qqnormsim(fhgt)
hist(fhgt)
Yes Height does follow normal distribution. QQ plots shows most of the points follow line with few outliers.
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.
prob_10 <- 0.98*0.98*0.98*0.98*0.98*0.98*0.98*0.98*0.98*0.02
prob_10
## [1] 0.01667496
prob_100 <- 0.98 ^ 100
prob_100
## [1] 0.1326196
MEAN
mean_2 <- 1/.02
mean_2
## [1] 50
On average, 50 transistors would be expected to be produced before the first with a defect
STANDARD DEVIATION
sd_2 <- sqrt((1-.02)/(0.02)^2)
sd_2
## [1] 49.49747
MEAN
mean_5 <- 1/.05
mean_5
## [1] 20
On average, 20 transistors would be expected to be produced before the first with a defect
STANDARD DEVIATION
sd_5 <- sqrt((1-.05)/(0.05)^2)
sd_5
## [1] 19.49359
Based on answers of (c) and (d), increasing the probability of an event decreases the mean and standard deviation.
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.
# Using binomial distribution to calculate the probability of observing exactly k successes in n independent trials
n <- 3
k <- 2
p_boy <- 0.51
p_2_boys <- choose(n, k) * p_boy ^ k * (1 - p_boy) ^ (n-k)
p_2_boys
## [1] 0.382347
Probability that two of them will be boys is 38.23%.
(p_boy*p_boy*(1-p_boy)) + (p_boy*(1-p_boy)*p_boy) + ((1-p_boy)*p_boy*p_boy)
## [1] 0.382347
Thus probabilities calculated in (a) and (b) match.
choose(8, 3)
## [1] 56
If we wanted to calculate the probability that a couple who plans to have 8 kids will have 3 boys, part (b) approach will be more tedious since there will 56 different combinations to deal with.
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.
# negative binomial distribution
n <- 10
k <- 3
p_serve <- 0.15
p_3_10 <- choose(n-1, k-1) * p_serve ^ k * (1 - p_serve) ^ (n - k)
p_3_10
## [1] 0.03895012
The probability that on the 10th try she will make her 3rd successful serve, is 3.9%.
The probability that her 10th serve will be successful is 15% given independant serves.
Though it appears both (a) and (b) talk about probabilities of having success in 10th try but they both are different. In (a), it has been asked for 3rd success in 10th try which points to negative binomial distribution but in (b), its just for 10th serve to be success which is like any other try.