[SciPy-User] How to fit data with errorbars
Tue Feb 16 14:21:36 CST 2010
On Tue, Feb 16, 2010 at 1:08 PM, Jeremy Conlin <firstname.lastname@example.org> wrote:
> I have some data with some errobars that I need to fit to a line. Is
> there anyway to use scipy.polyfit with the error associated with the
> data? If not, how can I make a fit routine work with my data?
I'm not sure what your data and your errorbars look like but I think
scipy.optimize.curve_fit might do what you want. the sigma keyword can
be used for weighted least squares fitting. You would have to specify
your own fitting function, e.g. a polynomial on np.linspace and e.g.
>>> from scipy import optimize
Help on function curve_fit in module scipy.optimize.minpack:
curve_fit(f, xdata, ydata, p0=None, sigma=None, **kw)
Use non-linear least squares to fit a function, f, to data.
Assumes ``ydata = f(xdata, *params) + eps``
sigma : None or N-length sequence
If not None, it represents the standard-deviation of ydata.
This vector, if given, will be used as weights in the
> SciPy-User mailing list
More information about the SciPy-User