scipy 拟合中的极限指数值

Limit index values in scipy fitting

我正在尝试拟合以下数据

tau = [0.0001, 0.0004, 0.0006, 0.0008, 0.001, 0.0015, 0.002, 0.004, 0.006, 0.008, 0.01, 0.05, 0.1, 0.2, 0.5, 0.6, 0.8, 1.0, 1.5, 2.0, 4.0, 6.0, 8.0, 10.0]
tet = [1.000000000, 0.993790739, 0.965602604, 0.924802378, 0.88010508, 0.778684048, 0.702773729, 0.569882533, 0.544103907, 0.54709633, 0.547347558, 0.543859156, 0.504348651, 0.691909732, 0.351717086, 0.405861814, 0.340536768, 0.301032851, 0.192656835, 0.188915355, 0.100207658, 0.059809495, 0.035968302, 0.024147687]

使用通式求和

f(x) = $\sum_{i=1}^{n} a_i* exp^{-x/ti}$

我是单独做的,我确定我可以使用一个函数或类似的东西来做,但我不知道该怎么做。就这样吧

def fitfunc_1(x, a, t1):
  return a * np.exp(- x / t1)

popt_tet_1, pcov = curve_fit(fitfunc_1, data['tau'], data['tet'], maxfev=10000, bounds = (0.0, np.inf))

def fitfunc_2(x, a, t1, b, t2):
  return a * np.exp(- x / t1) + b * np.exp(- x / t2)

popt_tet_2, pcov = curve_fit(fitfunc_2, data['tau'], data['tet'], maxfev=10000, bounds = (0.0, np.inf))

def fitfunc_3(x, a, t1, b, t2, c, t3):
  return a * np.exp(- x / t1) + b * np.exp(- x / t2) + c * np.exp(- x / t3)

popt_tet_3, pcov = curve_fit(fitfunc_3, data['tau'], data['tet'], maxfev=10000, bounds = (0.0, np.inf))

但是,我需要确保a_i个索引a,b,c的总和在1左右。意思是a~1,a+b~1,a+b+c~ 1

有没有办法这样限制scipy的拟合函数?

对不起,我想这个菜鸟问题

我尝试将您的数据拟合为两个指数之和以及三个指数之和。在这两种情况下,拟合仅在范围的一部分上是正确的,而在整个范围内都不正确。在横坐标轴上以对数刻度绘制实验点的难度可以理解。

模式的形状看起来更像是逻辑函数之和,而不是指数函数之和。

这表明和的每一项都可能采用这种形式:

因此要安装的整个函数是:

注意:以上是初步研究,目的是寻找一种方便的函数进行拟合。上述参数数值只是经验上的近似值。由于使用迭代微积分的非线性回归,为了更好地拟合,仍然需要计算参数。启动迭代过程的初始值可以是上述参数值。