我想用数据集优化剂量-反应曲线(4参数logistic)。我需要使用鲍威尔算法,因此,我必须使用优化.最小化()代替曲线拟合或最小二乘法。 我编写了以下代码:
import numpy as np
from scipy.optimize import minimize
ydata = np.array([0.1879, 0.4257, 0.80975, 1.3038, 1.64305, 1.94055, 2.21605, 2.3917])
xdata = np.array([40, 100, 250, 400, 600, 800, 1150, 1400])
initParams = [2.4, 0.2, 600.0, 1.0]
def logistic(params):
A = params[0]
B = params[1]
C = params[2]
D = params[3]
logistic4 = ((A-D)/(1.0+((xdata/C)**B))) + D
sse = np.sum(np.square(ydata-logistic4))
print sse
results = minimize(logistic, initParams, method='Powell')
print results
从理论上讲,这使实验和理论数据集的sse最小化,迭代最初使用Powell算法输入的4个参数。 实际上,它不起作用:它开始了,在一个相当长的列表中,最后一个错误是
TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'.
你知道怎么编码吗?你知道吗
这是一个用于数据和方程的图形化Python解算器,它使用带“Powell”的minimize(),还有一个注释掉的对curve\u fit的调用。我无法很好地拟合您提供的初始参数估计值,因此这里对这些参数进行了注释,并用我自己的值替换。我的方程搜索证实了这是一个很好的方程,用于建模这个数据集。你知道吗
相关问题 更多 >
编程相关推荐