title: Why does MATLAB native function cov (covariance matrix computation) use a different divisor than I expect?
body: <p>Given a data matrix data of M dimensions and N samples, say,</p>
  
  <pre><code>data = randn(N, M);
  </code></pre>
  
  <p>I could compute the covariance matrix with</p>
  
  <pre><code>data_mu = data - ones(N, 1)*mean(data);
  cov_matrix = (data_mu'*data_mu)./N
  </code></pre>
  
  <p>If I use the native MATLAB function </p>
  
  <pre><code>cov_matrix2 = cov(data)
  </code></pre>
  
  <p>this will always be equal to</p>
  
  <pre><code>cov_matrix = (data_mu'*data_mu)./(N-1)
  </code></pre>
  
  <p>That is, the denominator is (N - 1) is one less.</p>
  
  <p>Why?? Can you reproduce it? Is this a bug??</p>
  
  <p>I use MATLAB version 7.6.0.324 (2008).</p>