## What is a T-test?

A T-test is a hypothesis testing procedure that is used to determine if there is a significant difference between the means of two groups. It is based on the t-distribution, which is a probability distribution that is used to estimate the population mean when the sample size is small and the population variance is unknown. The T-test can be used to compare the means of two independent samples (independent T-test) or to compare the mean of a single sample to a known value (one-sample T-test).

## Why use a T-test?

T-tests are used to test hypotheses about the differences between group means in various scientific studies and research projects. They help to determine if the observed differences between groups are due to random chance or if they are statistically significant.

## T-test example

Here’s an example of performing an independent T-test using Python and the SciPy library:

```
import numpy as np
from scipy.stats import ttest_ind
# Generate sample data
group1 = np.random.normal(loc=10, scale=2, size=20)
group2 = np.random.normal(loc=12, scale=2, size=20)
# Perform the T-test
t_statistic, p_value = ttest_ind(group1, group2)
print("T-statistic:", t_statistic)
print("P-value:", p_value)
```

In this example, we generate two groups of random data with different means and perform an independent T-test to determine if there is a significant difference between the means of the two groups.