我正在尝试找到最适合以下类型的四参数累积 Weibull 拟合:
f(x) = A*(1-exp(-((x-xo)/W)^s)
在 scipy.optimize 中使用 curve_fit 如下:
import numpy as np
import pandas as pd
import matplotlib.pylab as plt
from scipy.optimize import curve_fit
def weib(x, *p):
XSsat, Lo, W, s = p
return XSsat*(1-np.exp(-((x-Lo)/W)**s))
x_data = [10.1, 11.7, 14.3, 20.2, 32.1, 37.1, 45.5, 64.2]
y_data = [2.96e-6, 2.58e-5, 1.72e-4, 1.18e-3, 2.27e-2, 3.26e-2, 3.98e-2, 4.67e-2]
p0 = [5e-2, 0, 35, 3]
coeff, pcov = curve_fit(weib, x_data, y_data, p0=p0)
但是,我得到的输出是:
print coeff
[ nan nan nan nan]
该问题似乎与未为 x 定义函数这一事实有关
有任何想法吗?