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\)

## Loading required package: shiny
## Loading required package: openintro
## Loading required package: airports
## Loading required package: cherryblossom
## Loading required package: usdata
## Loading required package: OIdata
## Loading required package: RCurl
## Loading required package: maps
## Loading required package: ggplot2
## 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 objects are masked from 'package:openintro':
## 
##     calc_streak, present, qqnormsim
## The following object is masked from 'package:utils':
## 
##     demo
## [1] -1.35
## [1] 0.08850799
normalPlot(mean = 0,sd = 1, bounds = c(-Inf, x), tails = FALSE)

Answer: The percentage represented in the region is: 8.85% # (b) \(Z > 1.48\)

## [1] 1.48
## [1] 0.9305634

Answer: The percentage represented in the region is: 6.94%

(c) \(-0.4 < Z < 1.5\)

mu <- 0
sd <- 1
Z1 <- -0.4
Z2 <- 1.5
#value for "x"
x1 <- Z1 * sd + mu
x2 <- Z2 * sd + mu
x1
## [1] -0.4
x2
## [1] 1.5
#Since we have that P(−0.4<Z<1.5) then, we can find P(−0.4<x<1.5)

# Finding probability.
p1 <- pnorm(x1, mean = 0, sd = 1)
p2 <- pnorm(x2, mean = 0, sd = 1)
p2 - p1
## [1] 0.5886145
# plot
normalPlot(mean = 0, sd = 1, bounds = c(x1, x2), tails = FALSE)

Answer: The percentage represented in the region is: 58.86% # (d) \(|Z| > 2\)

mu <- 0
sd <- 1
Z <- 2
#value for "x"
x <- Z * sd + mu

x1 <- -x
x2 <- x
#Since we have that P(|Z|>2) then, we can find P(|x|>2)=P(x<−2orx>2


# Finding probability 
p1 <- pnorm(x1, mean = 0, sd = 1)
p2 <- 1- pnorm(x2, mean = 0, sd = 1)
p1 +  p2
## [1] 0.04550026
#plot
normalPlot(mean = 0, sd = 1, bounds = c(x1, x2), tails = TRUE)

Answer: The percentage represented on the region is: 4.55%


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.

  1. Write down the short-hand for these two normal distributions. Men, Ages 30 - 34: N(mean = 4313 seconds, sd = 583 seconds) Women, Ages 25 - 29: N(mean = 5261 seconds, sd = 807 seconds)

  2. What are the Z-scores for Leo’s and Mary’s finishing times? What do these Z-scores tell you?

#Leo
(4948 - 4313)/583
## [1] 1.089194
#Mary
(5513 - 5261)/807
## [1] 0.3122677

Leo has a z score of 1.089 and Mary has a z score of 0.312. This shows that both were slower than the average of their groups, and they are a multiple of their z scores away from their means.

  1. Did Leo or Mary rank better in their respective groups? Explain your reasoning. Mary did better respectively, as her z score is lower than Leo’s.
  2. What percent of the triathletes did Leo finish faster than in his group?
1-pnorm(1.089194)
## [1] 0.1380342

Leo finished faster than 13.80% in his group. (e) What percent of the triathletes did Mary finish faster than in her group?

1 - pnorm(0.3122677)
## [1] 0.3774185

Mary finished faster than 37.74% in her group. (f) If the distributions of finishing times are not nearly normal, would your answers to parts (b) - (e) change? Explain your reasoning. The answers to parts b-e are dependent on the assumption that the distributions are normal. If they are not normal, things like the z-scores used will no longer be relevant.


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} \]

  1. 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.
mean <- 61.52
sd <- 4.58
sds <- sd * c(1:3)

#calculating proportions
pnorm(mean + sds, mean = mean, sd = sd) - pnorm(mean - sds, mean = mean, sd = sd)
## [1] 0.6826895 0.9544997 0.9973002

It does follow the 68-95-99.7% rule

  1. Do these data appear to follow a normal distribution? Explain your reasoning using the graphs provided below.

qqnorm(heights)
qqline(heights)

It looks that real data and simulated normal data have approximately the same number of points that fall on the line in normal Q-Q plot. Based on that comparison , I would say that real data follows normal distribution.


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. What is the probability that the 10th transistor produced is the first with a defect? It’s a case of geometric distribution. We’re counting “success”, as finding the defective part. In this case, 9 is the number of failures until we find a defective part.
dgeom(9,0.02)
## [1] 0.01667496
  1. What is the probability that the machine produces no defective transistors in a batch of 100? Rate of “success” is 1-0.02. In order to find probability of getting 100 successes we have to multiply success rate by 100 times.
(1-0.02)^100
## [1] 0.1326196
  1. On average, how many transistors would you expect to be produced before the first with a defect? What is the standard deviation?
1/0.02
## [1] 50
sqrt((1-0.02)/(0.02^2))
## [1] 49.49747
  1. 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 first with a defect? What is the standard deviation?
1/0.05
## [1] 20
sqrt((1-0.05)/(0.05^2))
## [1] 19.49359
  1. 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 probability increases mean and standard deviation decrease.

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.

  1. Use the binomial model to calculate the probability that two of them will be boys.
#number of cases of getting two boys 

num_boys<-2
num_kids<-3
p<-0.51

cases<-factorial(num_kids) / (factorial(num_boys)*factorial(num_kids - num_boys))
prb_two_boys <- cases*(p^num_boys)*((1-p)^(num_kids-num_boys))
prb_two_boys
## [1] 0.382347
  1. Write out all possible orderings of 3 children, 2 of whom are boys. Use these scenarios to calculate the same probability from part (a) but using the addition rule for disjoint outcomes. Confirm that your answers from parts (a) and (b) match.

All possible orderings of 3 children: BBB,BBG,BGB,GBB,BGG,GGB,GBG,GGG 3 orderings include 2 boys.

#probability of getting two boys and a girl

0.51*0.51*(1-0.51) 
## [1] 0.127449
#multiply probability of getting two boys and a girl by 3 cases

0.51*0.51*(1-0.51)*3 
## [1] 0.382347

The answers match.

  1. If we wanted to calculate the probability that a couple who plans to have 8 kids will have 3 boys, briefly describe why the approach from part (b) would be more tedious than the approach from part (a).

The approach from part (b) would be more tedious because it will be harder to list and count all cases with 3 boys and 5 girls than cases with 2 boys and a girl.


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.

  1. What is the probability that on the 10th try she will make her 3rd successful serve?
p <- 0.15
n <- 10
k <- 3


cases <- factorial(n-1)/(factorial(k-1)*(factorial(n-k)))
prb <-cases*(p^k)*((1-p)^(n-k))

prb
## [1] 0.03895012
  1. Suppose she has made two successful serves in nine attempts. What is the probability that her 10th serve will be successful? We have to find the probability of getting 2 successes in 9 previous attempts.
p <- 0.15
n <- 10-1
k <- 3-1



cases <- factorial(n)/(factorial(k)*(factorial(n-k)))
prb2 <-cases*(p^k)*((1-p)^(n-k))

prb2
## [1] 0.2596674
  1. 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 (a) calculates the probability that the 10th attempt is a success while two of the former nine attempts are successes. Part (b) calculates the probability that two of the previous nine attempts are successes.

prob in part a = prob in part b*0.15

prb
## [1] 0.03895012
prb2*0.15
## [1] 0.03895012