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

Peter Cock p.j.a.cock at googlemail.com
Fri May 24 09:12:32 EDT 2013


On Fri, May 24, 2013 at 1:59 PM, Emanuele Olivetti
<emanuele at relativita.com> wrote:
> Interesting. Anyone able to reproduce what I observe?
>
> Emanuele


Yes, I can reproduce this IndexError under Mac OS X:

$ which python2.7
/usr/bin/python2.7
$ python2.7
Python 2.7.2 (default, Oct 11 2012, 20:14:37)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> print np.random.multivariate_normal(mean=np.zeros(2), cov=np.eye(2), size=1)
[[ 0.68446902  1.84926031]]
>>> print np.random.multivariate_normal(mean=np.zeros(2), cov=np.eye(2), size=np.int64(1))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mtrand.pyx", line 3990, in
mtrand.RandomState.multivariate_normal
(numpy/random/mtrand/mtrand.c:16663)
IndexError: invalid index to scalar variable.
>>> np.__version__
'1.6.1'
>>> quit()

And on a more recent self-compiled Python and NumPy,

$ which python3.3
/Users/pjcock/bin/python3.3
$ python3.3
Python 3.3.1 (default, Apr  8 2013, 17:54:08)
[GCC 4.2.1 Compatible Apple Clang 4.0 ((tags/Apple/clang-421.0.57))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> print(np.random.multivariate_normal(mean=np.zeros(2), cov=np.eye(2), size=1))
[[-0.57757621  1.09307893]]
>>> print(np.random.multivariate_normal(mean=np.zeros(2), cov=np.eye(2), size=np.int64(1)))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mtrand.pyx", line 4161, in
mtrand.RandomState.multivariate_normal
(numpy/random/mtrand/mtrand.c:19140)
IndexError: invalid index to scalar variable.
>>> np.__version__
'1.7.1'

Peter



More information about the NumPy-Discussion mailing list