Python 中的渐近回归?

Asymptotic regression in Python?

我有数据集的 this 部分,其中 y 值最终必须达到渐近极限。这是前 300 个条目的图表:

我在它的库中看到了 asymptotic regression (of the form y = b0 + b1*(1-exp(-exp(lrc) * x)) and I think it would be the best model to fit this data. R seemingly already has the function,但在 Python.

中找不到

(1) 是否有下面 Cleb 回答的渐近回归或相关饱和动力学模型的库函数?如果不是,如何使用 scipy.optimize.curve_fit?

对其进行建模

(2) 还有如何预测曲线的最大整数值?例如,如果y=2454.1234X=10**20处的值,y=2545.5678X=10**50处的值,对于某个型号,我想获得2454。除了线性搜索,还有什么一次性方法吗?

感谢您的帮助。

您可以使用 scipy's curve_fit function 轻松安装它。我使用了不同的模型,但您可以轻松更改它。

您得到的输出如下所示:

这是不言自明的代码:

import numpy as np
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
import pandas as pd


def f(x, a, b, n):
    return a * x ** n  / (x ** n + b)


data = pd.read_csv('data.txt.txt', sep='\t')

y = data['y'].astype(float)
x = data['X'].astype(float)

popt, pcov = curve_fit(f, x, y, p0=[1800., 20., 1.])

plt.scatter(x, y)
plt.plot(x, f(x, *popt), 'r-')

plt.show()