ehrenfest.py

Created by alain-busser

Created on April 26, 2018

266 Bytes

Les urnes des époux Ehrenfest.Les fréquences des 1280 premiers tirages sont affichés, et on constate que les fluctuations autour de la fréquence “limite” de 50% ne se stabilisent jamais vraiment. Chaque appel à la fonction urnes() refait un dessin, ce qui fait que pour avoir 8 courbes superposées il suffit de faire for k in range(8): urnes()


from kandinsky import *
from random import *
def urnes():
  for x in range(320):
    set_pixel(x,100,color(0,0,255))
  urne=[0]*200
  for x in range(1280):
    n=randrange(200)
    urne[n]=1-urne[n]
    set_pixel(x//4,200-urne.count(1),color(0,0,0))

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.