Hey so i made an program to choose a random number betwen 1.01 and 999.99 with probabilty (1/2 * 0.98 for 2 1/3*0.98 for 3 ect) but i dont know why its seem to do around 1/10 for 2 and 15/85 for 3 anyone know why its does that an how to fix it?
proba = []
nombre = []
for numéroNombre in range (100,100000,1):
proba1 = ((1000000/numéroNombre)/10000) * 0.98
proba.append(proba1)
nombre.append(numéroNombre/100)
b = 0
c = 0
b = 0
a = [0]
for i in range(0,100):
b = a[0]
a = random.choices(nombre,weights=proba)
if int(a[0]) < int(b):
b = b + 1
else:
c = c +1
print(nombre[99],proba[99])
print("2 ou moins : " + str(b))
print("plus que 2 : " + str(c))```
Aucun commentaire:
Enregistrer un commentaire