Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:58:28

0001 #!/usr/bin/env python3
0002 
0003 #example taken from https://pypi.python.org/pypi/uncertainties/3.0.1
0004 from __future__ import print_function
0005 from uncertainties import ufloat
0006 x = ufloat(2, 0.25)
0007 print(x)
0008 square = x**2  # Transparent calculations
0009 print(square)
0010 print(square.nominal_value)
0011 print(square.std_dev)  # Standard deviation
0012 print(square - x*x)
0013 from uncertainties.umath import *  # sin(), etc.
0014 print(sin(1+x**2))
0015 print((2*x+1000).derivatives[x])  # Automatic calculation of derivatives
0016 from uncertainties import unumpy  # Array manipulation
0017 random_vars = unumpy.uarray([1, 2], [0.1, 0.2])
0018 print(random_vars)
0019 print(random_vars.mean())
0020 print(unumpy.cos(random_vars))