I want to generate a random covariance matrix ($c \in \mathcal{R}^{n \times n} $) whose eigenspectra, i.e., $n$ eigenvalues $e_0 \in \mathcal{R}^{n\times 1}$ and diagonal elements $c_{ii} \,\, i=1 \,\,... \, n $ and first off-diagonal elements $c_{i, i+1} \,\, i=1 \,\,... \, n-1 $are known.

And of course, the sum of diagonal elements should be equal to the sum of eigenvalues. Also, I would like the covariance matrices to be uniform distribution or as close to uniform as possible. Can this be done?

  • 1
    $\begingroup$ What probability distribution do you want to use? See my analyses at stats.stackexchange.com/a/477365/919 and stats.stackexchange.com/a/215647/919 for a start. Observe, too, that all the $c_{ii}$ must lie within the range of the eigenvalues and must have the same sum as the eigenvalues. But that still leaves great latitude to specify the distribution of the covariance matrices that satisfy these criteria. $\endgroup$
    – whuber
    May 21, 2022 at 14:57
  • $\begingroup$ @whuber I would prefer the covariance matrix to be from a uniform distribution (or as close to uniform ) as possible. Also, the example you mention in the link is great and I see the diagonal values from $\Sigma$ end up becoming the diagonals of the coviariance matrix but the eigenvalues are not constrained. I modified the original question. $\endgroup$ May 25, 2022 at 16:11
  • $\begingroup$ Unfortunately, there does not exist a uniform distribution on the space of all possible $n\times n$ covariance matrices. There is a relation between the diagonal of the matrix and the eigenvalues: the sum of the values on the diagonal invariably equals the sum of the eigenvalues. Moreover, because these are covariance matrices, their diagonal elements are non-negative. These are significant constraints! Why not explain why you want to generate these matrices and what they are intended to represent? That could give us some guidance. $\endgroup$
    – whuber
    May 25, 2022 at 16:14
  • 1
    $\begingroup$ Sure, there is a lot of context behind here. I work in neuroscience and devlop algorithms for generating surrogate data . Essentially, my main work here is that given a n x t empirical timeseries $v_0$ whose temporal similarity matrix is given by ( $c_{t0}= v_0^t v_0$), I want to obtain a surrogate temporal similarity matrix $c_{t1} \in {R}^{t \times t}$ that has the same eigenvalues as $c_{t0}$ and the diagonal and off-diagonal elements are preserved. I agree this is a very hard (and almost ill-defined ) problem. I am thinking of other ways to solve this problem as well. $\endgroup$ May 25, 2022 at 16:23


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.