Skip to Content

uncertainties (3)

  1. from uncertainties import ufloat
  2. from uncertainties.umath import *
  3. Paris_Lyon = ufloat((465,10))
  4. Lyon_Nice = ufloat((479,10))
  5. Paris_Nice = Paris_Lyon + Lyon_Nice
  6. print Paris_Nice
  7. 944.0+/-14.142135623730951
  8. # résultats en tenant compte de la rêgle des chiffres significatifs
  9. print "%.f" % Pa_Nic.nominal_value,"+/-","%.f" % Pa_Nic.std_dev()
  10. 944 +/- 14
  11.  
  12. Lyon_Nice_Lyon = Lyon_Nice * 2
  13. print Lyon_Nice_Lyon
  14. 958.0+/-20.0
  15. print "%.f" % Ly_Nic_Ly.nominal_value,"+/-","%.f" % Ly_Nic_Ly.std_dev()
  16. 958 +/- 20
  17.  
  18. # si les 2 variables n'étaient pas corrélées (indépendantes)
  19. x = ufloat((479,10))
  20. y = ufloat((479,10))
  21. test = x + y
  22. print "%.f" % test.nominal_value,"+/-","%.f" % test.std_dev()
  23. 958 +/- 14