jeudi 27 avril 2017

numpy.random.choice vs random.choice

Why does numpy.random.choice not work the same as random.choice? When I do this :

 >>> random.choice([(1,2),(4,3)])
 (1, 2)

It works.

But when I do this:

 >>> np.random.choice([(1,2), (3,4)])
 Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "mtrand.pyx", line 1393, in mtrand.RandomState.choice 
 (numpy/random/mtrand/mtrand.c:15450)
 ValueError: a must be 1-dimensional

How do I achieve the same behavior as random.choice() in numpy.random.choice()?




Aucun commentaire:

Enregistrer un commentaire