Python and data for quants
Shapes in a returns matrix, part 1 of 3
Shapes in a returns matrix · Part 1 of 3
R is a NumPy float64 array of daily returns with shape (250, 40): 250 days by 40 assets. Broadcasting aligns shapes from the right, and a dimension of size 1 stretches to match the other array.
The asset covariance matrix is C = np.cov(R, rowvar=False). How many distinct numbers does it hold, counting C[i, j] and C[j, i] once?
Answer with a number. Fractions, powers and expressions like 23/6 or C(52,5) are read correctly in practice.
The worked solution is in Premium
The answer, the full working and the one idea to take away – for this and all 1,322 questions in the bank. Answer it in practice and your working is marked, with a known mistake named when you make one.
Report an issue with this question
Learn the method
More python and data for quants questions
- What is the length of np.arange(10).reshape(2, 5).sum(axis=0)?Foundation · Premium
- You slice a[::2] and then modify the result. What happens to a?Applied · Premium
- What is the value in np.array([127], dtype=np.int8) + 1?Applied · Premium
- You take b = a[[0, 2, 4]] from a NumPy array a and then set b[0] = 99. What happens to a?Applied · Premium
- For the data 1,2,3,4, pandas’ Series.std() (default ddof=1) returns what, to…Applied · Premium
- You add an array of shape (100, 5) to one of shape (5,). What happens?Foundation · Premium