相关疑难解决方法(0)

使用scipy curve_fit进行正确拟合,包括x中的误差?

我正在尝试使用直方图来包含一些数据scipy.optimize.curve_fit.如果我想添加一个错误y,我可以通过应用一个weight适合来做到这一点.但是如何应用错误x(即直方图中由于分箱引起的错误)?

我的问题也适用于xcurve_fit或进行线性回归时的错误polyfit; 我知道如何添加错误y,但不是x.

这里有一个例子(部分来自matplotlib文档):

import numpy as np
import pylab as P
from scipy.optimize import curve_fit

# create the data histogram
mu, sigma = 200, 25
x = mu + sigma*P.randn(10000)

# define fit function
def gauss(x, *p):
    A, mu, sigma = p
    return A*np.exp(-(x-mu)**2/(2*sigma**2))

# the histogram of the data
n, bins, patches = P.hist(x, 50, histtype='step')
sigma_n = …
Run Code Online (Sandbox Code Playgroud)

python numpy curve-fitting scipy

15
推荐指数
1
解决办法
1万
查看次数

标签 统计

curve-fitting ×1

numpy ×1

python ×1

scipy ×1