How to propagate error when using scipy quad on a spline of data with measurement error?

你说的曾经没有我的故事 提交于 2020-06-17 09:51:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!