[Numpy-discussion] multivariate_normal issue with 'size' argument

Emanuele Olivetti emanuele at relativita.com
Fri May 24 08:02:22 EDT 2013


Hi,

I'm using NumPy v1.6.1 shipped with Ubuntu 12.04 (Python 2.7.3). I observed an
odd behavior of the multivariate_normal function, which does not like int64 for
the 'size' argument.
Short example:
"""
import numpy as np
print np.random.multivariate_normal(mean=np.zeros(2), cov=np.eye(2), size=1)
print np.random.multivariate_normal(mean=np.zeros(2), cov=np.eye(2), 
size=np.int64(1))
"""

Which outputs:

"""
$ python2.7 mvn_bug.py
[[ 0.28880655  0.43289446]]
Traceback (most recent call last):
   File "mvn_bug.py", line 3, in <module>
     print np.random.multivariate_normal(mean=np.zeros(2), cov=np.eye(2), 
size=np.int64(1))
   File "mtrand.pyx", line 3990, in mtrand.RandomState.multivariate_normal 
(numpy/random/mtrand/mtrand.c:16663)
IndexError: invalid index to scalar variable.
"""

I had a brief look to the tracker but haven't found any mention of this issue.
It might be already solved in the current NumPy (v1.7.0)... or not.

I'd like to have your feedback before submitting this issue to the bug tracking 
system.

Best,

Emanuele




More information about the NumPy-Discussion mailing list