declic2de25p374.py

Created by gilles-dhaussy

Created on June 11, 2024

586 Bytes


from random import *
from matplotlib.pyplot import *
from time import sleep

def frequence1(n):
    L=[]
    piece=['P','F']
    for i in range(n):
        x=choice(piece)
        L.append(x)
    Nombre_de_P=L.count('P')
    return Nombre_de_P/n

def frequence2(n):
    Nombre_de_P=0
    for i in range(n):
        x=random()
        if x<0.5:
            Nombre_de_P=Nombre_de_P+1
    return Nombre_de_P/n

lx,ly=[],[]
for i in range(50):
    lx.append(i)
    ly.append(frequence2(100))
axis([0,50,0,1])
plot([0,50],[0.5,0.5])
scatter(lx,ly,color='green')
show()

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.