【问题标题】:Area under the curve using idl使用 idl 的曲线下面积
【发布时间】:2018-06-22 06:01:01
【问题描述】:

我在 dff(x 轴) 和 dc(y 轴) 之间有一条曲线,我使用 IN_TABULATED 函数计算了曲线下的面积。

X=[-0.00205553,-0.00186668,-0.00167783,-0.00148899,-0.00130014,-0.00111129,-0.000922443,-0.000733597,-0.000450326,-0.000261480,0.000116216,0.000399487,  0.000588333,0.000777179,0.000966027,0.00115488,0.00134372,0.00153257,0.00172141,0.00181584,0.00200468]
F=[0.00000,21.0000,26.0000,57.0000,94.0000,148.000,248.000,270.000,388.000,418.000,379.000,404.000,358.000,257.000,183.000,132.000,81.0000,47.0000,23.0000,17.0000,431.000]
A=INT_TABULATED(X,F)
print, A

现在,我需要从 n,0(从右到左)开始循环并计算 A1,即 A 的 0.01 并停在那里,然后打印代表 A1 面积的 dff 值。我怎样才能做到这一点?任何建议都会有所帮助。

【问题讨论】:

    标签: idl-programming-language


    【解决方案1】:

    我不确定我是否完全理解这个问题,所以让我先说明我的解释。您有一条与 A 积分的曲线。从右侧开始,您需要包含 A 的 0.01 的 X 值(我们称之为 X1)(曲线下的总面积)。换句话说,曲线下总面积的 0.99FX1 的左侧,而 0.01 的面积在右侧。

    假设这个解释是正确的,这里有一个解决方案: 首先,循环遍历数据,计算从0到每个点的积分。

    npoints = n_elements(x)
    
    ; Initialize a vector to hold integration results 
    area_cumulative = [] 
    
    ; Loop through each data point, calculating integrals from 0 to that point
    for index = 0, npoints-1 do begin
    
        ; Assume area under first point is zero, otherwise, calculate integral
        if index eq 0 then area_up_to_point = 0d0 $
          else area_up_to_point = int_tabulated(x[0:index], f[0:index])
    
        ; Store integral value in the cumulative vector
            area_cumulative = [area_cumulative, area_up_to_point]
    
    endfor
    

    然后,你可以插值找到X1

    ;;; Find where cumulative distribution reaches 0.99 of A
    
    a1 = 0.99 * a
    
    x1 = interpol(x, area_cumulative, a1)
    

    这是一个插图。上图是您的数据,下图是累积面积(从 x[0] 到 x 的积分)。红色虚线显示X1 = 0.001952。灰色阴影区域占总面积的 0.01。

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-28
      • 1970-01-01
      • 1970-01-01
      • 2011-06-24
      • 1970-01-01
      • 2020-03-30
      相关资源
      最近更新 更多