1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Portfolio Risk Management in Python

Exercise

Statistical tests for normality

In order to truly be confident in your judgement of the normality of the stock's return distribution, you will want to use a true statistical test rather than simply examining the kurtosis or skewness.

You can use the shapiro() function from scipy.stats to run a Shapiro-Wilk test of normality on the stock returns. The function will return two values in a list. The first value is the t-stat of the test, and the second value is the p-value. You can use the p-value to make a judgement about the normality of the data. If the p-value is less than or equal to 0.05, you can safely reject the null hypothesis of normality and assume that the data are non-normally distributed.

clean_returns from the previous exercise is available in your workspace.

Instructions

100 XP
  • Import shapiro from scipy.stats.
  • Run the Shapiro-Wilk test on clean_returns.
  • Extract the p-value from the shapiro_results tuple.