Problem 1

Step 1: State the Null and Alternative Hypothesis.

Null Hypothesis: H0:μ≤51 Alternative Hypothesis: HA:μ>51

Step 2: Set Significance Level

alph=0.05

Step 3: Use The Z-Formula To Find A Z-Score.

sample_mean<-51
Sigma<-3
n<-10
Population_Mean<-50
z_stats=(sample_mean-Population_Mean)/Sigma/sqrt(n)
z_stats
## [1] 0.1054093

Step 4: Find Probability

##To calculate a two sided p-value, we need to find

P(|Z|≥|0.1054093|)=P(Z≥0.1054093)+P(Z≤−0.1054093)=1−P(Z≤0.1054093)+P(Z≤−0.1054093)=1−Φ(0.1054093)+Φ(−0.1054093)

##To do this we need to c.d.f. of a standard normal

library(distributions3)
## 
## Attaching package: 'distributions3'
## The following object is masked from 'package:stats':
## 
##     Gamma
## The following object is masked from 'package:grDevices':
## 
##     pdf
Z <- Normal(0, 1)  # make a standard normal r.v.
1 - cdf(Z, 1.054093) + cdf(Z, -1.054093)
## [1] 0.2918403

P(Z<1.054093) which we calculate with

cdf(Z, 1.054093)
## [1] 0.8540798

##Finally, sometimes we are interested in one sided Z-tests. For the test

The probability of the average hight is taller than 50 inches is given by P(Z>1.054093)

1 - cdf(Z, 1.054093)
## [1] 0.1459202

Step 5: Conclusion

The probability of their average height being taller than 50 inches is 0.1459202

Problem 2

 #by assumption
Mean1<-51      ## Average body height for boys
Sigma1<-3     ## Standard deviation of body height for boy
Mean2<-53      ## Average body height for girls
Sigma2<-2.5   ## Standard deviation of body height for girls
sigma_sq_1 <- 3^2
sigma_sq_2 <- 2.5^2
n1<-10   ## sample for boys
n2<-10   ## sample for girls

Calculate The Z-Statistic

z_stat <- Mean1 - Mean2 /  sqrt(sigma_sq_1 / n1 + sigma_sq_2 / n2)
z_stat
## [1] 8.081855

To calculate a two-sided p-value, we need to find

P(|Z|≥|-8.081855|)=P(Z≥8.081855)+P(Z≤−8.081855)=1−P(Z≤8.081855)+P(Z≤−8.081855)=1−Φ(8.081855)+Φ(8.081855)

To do this we need to c.d.f. of a standard normal

library(distributions3)

Z <- Normal(0, 1)  # make a standard normal r.v.
1 - cdf(Z,8.081855) + cdf(Z, -8.081855)
## [1] 6.520115e-16

Finally, sometimes we are interest in one sided Z-tests. For the test

H0:μ≤53HA:μ>53

P(Z<8.081855) which we calculate with

cdf(Z, 8.081855)
## [1] 1

P(Z>8.081855) which we calculate with

1 - cdf(Z, 8.081855)
## [1] 3.330669e-16

The probability of the average height of the boys would be taller than the average height of girls, is 3.330669e-16