Habib Khan

Data 606 - Homework 3

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
library(ggplot2)

Problem 3.2

  1. z < -1.13
1 - pnorm(-1.13, mean= 0, sd = 1)
## [1] 0.8707619
normalPlot(mean = 0, sd= 1, bounds= c(-1.13, 4))

(b) z > 0.18

pnorm(0.18, mean = 0, sd = 1)
## [1] 0.5714237
normalPlot(mean= 0, sd= 1, bounds =c(-4, 0.18))

(c) Z > 8

1-pnorm(8, mean=0, sd=1)
## [1] 6.661338e-16
normalPlot(mean=0, sd=1, bounds= c(8,Inf))

(d) |z| < 0.5

normalPlot(bounds=c(-0.5, 0.5))

Answer = 0.383

Problem 3.4

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

Group – > N(mean, sd) Women – > N(5261, 803) Men – > N(4313, 583)

  1. z-score for Leo
(4948-4313)/583
## [1] 1.089194

z-score for Mary

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

The z-score for Leo and Mary are 1.089 and 0.312, Leo’s time was 1.089 above the mean and Mary’s time was 0.312 above the mean in their groups.

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

As per the z-scores in part B, Leo performed 1.089 seconds faster than his group while Mary performed 0.312 seconds faster than her group.

  1. What percent of the traithletes did Leo finish faster than in his group?
pnorm(1.089)
## [1] 0.8619231

Leo performed 86.192 percent better than his group.

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

Mary finished the race 62.247 percent faster than her group.

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

Yes, although z-scores would be still same but the percentiles would be changed due to abnormality in the data.

Problem 3.18

  1. The mean height is 61.52 inches with a SD of 4.58 inches. Use this information to determine if the heights approximately follow the 68-95-99.7% rule.
  2. Also discuss with reasoning if the data appear to follow a normal distribution with reasoning using the graphs given.
femheights <- 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(femheights)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   54.00   58.00   61.00   61.52   64.00   73.00
hist(femheights)

qqnormsim(femheights)

femheightsmean <- mean(femheights)
femheightssd <- mean(femheights)
pnorm(femheightsmean+femheightssd, mean= femheightsmean, sd= femheightssd)
## [1] 0.8413447
pnorm(femheightsmean+2*femheightssd, mean= femheightsmean, sd= femheightssd)
## [1] 0.9772499
pnorm(femheightsmean+3*femheightssd, mean= femheightsmean, sd= femheightssd)
## [1] 0.9986501

Based on the above answers, the data follows 68, 95, 99% rule and it seems that the data is almost normally distributed as 99.86 percent of the data exists within 3 standard deviation but it has not perfectly normal. It has few outliers.

Problem 3.22

  1. Probability that the 10th transistor produced is the first with a defect?
pgeom(10-1, 0.02)
## [1] 0.1829272
  1. Probability that the machine produces no defective transistors in a batch of 100?
1-pgeom(100,0.02)
## [1] 0.1299672
  1. on average, how many transistors would you expect to be produced before the first with a defect? what is the SD?
p <- 0.02
t <- 1/p
t
## [1] 50
sd <- sqrt((1-p)/p^2)
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 SD?
p <- 0.05
t <- 1/p
t
## [1] 20
sd <- sqrt((1-p)/p^2)
sd
## [1] 19.49359
  1. Increasing the defective rate decreases the mean and SD which means that as the defective rate increases, there will be more defects (decreases the mean and SD)

Problem 3.38

  1. Use the binomial model to calculate the probability that two of them will be boys?
boy <- 0.51
n <- 3
x <- 2
dbinom(x, n, boy)
## [1] 0.382347
  1. Write out all possible orderings of 3 children, 2 of whom are boys.

BBG, GBB, BGB

pboys <- ((.51*.51*.49)+(.49*.51*.51)+(.51*.49*.51))
pboys
## [1] 0.382347

Both answers are same

  1. Part B would be more tedious because there are 8 different probabilities which would be there.

Problem 3.42

  1. Probability that on the 10th try she will make her 3rd successful serve?
p <- 0.15
k <- 3
n <- 10
choose(n - 1, k - 1) * (1 - p)^ (n - k) * p^k
## [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?

All the events are independent so the probability of her 10th successful serve will still be 15 percent.

  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?

In part (a) specified pattern of success was asked while in part (b) only one serve was concerned.