Is the determinant of a covariance matrix always zero? My understanding is that given matrix X, I can find its corresponding covariance matrix by:


finding the means of each column
subtracting each mean from each value in its respective column and 
multiplying the resulting matrix by its own transpose. Let's call this matrix C.


Here is what it would look like in Python:

Y = X - numpy.mean(X, axis = 0) 
C = numpy.dot(Y, Y.T)

If I do this, I can prove mathematically (and experimentally using some simple Python code) that det(C) = 0 always.

However, a colleague tells me that using the inverse of a covariance matrix is common in his field and he showed me some R code to demonstrate.

&gt; det(cov(swiss))
[1] 244394171542 

I notice that R has several ways of calculating the covariance matrix that leads to different results. I also notice from Googling that some people say the covariance matrix is always singular (eg here) whereas others say it is not.

So, my question is: why the differences of opinion and what's the true answer?

EDIT: I discovered that the determinant is only zero if the matrix is square. If anybody knows the proof for this or can throw some further light on the matter, I'd be grateful.
No, the covariance matrix is not always singular. Counterexample:
\begin{align}
X&amp;=(\mathbf x_1,\mathbf x_2,\mathbf x_3)=\pmatrix{1&amp;2&amp;3\\ 1&amp;1&amp;4},\\
\bar{\mathbf x}&amp;=\frac13(\mathbf x_1+\mathbf x_2+\mathbf x_3)=\pmatrix{2\\ 2},\\
Y&amp;=(\mathbf x_1-\bar{\mathbf x},\ \mathbf x_2-\bar{\mathbf x},\ \mathbf x_3-\bar{\mathbf x})=\pmatrix{-1&amp;0&amp;1\\ -1&amp;-1&amp;2},\\
YY^T&amp;=\pmatrix{2&amp;3\\ 3&amp;6},\text{ which is nonsingular}.
\end{align}
It is true, however, that when the data matrix $X$ is square or "tall", i.e. when $X$ is $n\times m$ with $n\ge m$ (or equivalently, when the number of data points $m$ does not exceed the number of variables $n$), $YY^T$ is always singular. This is evident because by definition, the sum of all columns of $Y$ is the zero vector. Hence $Y$ has deficient column rank and in turn, $\operatorname{rank}(YY^T)=\operatorname{rank}(Y)&lt;m\le n$.
The result of matrix multiplication is only an approximation of the true covariance matrix and disregards distributions of random variables that are crucial for accurate calcualtion. Hope it helps.