library('DATA606')
## Loading required package: shiny
## Warning: package 'shiny' was built under R version 3.5.1
## 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
## Warning: package 'OIdata' was built under R version 3.5.1
## Loading required package: RCurl
## Warning: package 'RCurl' was built under R version 3.5.1
## Loading required package: bitops
## Loading required package: maps
## Warning: package 'maps' was built under R version 3.5.1
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 3.5.1
## 
## Attaching package: 'ggplot2'
## The following object is masked from 'package:openintro':
## 
##     diamonds
## Loading required package: markdown
## Warning: package 'markdown' was built under R version 3.5.1
## 
## 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
library('data.table')

Chapter 3 Homework

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.

  1. Z > −1.13

The area under the curve where the Z score is greater than -1.13 is 0.87. Using the complement Probability 1-P.

1-0.1292
## [1] 0.8708
normalPlot(mean = 0, sd = 1, bounds = c(-1.13, 5), tails = FALSE)

(b) Z < 0.18 The area under the curve where the Z score is less than 0.18 is .5714

normalPlot(mean = 0, sd = 1, bounds = c(-5, 0.18), tails = FALSE)

  1. Z > 8 The area under the curve where the Z score is greater than 8 is 0. Since all Z greater than or equal to 3.50, the probability is greater than or equal to 0.9998, and using the complement rule, 1-1= 0.
normalPlot(mean = 0, sd = 1, bounds = c(0, 0), tails = FALSE)

  1. |Z| < 0.5

Can be re-written as -.5 < z > .5 = P(Z<.5)-P(Z>-.5) The area under the curve is 0.383

0.6915-0.3085
## [1] 0.383
normalPlot(mean = 0, sd = 1, bounds = c(-.5, .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:

• 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. ###Answer For men, N(u=4313, sd=583) For women, N(u=5261, sd=807)

  1. What are the Z-scores for Leo’s and Mary’s finishing times? What do these Z-scores tell you? ###Answer Leo’s z-score is 1.09
(4948-4313) / 583
## [1] 1.089194

Mary’s z-score is 0.312

(5513-5261) / 807
## [1] 0.3122677

The z-scores show the number of standard deviations either above or below the mean.

  1. Did Leo or Mary rank better in their respective groups? Explain your reasoning. ###Answer We see that Leo finished better than Mary did in his group than she did within her’s. Leo was more than a full standard deviation above the mean while Mary was only 1/3 above the mean.

  2. What percent of the triathletes did Leo finish faster than in his group? ###Answer Leo finished faster than 86.21% of the runners while

  3. What percent of the triathletes did Mary finish faster than in her group? ###Answer Mary finished faster than 62.17% of the runners in her group.

  4. If the distributions of finishing times are not nearly normal, would your answers to parts
      1. change? Explain your reasoning. Yes. If the data was not nearly normal, then the deviations from the mean would

3.18 Heights of female college students. Below are heights of 25 female college students.

  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. ###Answer Yes, the below calculations show that the data follows the 68-95-99.7% Rule or the Empirical Rule.
data =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)


one_sd<-data[between(data,(mean(data)-sd(data)), (mean(data)+sd(data)))]
length(one_sd) / length(data)    
## [1] 0.68
two_sd<-data[between(data,(mean(data)-2*sd(data)), (mean(data)+2*sd(data)))]
length(two_sd) / length(data)
## [1] 0.96
three_sd<-data[between(data,(mean(data)-3*sd(data)), (mean(data)+3*sd(data)))]
length(three_sd) / length(data)
## [1] 1
  1. Do these data appear to follow a normal distribution? Explain your reasoning using the graphs provided below.

Answer

Yes. The grpahs show a unimodal distribution with the highest bar being in the middle of the graph.

qqnorm(data)
qqline(data)

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 P(X=k) = (1-p)^(k-1)*p

  1. What is the probability that the 10th transistor produced is the first with a defect?

k=10 1-p = .8 k-1=10 p=

Answer: 0.01667

p <- .02
k<- 10
One_minus_p <- 1-p

prob_tenth_transistor_defect <- (One_minus_p^(k-1))*p
prob_tenth_transistor_defect
## [1] 0.01667496
  1. What is the probability that the machine produces no defective transistors in a batch of 100? ##Answer: 0.1326196
prob_of_defect <- .02
prob_of_no_defect <- 1-prob_of_defect
n <-100

prob_of_no_defect^n
## [1] 0.1326196
  1. On average, how many transistors would you expect to be produced before the first with a defect? ##Answer: 50
u<- 1/p
u
## [1] 50

What is the standard deviation? ##Answer: 49.49747

var <- (1-p) / (p^2)
sd <- sqrt(var)
sd
## [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? ##Answer: 20 transitors before a defect with 19.49 standard deviation.
p2 <- .05
u2 <- 1/p2
u2
## [1] 20
var2 <- (1-p2) / (p2^2)
sd2 <- sqrt(var2)
sd2
## [1] 19.49359

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? ##Answer: Increasing the probability of an event lowers the mean and standard deviation of the wait until success.

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.

  1. Use the binomial model to calculate the probability that two of them will be boys. ##Answer: The probability that two of the babies will be boys is 0.382

n = 3 k = 2 p = .51

dbinom(2,size=3,prob = .51)
## [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. ##Answer: Matches the probability in part (a), 0.382

P(g)XP(b)xP(b) P(b)xP(g)xP(g) P(b)xP(b)xP(g)

prob_g <- .49
prob_b <- .51

(prob_g*prob_b*prob_b) + (prob_b*prob_g*prob_b) +(prob_b*prob_b*prob_g)
## [1] 0.382347

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). ##Answer: It would be manually tedious to repeatedly write out the order of the probabilities. The three boys could be at any three of the 8 outcomes. Also, this would be prone to error.

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.

  1. What is the probability that on the 10th try she will make her 3rd successful serve? ##Answer:First find the probability that she will make 2 successful serves in her first 9 tries. Then multiply the probability that she will have a successful try on her 10th. She has a 3.9% chance
dbinom(2,size=9,prob = .15) * .15
## [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? ##Answer: Given independence of each try, she has a 15% percent chance on her 10th try.

  2. 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? ##Answer: Each serve is independent of each other. In part (a) we did not know which two serves were successful. In part (b), we were informed that two of the first serves were successful.