Standard deviation versus variance
Let's talk about the difference between variance and standard deviation. From the video you already know that the standard deviation \(\sigma\) is simply the square root of the variance. Both measures are used in practice to calculate market or stock volatility. Why should you use one or the other?
In the variance calculation we square the weights and the variances. Because of this squaring, the variance is no longer in the same unit of measurement as the original data. Taking the root of the variance means the standard deviation is restored to the original unit of measure and therefore much easier to interpret.
Let's calculate the standard deviation. Available are the weights
and the cov_matrix
from the previous exercise.
Este exercício faz parte do curso
Introduction to Portfolio Analysis in Python
Instruções do exercício
- Re-create the calculation of the portfolio variance using
weights
and thecov_matrix
. This time, take the square root of the whole calculation, to obtain the standard deviation instead. - Print the standard deviation, the same way we did for the portfolio variance.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Calculate the standard deviation by taking the square root
port_standard_dev = ____.____(np.dot(____.____, np.dot(____, ____)))
# Print the results
print(str(np.round(____, 4) * 100) + '%')