我使用实验数据进行理论分析的代码如下。我试图拟合曲线并推断S_u0值以确定初始温度。
mem = {}
def combos(target, n):
k = (target, n)
if k in mem:
return mem[k]
if n == 1:
return [[target]]
cs = []
for i in range(0, target+1):
cs += [[i]+c for c in combos(target-i, n-1)]
mem[k] = cs
return cs
在绘图之后,我获得了图1,但我想得到如图2所示的情节。请问如何得到如图2所示的图。提前感谢。
图2
答案 0 :(得分:0)
如果我理解了这个问题,那么您希望将模型的预测值绘制在拟合范围之外。
n
和m
数组的范围有限(至少与其他数据相比)
result = model.fit(m, params, n=n)
plt.plot(n, result.best_fit, 'b*-', label='Fit')
仅在您用于拟合的有限范围内绘制。
您可以使用一组参数(您可能想要最合适的参数)和独立变量n
的任何值来评估模型
与result.eval()
:
new_m = result.eval(result.params, n=new_n)
看起来你想要的东西可能就像
new_n = np.linspace(0, 5, 51)[1:] # to avoid 0, where your model fails
plt.plot(new_n, result.eval(result.params, n=new_n), label='Predicted')