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

Daniele Nicolodi daniele at grinta.net
Fri May 24 09:11:42 EDT 2013


On 24/05/2013 14:02, Emanuele Olivetti wrote:
> 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.
> """

Hello Emanuele,

it works for me with numpy 1.6.2 (python 2.7.3 on mac os x 10.6 via
macports but is should not matter).

Cheers,
Daniele




More information about the NumPy-Discussion mailing list