samedi 25 août 2018

np.random.randn refuses to take negative arguments

import numpy as np
a=[2,4,6,-1,4]
#b=[np.random.randn(0,2) for i in a[1:]]
#print(b)
b=[np.random.randn(x,y) for x, y in zip(a[1:], a[1:])]
print(b)

OUTPUT:

ValueError                                Traceback (most recent call 
last)
<ipython-input-34-b2077da31d55> in <module>()
      3 #b=[np.random.randn(0,2) for i in a[1:]]
      4 #print(b)
----> 5 b=[np.random.randn(x,y) for x, y in zip(a[1:], a[1:])]
      6 b

<ipython-input-34-b2077da31d55> in <listcomp>(.0)
      3 #b=[np.random.randn(0,2) for i in a[1:]]
      4 #print(b)
----> 5 b=[np.random.randn(x,y) for x, y in zip(a[1:], a[1:])]
      6 b

mtrand.pyx in mtrand.RandomState.randn()

mtrand.pyx in mtrand.RandomState.standard_normal()

mtrand.pyx in mtrand.cont0_array()

ValueError: negative dimensions are not allowed


the error keeps throwing no matter whatever a[x1:x2] i give .

What is the obvious thing i am missing ?

I am fairly new to numpy , so please dont mind if this is very basic .




Aucun commentaire:

Enregistrer un commentaire