首页 > 解决方案 > 在具有测量误差的样条数据上使用 scipy quad 时如何传播误差?

问题描述

我有一个包含 N 个点的数据集,我将其拟合为样条曲线并使用 scipy.integrate.quad 进行积分。我想使用 N 个相关的测量误差对最终的积分值进行误差估计。

我最初尝试使用不确定性包,但 x+/-stddev 对象不适用于 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)

有什么想法吗?

标签: scipysplinequaduncertainty

解决方案


合成数据集。您的数据点有错误。现在生成 1000 个数据集,每个点取自以测量点为中心的正态分布,此时的标准偏差由错误给出。拟合每个数据集。整合。重复。现在你有 1000 个积分值。计算这些值的均值和标准差。


推荐阅读