# (numpy/scipy) Build a random vector given mean vector and covariance matrix

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?

• if your variables are normal, then look at numpy.random.multivariate_normal. – 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.