[SciPy-user] Generating random variables in a joint normal distribution?
Sun Oct 28 21:42:06 CDT 2007
Parvel Gu wrote:
> Hi all,
> Since I am fresh to use SciPy for simulation, I am not sure about how
> to get a sequence of pairs of random variables in a joint normal
> I have read the info docs in the module scipy.stats. It seems that
> only the normal distribution rvs for single variable is provided. Thus
> one sequence of random variables could be get by calling
> stats.norm.rvs() for times (right?). But if I want pairs of random
> variables, for example, (p, s), which are expected to be in the joint
> normal distribution of some given coefficient ro, would there be any
> routine provided to do this just like stats.norm.rvs?
> If currently there is no such routine, would there be some workaround
> to achieve this by combining the existing routines? I am not very good
> at numerical probabilities...
In : from numpy import random
In : random.multivariate_normal?
Base Class: <type 'builtin_function_or_method'>
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
The second form returns an array of shape (m, n, ..., cov.shape).
In this case, output[i,j,...,:] is a 1-D array containing a multivariate
"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
More information about the SciPy-user