from random import choice import matplotlib.pyplot as plt import numpy as np c=31 def simulation_galton(c = 31, n = 500): base = c * [0] for bille in range(n): position = c // 2 for clou in range(c-1): position += choice([-1,1])/2 base[ int(position) ] += 1 return base x=np.arange(0,c,1) y=simulation_galton(n=500) plt.plot(x,y,'x',markersize=4) plt.show()