# import the toolbox and call it B import LT.box as B import numpy as np x = np.array([ 0. , 0.62831853, 1.25663706, 1.88495559, 2.51327412, 3.14159265, 3.76991118, 4.39822972, 5.02654825, 5.65486678, 6.28318531]) yexp = np.array([ 0.57344385, 0.46120388, -0.00214848, -0.17668092, -0.01647612, 0.0076221 , 0.00437011, -0.13967365, 0.01691304, 0.35493354, 0.53339805]) sigma = np.array([ 0.05458054, 0.04165251, 0.04823802, 0.05061557, 0.05109571, 0.04412829, 0.045951 , 0.04180152, 0.04169562, 0.05209264, 0.04291919]) B.plot_exp(x, yexp, sigma, x_label = 'Theta (rad)', y_label = 'U (arb.units)', plot_title='A fictious experiment'); B.pl.show() # plot the data # define the fitting functions f0 = lambda x:1 f1 = lambda x:np.cos(x) f2 = lambda x:np.cos(2.*x) # do the fit fit = B.gen_linfit( [f0, f1, f2], x, yexp, yerr = sigma) # plot the result B.plot_line(fit.xpl, fit.ypl); B.pl.show()