jeudi 16 avril 2020

random.seed() does not work with random.choice()

So i'm trying to generate a list of numbers with desired probability; the problem is that random.seed() does not work in this case.

M_NumDependent = []

for i in range(61729):
    random.seed(2020)
    n = np.random.choice(np.arange(0, 4), p=[0.44, 0.21, 0.23, 0.12])
    M_NumDependent.append(n)
print(M_NumDependent)

the desired output should be the same if the random.seed() works, but the output is different everytime i run it. Does anyone know if there's a function does the similar job of seed() for random.choice()?




Aucun commentaire:

Enregistrer un commentaire