smpl.plot.fit

smpl.plot.fit(func, *adata, **kwargs)[source]

Fit and plot function to datax and datay.

Parameters

dataxarray_like

X data either as unp.uarray or np.array or list

datayarray_like

Y data either as unp.uarray or np.array or list

functionfunc

Fit function with parameters: x, params

**kwargsoptional

see plot_kwargs().

Fit parameters can be fixed via kwargs eg. a=5.

Returns

array_like

Optimized fit parameters of function to datax and datay. If datay is complex, both the real and imaginary part are returned.

Examples

>>> from smpl import functions as f
>>> from smpl import plot
>>> param = plot.fit([0,1,2],[0,1,2],f.line)
>>> plot.unv(param).round()[0]
1.0

(Source code, png, hires.png, pdf)

../_images/smpl-plot-fit-1.png