2025-11-08

1. Hypothesis testing

In this presentation I will be explaining about hypothesis testing. It helps us decide whether a statement about a population is true or not based on the data.

2. Dataset

I created two groups of random numbers that show two samples for this test

group1= rnorm(21,mean= 46,sd= 5)
group2= rnorm(24,mean= 57,sd= 5)

head(group1)
## [1] 43.69091 50.21965 47.00670 48.50827 46.38668 42.84007
head(group2)
## [1] 53.00721 63.94151 55.90998 59.94482 58.89165 51.93504

And these samples will be helping me test if their average values are the same or not.

3. Density plot of the Two Samples

I used this density plot to look at the shape and the spread of the two samples.

4. Boxplot of the Two Samples

I used a box plot to see the difference between the two samples in a simple way.

5. Formula for the T-test

The formula is:

\[ t = \frac{{X}_1 - {X}_2} {\sqrt{\frac{(s_1)^2}{n_1} + \frac{(s_2)^2}{n_2}}} \] \({X}_1\) and \({X}_2\) are the sample means,
\(s_1\) and \(s_2\) are the standard deviations,
\(n_1\) and \(n_2\) are sample sizes.

This formula will help me compare the two sample means in my test.

6. R Code Example

result= t.test(group1,group2)
result
## 
##  Welch Two Sample t-test
## 
## data:  group1 and group2
## t = -5.2141, df = 43, p-value = 5.007e-06
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -12.029270  -5.319271
## sample estimates:
## mean of x mean of y 
##  47.10182  55.77609

I used this t-test to find if the two groups have the different mean values and yes they are completely different.

7. 3D Plot

I used a 3D plot to visualize both the groups and see how they spread across the three dimensions.

8. Understanding the Results

In hypothesis testing we compare the p-value with 0.05 to decide if the groups are really different.

\[ H_0:\mu_1=\mu_2\quad\text{and}\quad H_1:\mu_1\neq\mu_2 \]

If the p-value is smaller than 0.05 then we will reject the null hypothesis.

In my test the p-value was very very small so I can say that the two groups have different mean values from that. And this you can see in my R code example slide.

9. Conclusion

From all this I can finally conclude that,

I compared two groups by using a t-test to see if their average values are different.

The p-value I got was very very small which shows that the two groups are not the same.

By doing this I completely understood how hypothesis testing helps to make decisions using the data.