如何将多项式拟合到带有误差线的数据 [英] How to fit polynomial to data with error bars

查看:139
本文介绍了如何将多项式拟合到带有误差线的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用numpy.polyfit(x,y,deg)将多项式拟合到实验数据.但是,我想拟合一个基于点的误差使用加权的多项式.

I am currently using numpy.polyfit(x,y,deg) to fit a polynomial to experimental data. I would however like to fit a polynomial that uses weighting based on the errors of the points.

我找到了 scipy.curve_fit 利用权重,我想我可以将函数"f"设置为所需顺序的多项式形式,然后将权重放入"sigma",这应该可以实现我的目标.

I have found scipy.curve_fit which makes use of weights and I suppose I could just set the function, 'f', to the form a polynomial of my desired order, and put my weights in 'sigma', which should achieve my goal.

我想知道还有另一种更好的方法吗?

I was wondering is there another, better way of doing this?

非常感谢.

推荐答案

看看 http://scipy-cookbook.readthedocs.io/items/FittingData.html ,尤其是.它显示了如何将scipy.optimize.leastsq与包含错误权重的函数一起使用.

Take a look at http://scipy-cookbook.readthedocs.io/items/FittingData.html in particular the section 'Fitting a power-law to data with errors'. It shows how to use scipy.optimize.leastsq with a function that includes error weighting.

这篇关于如何将多项式拟合到带有误差线的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆