Auto Fit
[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
[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)
function: None
100%|██████████████████████████████████████████████| 25/25 [00:02<00:00, 9.40it/s]
function: None
100%|██████████████████████████████████████████████| 25/25 [00:01<00:00, 13.26it/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)
function: None
0%| | 0/25 [00:00<?, ?it/s]/usr/lib/python3.9/site-packages/uncertainties/core.py:171: RuntimeWarning: invalid value encountered in sqrt
std_devs = numpy.sqrt(numpy.diag(covariance_mat))
100%|██████████████████████████████████████████████| 25/25 [00:00<00:00, 99.05it/s]
[ ]:
[ ]:
[ ]:
[ ]:
[ ]:
[ ]:
[ ]:
[ ]: