from matplotlib import pyplot from random import random def Galton(N,L): positions=[] for n in range(N): pos=0 for l in range(L): r=random() if r>0.5: pos+=1 # la bille va a droite else: pos-=1 # sinon a gauche positions.append(pos) pyplot.hist(positions,range = (-L, L), bins = 2*L, color = 'blue',edgecolor = 'grey') pyplot.xlabel(str(N)+' billes lancées sur une planche avec '+str(L)+' lignes de clous.') pyplot.ylabel('Effectifs') pyplot.title('Planche de Galton')