Issue
I'm looking for a two-dimensional analog to the numpy.random.normal
routine, i.e. numpy.random.normal
generates a one-dimensional array with a mean, standard deviation and sample number as input, and what I'm looking for is a way to generate points in two-dimensional space with those same input parameters.
Looks like numpy.random.multivariate_normal
can do this, but I don't quite understand what the cov
parameter is supposed to be. The following excerpt describes this parameter in more detail and is from the scipy docs:
Covariance matrix of the distribution. Must be symmetric and positive-semidefinite for “physically meaningful” results.
Later in the page, in the examples section, a sample cov
value is given:
cov = [[1,0],[0,100]] # diagonal covariance, points lie on x or y-axis
The concept is still quite opaque to me, however.
If someone could clarify what the cov
should be or suggest another way to generate points in two-dimensional space given a mean and standard deviation using python I would appreciate it.
Solution
If you pass size=[1, 2]
to the normal()
function, you get a 2D-array, which is actually what you're looking for:
>>> numpy.random.normal(size=[1, 2])
array([[-1.4734477 , -1.50257962]])
Answered By - tamasgal
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.