-2
A
回答
2
看一看
https://docs.scipy.org/doc/scipy-0.19.0/reference/generated/scipy.optimize.curve_fit.html,
有在底部,这几乎做了你所追求的一个例子。
编辑:回复评论
import matplotlib.pyplot as plt;
import numpy as np;
import scipy.optimize as opt;
# This is the function we are trying to fit to the data.
def func(x, a, b, c):
return a * np.exp(-b * x) + c
# Generate some data, you don't have to do this, as you already have your data
xdata = np.linspace(0, 4, 50)
y = func(xdata, 2.5, 1.3, 0.5)
y_noise = 0.2 * np.random.normal(size=xdata.size)
ydata = y + y_noise
# Plot the actual data
plt.plot(xdata, ydata, ".", label="Data");
# The actual curve fitting happens here
optimizedParameters, pcov = opt.curve_fit(func, xdata, ydata);
# Use the optimized parameters to plot the best fit
plt.plot(xdata, func(xdata, *optimizedParameters), label="fit");
# Show the graph
plt.legend();
plt.show();
的X,Y数据是扩展数据和YDATA变量。所以如果你想使用这段代码,只需取出生成数据的位,并将x,y数据数组定义为“xdata”和“ydata”。
相关问题
- 1. 建议进行曲线拟合
- 2. 曲线拟合
- 3. 使用scipy在Python中进行曲线拟合
- 4. 用lsq曲线拟合加权曲线拟合
- 5. 曲线拟合scipy
- 6. scipy.optimize曲线拟合
- 7. Spotfire曲线拟合
- 8. python曲线拟合
- 9. Python曲线拟合
- 10. matplotlib散点图的回归线和拟合曲线
- 11. 拟合曲线利用NLS
- 12. 多条曲线使用Matplotlib
- 13. 使用RANSAC进行线条拟合
- 14. 曲线拟合耦合ODEs
- 15. 曲线拟合普朗克曲线
- 16. 拟合曲线,另一条曲线
- 17. 曲线中的R拟合使用NLS
- 18. 曲线拟合使用SciPy的
- 19. 使用ggplot绘制曲线拟合
- 20. 拟合曲线 - 拟合参数
- 21. 用MATLAB分段线性曲线拟合
- 22. 用误差线拟合曲线,Matlab
- 23. 曲线拟合与Python
- 24. 曲线拟合 - 建议请
- 25. 蟒蛇曲线拟合
- 26. 预测曲线拟合matlab
- 27. OpenCV中的曲线拟合
- 28. 拟合曲线与lsqcurvefit
- 29. OpenCV高斯曲线拟合
- 30. LabView中的曲线拟合
这个例子对我来说非常复杂,因为我是python中的新手。你能告诉我,如果我使用你给出的例子的代码,我应该在哪里放置我的x和y值。 –