Learning Statistics with Python
The main idea behind the t-test is that it follows the t-distribution. For it to be true, a few important assumptions are made:
- Homogeneity of variance. The variances of the two groups being compared must be roughly equal.
- Normality. Both samples should be approximately Normally distributed.
- Independence The samples are independent. This means the values in one group cannot be influenced by the values in the other group.
The t-test may not provide accurate results if the assumptions are not met.
There are different types of t-tests that handle violations of some of the assumptions:
- If the variances are different, you can run Welch's t-test. Its idea is the same. The only thing that differs is the degrees of freedom.
Performing Welch's t-test instead of the ordinary t-test in Python is as easy as setting
- If samples are not independent(for example, if you want to compare the means of the same group at different time periods), you can run paired t-test. A paired t-test will be discussed in a later chapter.