pnorm(150, 120, 10, lower.tail = FALSE)
## [1] 0.001349898
#Standard Deviation for sample size of 16 is:
10/sqrt(16)
## [1] 2.5
#Answer
pnorm(126, 120, 2.5, lower.tail = TRUE) - pnorm(122, 120, 2.5, lower.tail = TRUE)
## [1] 0.2036579
pbinom(2, 7, 0.15, lower.tail = FALSE)
## [1] 0.07376516
Mean is n*p
Standard deviation = sqrt(n * p * (1-p))
mu<-100*0.15
st.dev.<-sqrt(100*0.15*0.85)
pnorm(17.5, mu, st.dev., lower.tail = TRUE)
## [1] 0.7580801
z<-qnorm(0.05, lower.tail=FALSE)
4.8 - z * 1.5 / sqrt(100)
## [1] 4.553272
4.8 + z * 1.5 / sqrt(100)
## [1] 5.046728
\(\color{red}{\text{Answer:}}\) (4.55, 5.05)
z<-qnorm(0.025, lower.tail=FALSE)
z
## [1] 1.959964
popprop<-0.49
n<-1226
SE<-sqrt(popprop*(1-popprop)/n)
popprop - z*SE
## [1] 0.4620175
popprop + z*SE
## [1] 0.5179825
\(\color{red}{\text{Answer:}}\) (46.2%, 51.8%)
200, -99, 100, -50, 40, -60, 20, 30, 50, 300, -120, 100, 50, 30, -70, 40
A negative sign indicates an undercharge - the scanner price was below the shelf price.
a<-c(200, -99, 100, -50, 40, -60, 20, 30, 50, 300, -120, 100, 50, 30, -70, 40)
stem(a)
##
## The decimal point is 2 digit(s) to the right of the |
##
## -1 | 20
## -0 | 765
## 0 | 2334455
## 1 | 00
## 2 | 0
## 3 | 0
\(\color{red}{\text{Answer:}}\) The distribution of the data appears to be close enough to normal. The minimum value is -120, and the maximum value is 300. It appears that there are no significant outliers.
#Mean:
mean(a)
## [1] 35.0625
#Range:
max(a)-min(a)
## [1] 420
quantile(a)
## 0% 25% 50% 75% 100%
## -120.0 -52.5 35.0 62.5 300.0
boxplot(a)
\(\color{red}{\text{Answer:}}\) The data appears nearly normal, there is not a lot of variability in our data, “300” seems to be an outlier.
quantile(a)
## 0% 25% 50% 75% 100%
## -120.0 -52.5 35.0 62.5 300.0
#IQR
iqr<-IQR(a)
#Q1 - 1.5*IQR
-52.5-1.5*iqr
## [1] -225
#Q3 + 1.5*IQR
62.5+1.5*iqr
## [1] 235
\(\color{red}{\text{Answer:}}\) 300 is an outlier.
The sample is random and our sample is less than 10% of the total scans. The skew is not very strong.
H0: The mean overcharge = 0
HA: The mean overcharge > 0
z<-(35.0625-0)/(1.083/sqrt(16))
pnorm(z, lower.tail = FALSE)
## [1] 0
Since the p-value is 0 which is less than 0.05 significance level, we reject H0. The data provide convincing evidence that the average overcharge is greater that 0
Sorted data:
-120, -99, -70, -60, -50, 20, 30, 30, 40, 40, 50, 50, 100, 100, 200, 300
# Right Lane Left Lane
# Sample size 5 6
# Sample mean 65 69
# Sample standard deviation 4.12 3.22
H0: The right lane mean equals the left lane mean
HA: The right lane mean is slower than the left lane mean
We assume independence within groups: that all sample observations are sampled randomly and that the observations we are looking at are less that 10% of the entire population of all cars. We also assume independence between groups, which is reasonalbe since the sample is random. We assume normal distribution without strong skew.
#PointEstimate = MuLL - MuRL
PointEstimate<-69-65
#Standard Error
SE<-sqrt(((3.22^2)/6)+((4.12^2)/5))
T<-(PointEstimate-0)/SE
T
## [1] 1.767258
#p-value
dt(T, 4)
## [1] 0.0886121
\(\color{red}{\text{Answer:}}\) Because our p-value is larger than 0.01 we do not reject out null hypothesis and conclude that there is no difference between right late and left lane means.
Verifying Conditions: We assume that both samples follow a normal model and that the observations are independent of each other, each group is a simple random sample from less than 10% of the population, the observations are independent, both within the samples and between the samples. The success-failure condition also holds for each sample - there are 10 success and failures in each sample.
Hypothesis Testing:
H0: There is no difference between the proportion of adults who are active and suffered heart attacks and the proportion of adults who are not active and suffered heart attacks.
HA: There is a difference between the proportion of adults who are active and suffered heart attacks and the proportion of adults who are not active and suffered heart attacks.
#Pooled Proportion
n1<-100
n2<-200
pp<-(10+25)/(n1+n2)
#Proportions of active adults who suffered heart attacks
p1<-10/n1
#Proportions of not active adults who suffered heart attacks
p2<-25/n2
#Point Estimate of difference
pe<-p1-p2
#Standard Error Calculation
SE<-sqrt(((pp*(1-pp))/n1)+((pp*(1-pp))/n2))
SE
## [1] 0.03931709
#Using the point estimate and standard error to calculate a p-value for the hypothesis test
Z<-(pe-0)/SE
pvalue<-2*pnorm(Z, lower.tail = TRUE)
\(\color{red}{\text{Answer:}}\) Because p-value is larger than 0.05 we cannot reject our null hypothesis and we conclude that there is no difference between the proportion of adults who are active and suffered heart attacks and the proportion of adults who are not active and suffered heart attacks.
#Recalculating the standard error using the sample proportions:
SE<-sqrt(((p1*(1-p1))/n1)+((p2*(1-p2))/n2))
SE
## [1] 0.03803781
#z for 99% confidence interval
z<-qnorm(0.005, lower.tail=FALSE)
z
## [1] 2.575829
#Confidence interval = pointestimate ± z*SE
round(pe-z*SE,2)
## [1] -0.12
round(pe+z*SE,2)
## [1] 0.07
\(\color{red}{\text{Answer:}}\) (-0.12,0.07)