简体   繁体   English

零件的曲线拟合-lmfit Python

[英]curve fitting by parts - lmfit Python

I would like to know if in Python, and more precisely, in lmfit library, there is an option for fitting data by parts ? 我想知道在Python中,更确切地说在lmfit库中,是否有按部分拟合数据的选项? I would like to fit data defined in different ranges and then obtain a unique fit. 我想拟合在不同范围内定义的数据,然后获得唯一的拟合。

Thank you 谢谢

Without a more concrete example, it is hard to give a concrete answer. 没有更具体的例子,很难给出具体答案。 But, if I understand your question correctly, you are looking to do a fit to one specific region of your data, then a fit (probably with a different functional form) to another region of your data, and then perhaps combine the multiple regions to get a final fit. 但是,如果我正确理解了您的问题,那么您正在寻找适合数据的一个特定区域,然后适合(可能具有不同的功能形式)适合数据的另一个区域,然后可能将多个区域组合在一起最终适应。

If that is correct, then yes, this can be done with lmfit (and probably with other libraries as well). 如果那是正确的,那么可以,可以使用lmfit(也可以使用其他库)完成。 Let's say you want to fit data that is sort of peak like with an exponential decaying background. 假设您要拟合像指数衰减背景这样的峰值数据。 First, isolate a region around that peak (it doesn't have to be perfect) and fit a peak (say, Gaussian to that). 首先,隔离该峰周围的区域(不一定是完美的)并拟合一个峰(例如,对该峰进行高斯拟合)。 Then fit an exponential decay to all the data except the peak area. 然后对峰面积以外的所有数据进行指数衰减。 (Aside: numpy.where can be very useful in identifying the regions). (此外:numpy.where在识别区域时非常有用)。 Finally, combine the two and fit the whole curve to peak + background. 最后,将两者结合起来,将整个曲线拟合为峰+背景。

If that is too vague and doesn't point you in the right direction, please make the question more specific. 如果这太含糊,不能为您指明正确的方向,请使问题更具体。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM