标签: simpsons-rule

辛普森规则整合负面领域

simpson's rulescipy.integrate库中使用时出现问题。即使所有数字均为正且x轴上的值从左向右递增,有时计算得出的面积也为负。例如:

from scipy.integrate import simps

x = [0.0, 99.0, 100.0, 299.0, 400.0, 600.0, 1700.0, 3299.0, 3300.0, 3399.0, 3400.0, 3599.0, 3699.0, 3900.0,
    4000.0, 4300.0, 4400.0, 4900.0, 5000.0, 5100.0, 5300.0, 5500.0, 5700.0, 5900.0, 6100.0, 6300.0, 6600.0,
    6900.0, 7200.0, 7600.0, 7799.0, 8000.0, 8400.0, 8900.0, 9400.0, 10000.0, 10600.0, 11300.0, 11699.0,
    11700.0, 11799.0]

y = [3399.68, 3399.68, 3309.76, 3309.76, 3274.95, 3234.34, 3203.88, 3203.88, 3843.5,
     3843.5,  4893.57, 4893.57, 4893.57, 4847.16, 4764.49, 4867.46, 4921.13, 4886.32,
     4761.59, 4731.13, 4689.07, 4649.91, 4610.75, 4578.84, 4545.48, 4515.02, …
Run Code Online (Sandbox Code Playgroud)

python integral scipy simpsons-rule

6
推荐指数
1
解决办法
128
查看次数

Python:Simpson法则,曲线下正面积的否定答案?

我有

y1=[  9.49110000e-004   4.74145420e-004   1.41847155e-008   3.33228420e-028
       3.76352289e-081   4.48206815e-193   0.00000000e+000   0.00000000e+000
       0.00000000e+000   0.00000000e+000   0.00000000e+000] 

x=[ 112.  111.97667396  111.90666665  111.78989038  111.62619837  
     111.41538384  111.15717866  110.85125168  110.49720654  110.09457901
    109.64283388]
Run Code Online (Sandbox Code Playgroud)

所有y值均为正,因此曲线下的面积应为正。但是当我尝试使用辛普森规则进行整合时

  from scipy.integrate import simps
  b= simps(y1, x)

  print b
Run Code Online (Sandbox Code Playgroud)

我得到-2.45630795891e-05答案。我究竟做错了什么?

python integrate scipy simpsons-rule

3
推荐指数
1
解决办法
1124
查看次数

标签 统计

python ×2

scipy ×2

simpsons-rule ×2

integral ×1

integrate ×1