问题
I have a data set with N points which I fit a spline to and integrate using scipy.integrate.quad. I would like to use the N associated measurement errors to put an error estimate on the final integral value.
I originally tried to use the uncertainties package but the x+/-stddev objects did not work with scipy.
def integrand(w_point, x, y):
#call spline function to get data arbitrary points
f_i = spline_flux_full(x, y, w_point)
#use spline for normalizing data at arbitrary points
f_i_continuum = coef_continuum(w_point)
#this is the integrand evaluated at w_point
W_i = 1.-(f_i/f_i_continuum)
return(W_i)
Have any ideas?
回答1:
Synthetic datasets. You have your data points with errors. Now generate 1000 datasets with each point drawn from a normal distribution centered around the measured point and standard deviation given by an errror at this point. Fit each dataset. Integrate. Repeat. Now you have 1000 values of the integral. Compute the mean and std dev of these values.
来源:https://stackoverflow.com/questions/50072466/how-to-propagate-error-when-using-scipy-quad-on-a-spline-of-data-with-measuremen