Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-25 02:29:52

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