library(DATA606)
##
## 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.
3.2 Area under the curve, Part II. What percent of a standard normal distribution N(µ = 0,= 1) is found in each region? Be sure to draw a graph.
pnorm(1.13, mean= 0, sd= 1 )
## [1] 0.8707619
normalPlot(bounds = c(-1.13, Inf))
pnorm(0.18, mean= 0, sd= 1)
## [1] 0.5714237
normalPlot(bounds = c(-Inf, 0.18))
(c) Z > 8
pnorm(8, mean= 0, sd= 1)
## [1] 1
normalPlot(bounds = c(8, Inf))
pnorm(0.5, mean=0, sd= 1)
## [1] 0.6914625
normalPlot(bounds = c(-0.5, 0.5))
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 ???nished 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 ???nishing times of the Men, Ages 30 - 34 group has a mean of 4313 seconds with a standard deviation of 583 seconds. . The ???nishing times of the Women, Ages 25 - 29 group has a mean of 5261 seconds with a standard deviation of 807 seconds. . The distributions of ???nishing times for both groups are approximately Normal. Remember: a better performance corresponds to a faster ???nish.
$N(=4313, =583) $ Men Ages 30 - 34: N(µ =4313, o =583)
Women Ages 25-29: N(µ =5261, o =807)
leo <- 4948
leo_uMale <- 4313
leo_sdMale <- 583
mary <- 5513
mary_ufemale <- 5261
mary_sdfemale <- 807
(leo - leo_uMale) / leo_sdMale
## [1] 1.089194
(mary - mary_ufemale)/mary_sdfemale
## [1] 0.3122677
Mary’s Z score was lower than Leo’s . Therefore she had performed better than leo performed in their respective groups. Mary is 0.31 away from the mean while Leo is 1.08 SD from the mean.
pnorm(leo, leo_uMale, leo_sdMale, lower.tail = FALSE)
## [1] 0.1380342
pnorm( mary, mary_ufemale, mary_sdfemale,lower.tail = FALSE)
## [1] 0.3774186
Yes. In this problem the Z score was determined by a normal distribution. We couldn’t determine how they did in comparison to their respective groups.
3.18 Heights of female college students. Below are heights of 25 female college students.
hts <- 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)
m <- mean(hts)
sd <- sd(hts)
hts_upper1 <- m + sd
hts_upper1
## [1] 66.10367
hts_lower1 <- m - sd
hts_lower1
## [1] 56.93633
hts_upper2 <- m + (2*sd)
hts_upper2
## [1] 70.68733
hts_lower2 <- m - (2*sd)
hts_lower2
## [1] 52.35267
hts_upper3 <- m + (3*sd)
hts_upper3
## [1] 75.271
hts_lower3 <- m - (3*sd)
hts_lower3
## [1] 47.769
length(hts[hts >= hts_lower1 & hts <= hts_upper1]) / length(hts) * 100
## [1] 68
length(hts[hts >= hts_lower2 & hts <= hts_upper2]) / length(hts) * 100
## [1] 96
length(hts[hts >= hts_lower3 & hts <= hts_upper3]) / length(hts) * 100
## [1] 100
In this problem the data which is shown followes approx. the 68-95-99.7 rule - 68-96-100
hist(hts, probability = T)
x <- 40:100
y <- dnorm(x=x, m + sd)
lines(x=x,y=y, col= "red")
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.
pf <- 0.02
ps <- 1 - pf
n <- 10
round(dgeom(n, ps), 2)
## [1] 0
pf <- 0.02
ps <- 1- pf
n <- 100
round(ps^n, 2)
## [1] 0.13
pf <- 0.02
ex <- 1/pf
ex
## [1] 50
sd <- sqrt((1-pf)/(pf^2))
sd
## [1] 49.49747
pf <- 0.05
ex <- 1/pf
ex
## [1] 20
sd <- sqrt((1-pf)/(pf^2))
sd
## [1] 19.49359
When the probability of failure is bigger, the event is more common, meaning the expected number of trials before a success and the standard deviation of the waiting time are smaller.
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.
n <- 3
k <- 2
pboy1 <- 0.51
choose(n, k) * (1 - pboy1)^(n - k) * (pboy1)^k
## [1] 0.382347
children <- c(pboy1 * pboy1 * (1 - pboy1), pboy1 * (1 - pboy1) * pboy1, (1 - pboy1) *
pboy1 * pboy1)
sum(children)
## [1] 0.382347
Part B you’d have to write out the entire # of combinations vs. using combinations to solve for the answer much quicker
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 <- 0.15
n <- 10
k <- 3
choose(n-1, k-1) * (1-p)^(n-k) * p^k
## [1] 0.03895012
Each attempt is independent of the last, so 15%
According to the text: In the negative binomial case, we examine how many trials it takes to observe a fixed number of successes and require that the last observation be a success.