Automatic fit function¶
[1]:
import numpy as np
from smpl import plot
from smpl import stat
from smpl import io
from smpl import functions as f
import uncertainties.unumpy as unp
import smpl
smpl.__version__
[1]:
'1.0.1.8'
[2]:
for n in ['test_linear_data.txt', 'test_quad_data.txt']:
data = np.loadtxt(io.find_file(n,3))
xdata = data[:,0]
xerr = data[:,2]
ydata = data[:,1]
yerr = data[:,3]
x = unp.uarray(xdata,xerr)
y = unp.uarray(ydata,yerr)
function,fitparams,lfunc = plot.auto(xdata, ydata, fmt='.', label='data', xaxis="x in a.u.",yaxis="y in a.u.",sigmas=1,epsfcn=0.00001,maxfev=1000000,init=True)
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 26/26 [00:02<00:00, 8.77it/s]
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 26/26 [00:02<00:00, 12.95it/s]
[ ]:
[3]:
x= np.linspace(-5,5,100)
y = stat.noisy(np.exp(2*x))
ff = plot.auto(x, y, fmt='.', label='data', xaxis="x in a.u.",yaxis="y in a.u.",sigmas=1)
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 26/26 [00:04<00:00, 6.39it/s]
[ ]:
[ ]: