Generate n-dimensional random numbers in Python

Posted by Magsol on Stack Overflow See other posts from Stack Overflow or by Magsol
Published on 2010-06-03T20:40:01Z Indexed on 2010/06/03 20:44 UTC
Read the original article Hit count: 346

I'm trying to generate random numbers from a gaussian distribution. Python has the very useful random.gauss() method, but this is only a one-dimensional random variable. How could I programmatically generate random numbers from this distribution in n-dimensions?

For example, in two dimensions, the return value of this method is essentially distance from the mean, so I would still need (x,y) coordinates to determine an actual data point. I suppose I could generate two more random numbers, but I'm not sure how to set up the constraints.

I appreciate any insights. Thanks!

© Stack Overflow or respective owner

Related posts about python

Related posts about random-number-generator