t-test Mathematically
The task of the t-test is to determine whether the difference between the two samples' means is significant. What should we take into consideration to perform it?
- Obviously, we should consider the difference between the means itself;
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a849660e-ddfa-4033-80a6-94a1b7772e23/Testing2.0/BiggerDiff.png)
- As shown in the image below, the variance matters too;
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a849660e-ddfa-4033-80a6-94a1b7772e23/Testing2.0/BiggerVar.png)
- Also, the size of each sample should be taken into consideration.
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a849660e-ddfa-4033-80a6-94a1b7772e23/Testing2.0/BiggerSize.png)
To account for the difference between the means, we simply calculate that difference:
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a849660e-ddfa-4033-80a6-94a1b7772e23/Testing2.0/MeanDiff.png)
The situation becomes more complex when it comes to variance. The t-test assumes that the variance is equal for both samples. We will delve deeper into this in the t-test assumptions chapter. To estimate the variance from two samples, the pooled variance formula is applied:
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a849660e-ddfa-4033-80a6-94a1b7772e23/Testing2.0/SPooled.png)
And to account for the size, we need sample sizes:
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a849660e-ddfa-4033-80a6-94a1b7772e23/Testing2.0/Sizes.png)
Let's put it all together into t statistic.
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a849660e-ddfa-4033-80a6-94a1b7772e23/Testing2.0/Tstat.png)
You may have noticed that sample sizes are not used in the most intuitive manner. However, this approach ensures that t follows the t-distribution, as we'll explore in the next chapter.
Everything was clear?
Course Content
Learning Statistics with Python
Learning Statistics with Python
2. Mean, Median and Mode with Python
4. Covariance vs Correlation
t-test Mathematically
The task of the t-test is to determine whether the difference between the two samples' means is significant. What should we take into consideration to perform it?
- Obviously, we should consider the difference between the means itself;
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a849660e-ddfa-4033-80a6-94a1b7772e23/Testing2.0/BiggerDiff.png)
- As shown in the image below, the variance matters too;
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a849660e-ddfa-4033-80a6-94a1b7772e23/Testing2.0/BiggerVar.png)
- Also, the size of each sample should be taken into consideration.
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a849660e-ddfa-4033-80a6-94a1b7772e23/Testing2.0/BiggerSize.png)
To account for the difference between the means, we simply calculate that difference:
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a849660e-ddfa-4033-80a6-94a1b7772e23/Testing2.0/MeanDiff.png)
The situation becomes more complex when it comes to variance. The t-test assumes that the variance is equal for both samples. We will delve deeper into this in the t-test assumptions chapter. To estimate the variance from two samples, the pooled variance formula is applied:
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a849660e-ddfa-4033-80a6-94a1b7772e23/Testing2.0/SPooled.png)
And to account for the size, we need sample sizes:
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a849660e-ddfa-4033-80a6-94a1b7772e23/Testing2.0/Sizes.png)
Let's put it all together into t statistic.
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/a849660e-ddfa-4033-80a6-94a1b7772e23/Testing2.0/Tstat.png)
You may have noticed that sample sizes are not used in the most intuitive manner. However, this approach ensures that t follows the t-distribution, as we'll explore in the next chapter.
Everything was clear?