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.3.0.11'
[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)
 70%|███████   | 21/30 [00:00<00:00, 73.48it/s]/__w/smpl/smpl/smpl/functions.py:111: RuntimeWarning: invalid value encountered in power
  return a * (x) ** k + y
/github/home/.cache/pypoetry/virtualenvs/smpl-4sWS420u-py3.8/lib/python3.8/site-packages/scipy/optimize/_minpack_py.py:881: OptimizeWarning: Covariance of the parameters could not be estimated
  warnings.warn('Covariance of the parameters could not be estimated',
/github/home/.cache/pypoetry/virtualenvs/smpl-4sWS420u-py3.8/lib/python3.8/site-packages/uncertainties/core.py:188: RuntimeWarning: invalid value encountered in divide
  covariance_mat/norm_vector/norm_vector[:,numpy.newaxis],
100%|██████████| 30/30 [00:01<00:00, 22.27it/s]
100%|██████████| 31/31 [00:01<00:00, 30.35it/s]
../../../_images/example_fit_auto_test_auto_2_1.png
../../../_images/example_fit_auto_test_auto_2_2.png
[ ]:

[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%|██████████| 31/31 [00:03<00:00,  9.72it/s]
../../../_images/example_fit_auto_test_auto_4_1.png
[ ]:

[ ]: