Although numpy has convenient utility functions, you can always “rescale” several independent normally distributed variables according to your covariance matrix. Therefore, if you can generate a column vector x (or many vectors grouped into a matrix) in which each element is usually distributed and you scale with the matrix M , the result will have covariance MM^T And vice versa, if you analyze the covariance C in the form MM^T , then it is really simple to make such a distribution even without the utility function NumPy provides (only multiply your bunch of normally distributed vectors by M ).
This may not be the answer you are just looking for, but it is useful to remember, for example:
- If you ever find scaling of random output, you can combine scaling with initial covariance instead
- If you ever need to port code to libraries that do not directly support such a utility method, it is very easy to implement yourself.
source share