simu_bernoull.py

Created by bhenry1

Created on June 07, 2022

538 Bytes


from random import random


def epreuve_B():# un tirage
    return random() < 0.2
    
def repete_40():# 40 timbres
  compte = 0
  for i in range(40):
     compte = compte + epreuve_B()
  return compte

from matplotlib.pyplot import * # on utilise la bibliothèque matplotlib

liste = [0]*41
for i in range(10000):
     liste[repete_40()] += 1# 
for x in range(41):
    scatter(x, liste[x]/10000,color="red") # dessine le point de coordonnées x,y
axis((-2, 40, -0.05, 0.25)) # 0<x40 0<y< (20 maximum imaginé)
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.