姬長信(Redy)

python – 指数曲线拟合的置信区间


我试图获得一些x,y数据的指数拟合的置信区间(可用here).这是MWE我必须找到最适合数据的指数:
from pylab import *
from scipy.optimize import curve_fit

# Read data.
x, y = np.loadtxt('exponential_data.dat', unpack=True)

def func(x, a, b, c):
    '''Exponential 3-param function.'''
    return a * np.exp(b * x) + c

# Find best fit.
popt, pcov = curve_fit(func, x, y)
print popt

# Plot data and best fit curve.
scatter(x, y)
x = linspace(11, 23, 100)
plot(x, func(x, *popt), c='r')
show()

产生:

如何使用纯python,numpy或scipy(我已安装的软件包)获得95%(或其他值)置信区间?