I am using the function MultinormalDistribution to generate a random vector using the following code:

  c03 ConstantArray[
   1, {Binomial[n, 2], Binomial[n, 2]}] + (1 - 
     c03) IdentityMatrix[Binomial[n, 2]]]]

Here c03 = 0.959016 and n = 100 so the covariance matrix is very large. To check the resulting random vector, I plugged it into Histogram to see if it made sense. The histogram is a bell curve like it should be, but its mean is not the theoretically predicted zero. In fact, every time I run my code I get a histogram with the same shape but with a different mean which ranges as far as -1 to 1. However, if I generate a random vector of the same length using

RandomVariate[NormalDistribution[], Binomial[n,2]]

it has the correct mean of about zero without fail. Am I using MultinormalDistribution incorrectly? Are these errors because the covariance matrix is so big? I really appreciate any thoughts.

  • 1
    $\begingroup$ Lots of missing stuff. Can you give typical values for c03, c13, and undirectedlist? $\endgroup$ – J. M.'s technical difficulties Nov 3 '17 at 3:44
  • $\begingroup$ In my case c03 = c13 = 0.959016 so actually the sparse array with undirectedlist doesn't matter. However undirectedlist is a list of pairs of indices of length 6Binomial[n,3] = 970200 and is such that the sparse array is symmetric. $\endgroup$ – TimF Nov 3 '17 at 4:40
  • 1
    $\begingroup$ Then why did you not give the simpler example to begin with? Please include this additional information in your post by editing it. In any event: RandomVariate[MultinormalDistribution[ToeplitzMatrix[Prepend[ConstantArray[c03, Binomial[n, 2] - 1], 1]]]] $\endgroup$ – J. M.'s technical difficulties Nov 3 '17 at 4:42
  • $\begingroup$ Also, your guess about the ill-conditioning seems to be correct: With[{c03 = 0.959016, n = 100}, LinearAlgebra`MatrixConditionNumber[ToeplitzMatrix[Prepend[ConstantArray[c03, Binomial[n, 2] - 1], 1]]]] gives 231612.. $\endgroup$ – J. M.'s technical difficulties Nov 3 '17 at 4:47
  • $\begingroup$ I increased the precision in the computation and now the results are making sense. Thanks! $\endgroup$ – TimF Nov 3 '17 at 16:13