samedi 13 juin 2015

How to use numpy.random.choice in a list of tuples?

I need to do a random choice with a given probability for selecting a tuple from a list. The next sample code give me an error:

import numpy as np

probabilit = [0.333, 0.333, 0.333]
lista_elegir = [(3, 3), (3, 4), (3, 5)]

np.random.choice(lista_elegir, 1, probabilit)

And the error is:

ValueError: a must be 1-dimensional

How can i solve that?




Aucun commentaire:

Enregistrer un commentaire