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.
Este ejercicio forma parte del curso
Introduction to Portfolio Risk Management in Python
Instrucciones de ejercicio
- Import
shapiro
fromscipy.stats
. - Run the Shapiro-Wilk test on
clean_returns
. - Extract the p-value from the
shapiro_results
tuple.
Ejercicio interactivo práctico
Pruebe este ejercicio completando este código de muestra.
# Import shapiro from scipy.stats
from ____ import ____
# Run the Shapiro-Wilk test on the stock returns
shapiro_results = ____
print("Shapiro results:", shapiro_results)
# Extract the p-value from the shapiro_results
p_value = ____
print("P-value: ", p_value)