2
$\begingroup$

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?

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

1 Answer 1

1
$\begingroup$

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.

$\endgroup$

Your Answer

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

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