library(IS606)
## 
## Welcome to CUNY IS606 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='IS606') will list the demos that are available.
## 
## Attaching package: 'IS606'
## The following object is masked from 'package:utils':
## 
##     demo
library(StMoSim)
## Warning: package 'StMoSim' was built under R version 3.2.3
## Loading required package: RcppParallel
## Warning: package 'RcppParallel' was built under R version 3.2.3
## Loading required package: Rcpp
## Warning: package 'Rcpp' was built under R version 3.2.3

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.

For a standard normal distribution, we can use the default mean=0 and sd=1 for the normalPlot function.

  1. Z>1.13
normalPlot(bounds=(c(1.13,Inf)))

  1. Z<0.18
normalPlot(bounds=(c(-Inf,0.18)))

  1. Z>8
normalPlot(bounds=(c(8,Inf)))

  1. |Z| < 0.5
normalPlot(bounds=(c(-Inf,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 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 fiishing 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.

N(µ=4313, sd=583) for Men and N(µ=5261, sd=807) for women

  1. What are the Z-scores for Leo’s and Mary’s finishing times? What do these Z-scores tell you?
z_leo <- (4948-4313)/583
z_leo
## [1] 1.089194
z_mary <- (5513-5261)/807
z_mary
## [1] 0.3122677

Leo is 1.09 standard deviations above the mean and Mary is only 0.31 standard deviation above the mean. So Mary did better in her group than Leo (in this case, the lower the z-value, the faster is your finishing time)

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

Mary rank better than Leo. In this case, the lower the z-value the higher is your rank.

  1. What percent of the triathletes did Leo finish faster than in his group?
pnorm(1.09,lower.tail=FALSE)
## [1] 0.1378566
  1. What percent of the triathletes did Mary finish faster than in her group?
pnorm(0.31,lower.tail=FALSE)
## [1] 0.3782805
  1. If the distributions of finishing times are not nearly normal, would your answers to parts (b) - (e) change? Explain your reasoning.

No, the answers will be same. The z score and corresponding percentile score gives your performance relative the other participants. So if you are in the 37.8 percentile, it does not matter whether the distribution is normal, multimodal, skewed, etc…you are still in that cut-off line on the graph where 37.8% of the area is computed.

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

hgt <- 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(hgt)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   54.00   58.00   61.00   61.52   64.00   73.00
hist(hgt)

qqnormSim(hgt, nSim=500)

pnorm(61.52+4.58,mean=61.52,sd=4.58)
## [1] 0.8413447
pnorm(61.52+2*4.58,mean=61.52,sd=4.58)
## [1] 0.9772499
pnorm(61.52+3*4.58,mean=61.52,sd=4.58)
## [1] 0.9986501
  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.

No. The sample data above does not follow the 68-95-99.7% rule. The distribution seems to be skewed to the left.

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

Not from the 68-95-99.7% rule. Although, when executing the Q-Q plot simulation (500 times), it seems that all the point are within the gray area (even the high value outliers), suggesting that the sample data is normal (by this standards).

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 produced is the first with a defect?

define p(sucess) as the probability the transistor is defective = .02

pgeom(10-1,0.02)
## [1] 0.1829272
  1. What is the probability that the machine produces no defective transistors in a batch of 100?

The probabilty that the 101th transistor is defective

pgeom(100,0.02)
## [1] 0.8700328
  1. On average, how many transistors would you expect to be produced before the first with a defect? What is the standard deviation?
#mean
1/0.02
## [1] 50
#standard deviation
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?
#mean
1/0.05
## [1] 20
#standard deviation
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?

increasing the probability of success decreases the wait time for success and decreases the spread in the distribution

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.
dbinom(2,3,0.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.
# BBG GBB BGB #
(0.51^2)*0.49*3
## [1] 0.382347

Confirm that your answers from parts (a) and (b) match. (c) 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).

My answer for (a) and (b) matched - 0.382347. The approach from part (b) will be more tedious because you have to manually draw all the possible combinations of 3 boys from 8 siblings while in (a) the choose function will compute that number for you

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?
choose(9,2)*0.15^3*0.85^7
## [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?

Since each attempt is independent of each other and the probability of success is the same for each attempt, the probability of success on the 10th serve is the same as the probability of success for the previous 9 servers - 0.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?

(a) fits the case of a negative binonmial distribution - (probability of kth success on the nth trial). For (a) we are looking for the 3rd success (the last attempt being a success) after the 10th attempt. For (b), we are not concern about the probabilities of the first 9 attempts - we are only concern about the probability of success on the 10 attempt.