Consider the problem of computing the covariance matrix
where
x
i
= (![](https://s3.us-east-1.amazonaws.com/storage.unifolks.com/qimg-005/sbmgqpk-ouinh0kg.png)
i1,
![](https://s3.us-east-1.amazonaws.com/storage.unifolks.com/qimg-005/sbmgqpk-ouinh0kg.png)
i2)
T
. The question addressed is, what is the fastest way to compute this matrix. In doing this, the
x
i
’s should be randomly generated, and this should be done before answering the following questions. Also, you should answer the questions taking
= 2,000,
= 20,000, and
= 200,000. Finally, you should take advantage of any mathematical simplifications available (e.g., symmetry), to reduce the computational time.
(a) How long does it take to compute
B
using the summation formula? This means that each 2 × 2 matrix
x
i
(x
i
)
T
is computed, and then added into the sum.
(b) How long does it take to compute
B
by first forming the matrix
X, and then using (9.33)? You should use MATLAB’s matrix multiply command to compute the product.
(c) How long does it take to compute
B
by first forming the vectors
c
∗
1
and
c
∗
2, and then using (9.34)? You should use MATLAB’s dot multiply command to compute the dot products.
(d) How long does it take to compute
B
by first forming the matrix
X, and then using MATLAB’s cov command?
(e) Explain the differences, or non-differences, in the computing times. Also, comment if any of the methods failed, and why that happened.