##
## 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.
Graded: 3.2 (see normalPlot), 3.4, 3.18 (use qqnormsim from lab 3), 3.22, 3.38, 3.42
3.2 Area under the curve, Part II. What percent of a standard normal distribution N(mean = 0,sd = 1) is found in each region? Be sure to draw a graph.
1 - pnorm(-1.13, mean=0, sd=1)## [1] 0.8707619
normalPlot(mean = 0, sd = 1, bounds = c(-1.13, Inf), tails = FALSE)pnorm(0.18, mean=0, sd=1)## [1] 0.5714237
normalPlot(mean = 0, sd = 1, bounds = c(-Inf, 0.18), tails = FALSE)1- pnorm(8, mean=0, sd=1)## [1] 6.661338e-16
normalPlot(mean = 0, sd = 1, bounds = c(8, Inf), tails = FALSE)1 - pnorm(.5, mean=0, sd=1)## [1] 0.3085375
pnorm(.5, mean=0, sd=1)## [1] 0.6914625
normalPlot(mean = 0, sd = 1, bounds = c(-0.5, 0.5), tails = FALSE)3.4 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. 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.
a. Write down the short-hand for these two normal distributions. Men: N(µ=4313, sd=583); Women: N(µ=5261, sd=807)
b. What are the Z-scores for Leo’s and Mary’s finishing times? What do these Z-scores tell you? Leo: 1.089; Mary: 0.312
LRunTime <- 4948
LGroupMu <- 4313
LGroupSD <- 583
Leo <- (LRunTime - LGroupMu)/LGroupSD
Leo## [1] 1.089194
MRunTime <- 5513
MGroupMu <- 5261
MGroupSD <- 807
Mary <- (MRunTime - MGroupMu)/MGroupSD
Mary## [1] 0.3122677
c. Did Leo or Mary rank better in their respective groups? Explain your reasoning. Leo’s finishing time Z-score was higher than Mary’s score. Thus, Leo performed better in their respective groups.
d. What percent of the triathletes did Leo finish faster than in his group? 13.79%
pnorm(1.09,lower.tail=FALSE)## [1] 0.1378566
e. What percent of the triathletes did Mary finish faster than in her group? 37.83%
pnorm(0.31,lower.tail=FALSE)## [1] 0.3782805
f. If the distributions of ???nishing times are not nearly normal, would your answers to parts (b) - (e) change? Explain your reasoning. Yes. The answers to parts (b) - (e) would change as the finishing time distriubtions stray further from a normal distribution.
3.18 Heights of female college students. Below are heights of 25 female college students. Below are heights of 25 female college students. (Use qqnormsim)
a. The mean height is 61.52 inches with a standard deviation of 4.58 inches. Use this information to determine if the heights approximately follow the 68-95-99.7% Rule.
h <- 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(h)## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 54.00 58.00 61.00 61.52 64.00 73.00
hmean <- 61.52
hsd <- 4.58
h_sd1 <- c(hmean - hsd, hmean + hsd)
h_sd2 <- c(hmean - 2 * hsd, hmean + 2 * hsd)
h_sd3 <- c(hmean - 3 * hsd, hmean + 3 * hsd)
h_sd1## [1] 56.94 66.10
h_sd2## [1] 52.36 70.68
h_sd3## [1] 47.78 75.26
Do these data appear to follow a normal distribution? Explain your reasoning using the graphs provided below. The histogram is slightly skewed right and there are two noticiable outliers in the q-q plot. However, the data appears to follow a nearly normal distribution.
hist(h)qqnorm(h)
qqline(h, col = 2)qqnormsim(h)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.
p <- .02
n <- 10
(1 - p)^(n - 1) * p## [1] 0.01667496
n = 100
b = (1 - p)**n
round(b, 4)## [1] 0.1326
c. On average, how many transistors would you expect to be produced before the first with a defect? What is the standard deviation?
u = 1/p
u## [1] 50
sd <- sqrt((1-p) / (p^2))
sd## [1] 49.49747
d. Another machine that also produces transistors has a 5% defective rate where each transistor is produced independent of the others. On average how many transistors would you expect to be produced with this machine before the ???rst with a defect? What is the standard deviation?
p <- 0.05
u <- 1/p
u## [1] 20
sd <- sqrt((1 - p)/(p^2))
sd## [1] 19.49359
e. Based on your answers to parts (c) and (d), how does increasing the probability of an event affect the mean and standard deviation of the wait time until success? As the probability increases, the mean and standard deviation decrease.
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.
p <- 0.51 # probability of having a boy
n <- 3 # number of independent trials
k <- 2 # number of successes (boys)
outcome <- (factorial(n)/(factorial(k)*(factorial(n-k))))*p^k*(1-p)^(n-k) # binomial model
outcome## [1] 0.382347
| Child 1 | Child 2 | Child 3 |
|---|---|---|
| Girl | Boy | Boy |
| Boy | Girl | Boy |
| Boy | Boy | Girl |
outcome <- (1-p) * 3 * p^2
outcome## [1] 0.382347
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.
p <- .15
n <- 9
k <- 2
choose(n,k) * p^3*(1-p)^7## [1] 0.03895012
Suppose she has made two successful serves in nine attempts. What is the probability that her 10th serve will be successful?
Each attempt is independent, thus the probability of the 10th service being successful is p (15%).
Even though parts (a) and (b) discuss the same scenario, the probabilities you calculated should be different. Can you explain the reason for this discrepancy?
*Part (b) asks for the probability of an independent event, while (a) is asking for a probability that is dependent on previous outcomes. Thus, the probabilities are different for these two calculations.