c语言 拟合指数函数的代码,如何找到拟合指数函数的x?

fp.append(np.polyfit(train_x, train_y, 2))

f.append(np.poly1d(fp))

print(np.poly1d(fp))

threshold = fsolve(f, 50)

上述代码成功找到y = 50的x值。但是当我试图对拟合的指数函数做同样的事情时,我无法理解如何做到这一点。如何找到拟合指数函数的x?

def f_exp(x, a, b, c):

y = a * np.exp(-b * x) + c

return y

popt, pcov = curve_fit(f_exp, train_x, train_y)

print(popt)

threshold = fsolve(f_exp, 50) fails with :TypeError: f_exp() missing 3 required positional arguments: 'a', 'b', and 'c'

如果我添加* POPT然后我得到

threshold = fsolve(f_exp(*popt), 50) fails with: TypeError: f_exp() missing 1 required positional argument: 'c'

我认为我需要补充的x值,但它是我试图找到...无论如何价值,增加了一些价值代替X,导致另一个错误:

threshold = fsolve(f_exp(1, *popt), 50) fails with: TypeError: 'numpy.float64' object is not callable

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值