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

3.2 Area under the curve

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
normalPlot(mean = 0, sd = 1, bounds = c(-1.13, Inf))

So the area under the curve is .871

  1. z < .18
normalPlot(mean = 0, sd = 1, bounds = c(-Inf, 0.18))

So the area under the curve is .571

  1. z > 8
normalPlot(mean = 0, sd = 1, bounds = c(8, Inf))

So the area under the curve is 6.66e-16, which is approximately 0.

  1. |z| < .5
normalPlot(mean = 0, sd = 1, bounds = c(-.5, .5))

So the area under the curve is .383

3.4 Triathlon times

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.

  1. Write down the short-hand for these two normal distributions.

Men 30-34: N(μ=4313,σ=583) Women 25-29: N(μ=5261,σ=807)

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

Leo’s Z-score (4948-4313)/(807) = 1.0892

Mary’s Z-score: (5513-5261)/(807) = .3123

For Mary’s group, she did better than Leo did for his respective group.

  1. Did Leo or Mary rank better in their respective groups? Explain your reasoning.

Mary ranked better because she has the lower z-score, therefore she has the lower time for her group.

  1. What percent of the triathletes did Leo finish faster than in his group?
(1-pnorm(1.0892))
## [1] 0.1380328

The percent of the triathletes Leo finished faster than is 13.80328%

  1. What percent of the triathletes did Mary finish faster than in her group?
(1-pnorm(.3123))
## [1] 0.3774063

The percent of the triathletes Leo finished faster than is 37.74063%

  1. If the distributions of finishing times are not nearly normal, would your answers to parts (b) - (e) change? Explain.

Yes, because we based our calculations and comparisons based off the assumption that the distributions were normal.

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

heights <- 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)
  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.
htmean <- c(61.52)
htstd <- c(4.58)

one <- heights[heights > htmean - htstd & heights < htmean + htstd]

a <- length(one)/length(heights)

two <- heights[heights > htmean - 2*htstd & heights < htmean + 2*htstd]

b <- length(two)/length(heights)

three <- heights[heights > htmean - 3*htstd & heights < htmean + 3*htstd]

c <- length(three)/length(heights)

p <- c(a, b, c)
p
## [1] 0.68 0.96 1.00

The heights do follow the 68-95-99.7% Rule, appoximately.

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

There are a few outliers, but the distribution appears to be relatively normal.

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.

  1. What is the probability that the 10th transistor is the first with a defect?
((.98)^(9))*(.02)
## [1] 0.01667496

the probability that the 10th transistor is the first with a defect is .01667496

  1. What is the probability that the machine produces no defective transistors in a batch of 100? The events are independent, therefore we can use the below formula:
(.98)^(100)
## [1] 0.1326196

The probability that the machine produces no defective transistors in a batch of 100 is 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/p = 1/(.02) = 50 transistors

I would expect 50 transistors to be produced before the first with a defect.

σ = (p/((1 - p)2))(1/2) = ((.02)/(.98*.98))^(1/2) = .1443

the standard deviation is .1443.

  1. Another machine that also produces transistors has a 5% defective rate where each transistor is procuced independent of the others. On average how many transistors would you expect to be produced with the machine before the first with a defect? What is the standard deviation?

μ = 1/p = 1/(.05) = 20 transistors

I would expect 20 transistors to be produced before the first with a defect.

σ = (p/((1 - p)2))(1/2) = ((.05)/(.95*.95))^(1/2) = .23537557657

the standard deviation is approximately .235

  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?

The wait time for a defective transistor decreases and the probability of there being a defective transistor increases.

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.
((.51)^(2))*(.49)*choose(3, 2)*choose(1, 1)
## [1] 0.382347

The probability that two of them will be boys is 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.

P(BBG | BGB | GBB) = (.51.51.49) + (.51.49.51) + (.49.51.51) = (.127449)(3) = 0.382347. a) and b) are the same probability.

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

There are many more combinations to have 8 kids and 3 of them be boys, so writing out all C(8,3)=56 ways would be very tedious.

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?

So the first 9 times can go any which way, but must include two succesful serves, so it is calculated as C(9,2)(.15)^(2). The tenth serve can go only one way, so it is calculated (.15)(1).

choose(9, 2)*((.15)^(3))
## [1] 0.1215

So there is a 0.1215 chance the tenth serve with be the third successful serve.

  1. Suppose she has made two successful serves in nine attempts. What is the probability that her 10th serve will be successful?

Since the events are independent, the probability that her 10th serve will be successful is .15

  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) asks for a combination of independent outcomes whereas b) asks for just one independent outcome.