I wanted to create a random array with the lenght of 24 in python, by assigning the values of a list seq=[30,170]
. So I wanted to have an array which looks like a=[30,30,30,170,30,170,...]
. The problem is, that the values shouldn't be assigned completely random, but with a certain probability. In this case, if the first value is 30 (or 170) the probability of the next value to be 30 (or 170) as well, should be 90% and the probability of the next value to be 170 (or 30) should be 10%.
Does anyone know how to do this? For the moment I only found how to arrange them randomly. Thanks!!
import random
seq=[30,170]
a = random.choices(seq,k=24)
Aucun commentaire:
Enregistrer un commentaire