Is the covariance matrix of multivariate normal distribution has to be positive definite? Let $\Sigma $ be the covariance matrix of a multivariate normal
distribution.
Thereotically, I guess it does not have to to strictly positive definition,
i.e., $\det (\Sigma )=0$ is possible.
In this case, the density function does not exist, how can I generate random
numbers(vectors) from such multivariate normal distribution?
 A: A multivariate normal distribution has the density function:
$$f(X) = \frac{1}{\sqrt{(2\pi)^n |\Sigma|}} \exp\{\frac{-1}{2}X \Sigma^{-1} X^T\}$$
and the covariance should be positive definite.
So if you need multivariate normal samples you've got to generate them using a valid (meaning symmetric positive definite) covariance matrix.
But then, when you generated the random vectors, the calculated sample covariance can be not positive definite. As an example, consider a covariance matrix of rank 10. If you generate less than 10 sample vectors (i.e. 1 to 9 samples), and calculate their sample covariance, the calculated covariance matrix is not full rank, and its determinant becomes 0, although the generative model has a valid positive definite covariance.
A: This is one possible approach. Suppose that $X\sim N(0,\Sigma)$. We have that
$$
\Sigma=Q\Lambda Q^{\mathrm T},
$$
where $Q$ is an orthogonal matrix with the eigenvectors of $\Sigma$ as its columns and $\Lambda$ is a diagonal matrix with the eigenvalues of $\Sigma$ on its diagonal (this is the eigendecomposition or the spectral decomposition of $\Sigma$). Generate $Z\sim N(0,I)$. Then $Q\Lambda^{1/2}Z\sim N(0,\Sigma)$, where $\Lambda^{1/2}$ is the square root of $\Lambda$ obtained by taking the square roots of the eigenvalues on the diagonal. Indeed,
$$
\operatorname E[(Q\Lambda^{1/2}Z)(Q\Lambda^{1/2}Z)^{\mathrm T}]
=\operatorname E[Q\Lambda^{1/2}ZZ^{\mathrm T}\Lambda^{1/2}Q^{\mathrm T}]
=Q\Lambda^{1/2}I\Lambda^{1/2}Q^{\mathrm T}
=Q\Lambda Q^{\mathrm T}=\Sigma.
$$
The eigendecomposition of $\Sigma$ can by obtained using the $\texttt{eigen}()$ function in $\texttt R$.
I hope this is helpful.
