title: Estimating the variance of eigenvalues of sample covariance matrices in Matlab
body: <p>I am trying to investigate the statistical variance of the eigenvalues of sample covariance matrices using Matlab. To clarify, each <strong>sample</strong> covariance matrix is constructed from a <strong>finite</strong> number of vector snapshots (afflicted with random white Gaussian noise). Then, over a <strong>large</strong> number of trials, a large number of such matrices are generated and eigendecomposed in order to estimate the <strong>theoretical</strong> statistics of the eigenvalues.</p>
  
  <p>According to several sources (see, for example, [1, Eq.3] and [2, Eq.11]), the variance of each <strong>sample</strong> eigenvalue should be equal to that <strong>theoretical</strong> eigenvalue squared, divided by the number of vector snapshots used for each covariance matrix. However, the results I get from Matlab aren't even close.</p>
  
  <p>Is this an issue with my code? With Matlab? (I've never had such trouble working on similar problems).</p>
  
  <p>Here's a very simple example:</p>
  
  <pre><code>% Data vector length
  Lvec = 5;
  % Number of snapshots per sample covariance matrix
  N = 200;
  % Number of simulation trials
  Ntrials = 10000;
  % Noise variance
  sigma2 = 10;
  
  % Theoretical covariance matrix
  Rnn_th = sigma2*eye(Lvec);
  % Theoretical eigenvalues (should all be sigma2)
  lambda_th = sort(eig(Rnn_th),'descend');
  
  lambda = zeros(Lvec,Ntrials);
  for trial = 1:Ntrials
      % Generate new (complex) white Gaussian noise data
      n = sqrt(sigma2/2)*(randn(Lvec,N) + 1j*randn(Lvec,N));
      % Sample covariance matrix
      Rnn = n*n'/N;
      % Save sample eigenvalues
      lambda(:,trial) = sort(eig(Rnn),'descend');   
  end
  
  % Estimated eigenvalue covariance matrix
  b = lambda - lambda_th(:,ones(1,Ntrials));
  Rbb = b*b'/Ntrials
  % Predicted (approximate) theoretical result
  Rbb_th_approx = diag(lambda_th.^2/N)
  </code></pre>
  
  <p>References:</p>
  
  <p>[1] Friedlander, B.; Weiss, A.J.; , "<a href="http://www.scribd.com/doc/112067632" rel="nofollow">On the second-order statistics of the eigenvectors of sample covariance matrices</a>," Signal Processing, IEEE Transactions on , vol.46, no.11, pp.3136-3139, Nov 1998
  [2] Kaveh, M.; Barabell, A.; , "<a href="http://www.scribd.com/doc/112046406/Kaveh-86" rel="nofollow">The statistical performance of the MUSIC and the minimum-norm algorithms in resolving plane waves in noise</a>," Acoustics, Speech and Signal Processing, IEEE Transactions on , vol.34, no.2, pp. 331- 341, Apr 1986</p>