Covariance estimate $\frac{1}{n}\sum_ix_ix^T$. From the result it seems the estimate is very poor? This contradicts LLN so I'm wondering if there's something wrong the way I did this simulation?
M = 5;
N = 9999;
Y = zeros(N,M);
A = rand(M,M);
Sigma = A*A';
for i = 1:N
[S,V,U] = svd(Sigma);
X = rand(M,1);
Y(i,1:M) = S*sqrt(V)*X;
end
sum = 0;
for i = 1:N
X = Y(i,:);
sum = sum + X'*X;
end
Sigma_hat = sum/N;
diff = (Sigma - Sigma_hat)./Sigma;
and get
diff =
0.8696 0.8621 0.6979 0.8151 0.7628
0.8621 0.8705 0.6561 0.8067 0.7515
0.6979 0.6561 0.3176 0.4588 0.3674
0.8151 0.8067 0.4588 0.7772 0.6885
0.7628 0.7515 0.3674 0.6885 0.5767