Skip to content
Snippets Groups Projects
Select Git revision
  • 5cba93d25eb47a677c14a56ef90a1e6176d544c2
  • master default protected
2 results

tirage-gaussienne.py

Blame
  • tirage-gaussienne.py 557 B
    from math import *
    from random import *
    
    def tirage_gauss_centre_reduit():
        x=uniform(0,1)
        y=sqrt(-2*log(uniform(0,1)))
        y = y*cos(x*2*pi)
        return y 
     
    try :
      n=int(input("combien de valeurs : "))
      for i in range(n) :
        print("Le tirage : ", tirage_gauss_centre_reduit())
    except ValueError as err :
      print("Error: {0}".format(err))    
    
    """ TRACE :
    combien de valeurs : 5
    Le tirage :  0.1675459650607427
    Le tirage :  -0.8810297798592189
    Le tirage :  0.4764601603767129
    Le tirage :  -1.8446292482050937
    Le tirage :  -0.35483078367598453
    """