After running several calculations with numpy, I end with the mean vector and covariance matrix for a state vector. Is there a way with numpy or scipy to sample a random vector around this mean and covariance?

  • 1
    $\begingroup$ if your variables are normal, then look at numpy.random.multivariate_normal. $\endgroup$ – GoHokies Feb 11 '16 at 21:28

If random vector $X$ has variance $S$, then $LX$ has variance $LSL^\top$.

So generate whatever random variables with mean 0 and identity covariance matrix, then transform it $LX+\mu$, where $\mu$ is your mean vector and $LL^\top$ equals to your covariance matrix. You can find $L$ by cholesky decomposition.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.