Null Hypothesis: H0:μ≤51 Alternative Hypothesis: HA:μ>51
alph=0.05
sample_mean<-51
Sigma<-3
n<-10
Population_Mean<-50
z_stats=(sample_mean-Population_Mean)/Sigma/sqrt(n)
z_stats
## [1] 0.1054093
##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
cdf(Z, 1.054093)
## [1] 0.8540798
##Finally, sometimes we are interested in one sided Z-tests. For the test
1 - cdf(Z, 1.054093)
## [1] 0.1459202
The probability of their average height being taller than 50 inches is 0.1459202
#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
z_stat <- Mean1 - Mean2 / sqrt(sigma_sq_1 / n1 + sigma_sq_2 / n2)
z_stat
## [1] 8.081855
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)
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
H0:μ≤53HA:μ>53
cdf(Z, 8.081855)
## [1] 1
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