不均匀间隔的数值积分,Python

时间:2015-07-08 14:38:19

标签: python scipy numerical-integration simpsons-rule

我想对一组给定的样本进行数值积分。

假设我有 x不均匀的区域 ,而y = f(x)是我要整合的功能。

    x       y=f(x)
   0.1      10.5
   1.2      2.0
   3.7      11.0
   7.0      4.0

现在可以这样使用Simpon's rule from scipy.integrate吗?

from scipy.integrate import simps

I = simps(y,x)

即使我的x值不均匀?

1 个答案:

答案 0 :(得分:1)

对于数值积分,一旦我们得到x和函数y=f(x)的值,就可以执行上述过程。

也可以使用numpy中的梯形规则,如:

result = np.trapz(y,x)
相关问题