paquet_lune.py

Created by bhenry1

Created on October 14, 2020

845 Bytes


from random import random  # On importe la fonction random() de la bibliothèque random

def lot():
  legend = 0
  for i in range (40):
    if random()<0.3:
      legend = legend + 1
  return legend
  
import matplotlib.pyplot as plt  # On importe le traitement grahique pyplot depuis la bibliothèque matplotlib

def fluct():
    """représente les fréquences de 100 échantillons de 40 tirages de carte avec une probabilité de 30 %"""
    x=[]
    y=[]
    for i in range(100):  # On veut 100 échantillons
        x.append(i)
        y.append(lot()/40) # On va travailler en fréquence
    plt.scatter(x, y)  # représente le point de coordonnées (i, freq) en bleu(b)
    plt.axis([0,100,0,1]) # Définition des axes
    plt.grid(True)        # On active le quadrillage du repère
    plt.show()  # affichage du dessin.

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.