繁体   English   中英

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

[英]Python: Simpson's rule, negative answer for positive area under the curve?

我有

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]

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

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

  print b

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

x在减小,因此您是从右到左进行积分。 这会翻转结果的迹象。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM