[Numpy-discussion] strange behavior of numpy.random.multivariate_normal, ticket:1842
josef.pktd@gmai...
josef.pktd@gmai...
Wed Feb 15 21:52:33 CST 2012
Doing a bit of browsing in the numpy tracker, I found this. From my
search this was not discussed on the mailing list.
http://projects.scipy.org/numpy/ticket/1842
The multivariate normal random sample is not always the same, even
though a seed is specified.
It seems to alternate randomly between two patterns, the sum of the
random numbers is always the same.
Is there a randomness in the svd? Given the constant sum, I guess the
underlying random numbers are the same.
(windows 7, python 32bit on 64 machine, numpy 1.5.1)
import numpy
d = 10
alpha = 1 / d**0.5
mu = numpy.ones(d)
R = alpha * numpy.ones((d, d)) + (1 - alpha) * numpy.eye(d)
rs = numpy.random.RandomState(587482)
rv1 = rs.multivariate_normal(mu, R, 1)
print rv1, rv1.sum()
numpy.random.seed(587482)
rv2 = numpy.random.multivariate_normal(mu, R, 1)
print rv2[0][0], rv2.sum()
running it a few times
>>>
[[ 0.43028555 1.06584226 -0.03496681 -0.31372591 -0.49716804 -1.50641838
0.99209124 0.57236839 -0.32107663 0.5865379 ]] 0.973769580498
0.0979690286727 0.973769580498
>>>
[[ 0.09796903 1.41010513 -1.10250773 0.71321445 0.09903517 0.36432555
-1.27590062 0.04533834 0.37426153 0.24792873]] 0.973769580498
0.430285553017 0.973769580498
>>>
[[ 0.09796903 1.41010513 -1.10250773 0.71321445 0.09903517 0.36432555
-1.27590062 0.04533834 0.37426153 0.24792873]] 0.973769580498
0.430285553017 0.973769580498
>>>
[[ 0.43028555 1.06584226 -0.03496681 -0.31372591 -0.49716804 -1.50641838
0.99209124 0.57236839 -0.32107663 0.5865379 ]] 0.973769580498
0.0979690286727 0.973769580498
Josef
More information about the NumPy-Discussion
mailing list