Different Means, Different Risks: Assessing Stock Risk with the T-Test

We just talked about the F-Test for comparing risk (variance), but what if you want to know if two stocks actually earn different amounts on average? In Chapter 10 of Data Analytics for Finance Using Python, we look at the T-Test.

While the F-Test is all about the “swing” or volatility, the T-Test is all about the “center” or the mean. It’s used to see if the average returns of two groups are significantly different from each other.

The Hypotheses

The authors set up a classic experiment:

  • Null Hypothesis: The mean returns of Stock A and Stock B are equal.
  • Alternative Hypothesis: The mean returns are different.

They used a small sample size of 12 days of closing prices for two different companies.

The Results

After running the test in Python using scipy.stats, they got a p-value of 0.23.

Just like with the F-Test, this p-value is much higher than our 0.05 threshold. This means we can’t reject the null hypothesis. Statistically speaking, there was no real difference in the average returns of these two stocks over that period.

Why it matters

The T-Test is a reality check for your portfolio. If you think one stock is “better” than another because its average price looks higher, the T-Test can tell you if that difference is statistically meaningful or just random noise.

But here’s the catch: the T-Test also assumes your data is “normally distributed.” If your stock data has a lot of crazy spikes or crashes, the T-Test might give you a misleading answer.

And that’s why it matters. In finance, you always need to know if the “gains” you’re seeing are real or just luck of the draw.

Next: Assessing Stock Risk with the Z-Test | Previous: Assessing Stock Risk with the F-Test

About

About BookGrill.net

BookGrill.net is a technology book review site for developers, engineers, and anyone who builds things with code. We cover books on software engineering, AI and machine learning, cybersecurity, systems design, and the culture of technology.

Know More