[SciPy-user] Generating random variables in a joint normal distribution?

Parvel Gu parvel.gu@gmail....
Sun Oct 28 23:26:04 CDT 2007


Thanks a lot.
And I am still puzzled about the input arguments, mean and cov.

So take my current problem for example. I am expecting the random
variable P and S, which follow a joint normal distribution with
(Mu)p=(Mu)s=0.5 (the mean?), and (Sigma)p=(Sigma)s=0.4 (the variance),
and a coefficient ro = 0.8.

According to the function multivariate_normal(mean, cov), only the
matrixes of mean and cov are provided as input. Mapping to my problem,
the mean could be [0.5, 0.5]. and the cov matrix is supposed to be
cov(p,p), cov(p,s)
cov(s,p), cov(s,s)

Is it indicated that we have to get each cov(p, s) with some formula like
ro = cov(p, s) / (sqrt(Dp) * sqrt(Ds)) = 0.8
then fill the result into the cov matrix?


On 10/29/07, Robert Kern <robert.kern@gmail.com> wrote:

> In [1]: from numpy import random
> In [2]: random.multivariate_normal?
> Type:           builtin_function_or_method
> Base Class:     <type 'builtin_function_or_method'>
> Namespace:      Interactive
> Docstring:
>     Return an array containing multivariate normally distributed random numbers
>     with specified mean and covariance.
>     multivariate_normal(mean, cov) -> random values
>     multivariate_normal(mean, cov, [m, n, ...]) -> random values
>     mean must be a 1 dimensional array. cov must be a square two dimensional
>     array with the same number of rows and columns as mean has elements.
>     The first form returns a single 1-D array containing a multivariate
>     normal.
>     The second form returns an array of shape (m, n, ..., cov.shape[0]).
>     In this case, output[i,j,...,:] is a 1-D array containing a multivariate
>     normal.
> --
> Robert Kern
> "I have come to believe that the whole world is an enigma, a harmless enigma
>  that is made terrible by our own mad attempt to interpret it as though it had
>  an underlying truth."
>   -- Umberto Eco
> _______________________________________________
> SciPy-user mailing list
> SciPy-user@scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user

More information about the SciPy-user mailing list