Generate \(x\),\(y\) \(\sim\) \(N(0,1)\)

Generate two sets of random numbers \(x\),\(y\):

##Set seed to ensure reproduciblity
set.seed(10)
x <- rnorm(10, mean=0, sd=1)
y <- rnorm(10, mean=0, sd=1)
mean_x <- mean(x)
mean_y <- mean(y)
difference_of_mean_xy <- mean_x - mean_y
print(difference_of_mean_xy)
## [1] -0.8602484

Difference of mean of \(x\), \(y\) is: -0.8602484

t-test for \(x,y \sim N(0,1)\)

t_test <- t.test(x,y)
print(t_test)
## 
##  Welch Two Sample t-test
## 
## data:  x and y
## t = -2.8063, df = 17.967, p-value = 0.01169
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -1.5043525 -0.2161442
## sample estimates:
##  mean of x  mean of y 
## -0.4906568  0.3695915

From the t-test results with degrees of freedom and a p-value of \(0.0116922\) and using a threshold level of significance of \(\alpha = 0.01\), we FAIL to reject the null hypothesis that the means of two samples, \(x\) and \(y\) are equal. [Since p-value < \(\alpha\)]

Generate \(x \sim N(0,1)\),\(y \sim N(2,1)\)

##Set seed to ensure reproduciblity
set.seed(10)
x <- rnorm(10, mean=0, sd=1)
y <- rnorm(10, mean=2, sd=1)
mean_x <- mean(x)
mean_y <- mean(y)
difference_of_mean_xy <- mean_x - mean_y
print(difference_of_mean_xy)
## [1] -2.860248

Difference of mean of \(x\), \(y\) is: -2.8602484

t-test for \(x \sim N(0,1)\),\(y \sim N(2,1)\)

t_test <- t.test(x,y)
print(t_test)
## 
##  Welch Two Sample t-test
## 
## data:  x and y
## t = -9.3307, df = 17.967, p-value = 2.607e-08
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -3.504352 -2.216144
## sample estimates:
##  mean of x  mean of y 
## -0.4906568  2.3695915

From the t-test results with degrees of freedom 17.9674049 and a p-value of \(2.6066356\times 10^{-8}\) and using a threshold level of significance of \(\alpha = 0.01\), we reject the null hypothesis that the means of two samples, \(x\) and \(y\) are equal.[Since p-value of \(2.6066356\times 10^{-8} < \alpha\)]