from math import*
from random import random
import matplotlib.pyplot as plt
#N = nombre de tirages
#p = probabilité de l'événement
def freq_proba(N,p):
total = 0
frequence = 0
points = []
for tirage in range(1,N+1):
if random() <= p:
total = total + 1
frequence = total/tirage
plt.plot(tirage,frequence, markeredgecolor="green", marker="o", markerfacecolor="green")
plt.ylim([0,1])
plt.show()
freq_proba(1000,0.5)
Nos manuels sont collaboratifs, n'hésitez pas à nous en faire part.
j'ai une idée !
Oups, une coquille