借助scipy.integrate.simps()
方法,我們可以使用沿軸的樣本和複合辛普森法則來獲得y(x)的積分,方法是scipy.integrate.simps()
方法。
用法: scipy.integrate.simps(y, x)
返回:Return the integrated value of y(x) using samples.
範例1:
在這個例子中,我們可以通過使用scipy.integrate.simps()
方法,我們可以使用樣本和複合辛普森規則來獲得y(x)的積分值。
# import numpy and scipy.integrate
import numpy as np
from scipy import integrate
x = np.arange(0, 10)
y = np.arange(0, 10)
# using scipy.integrate.simps() method
gfg = integrate.simps(y, x)
print(gfg)
輸出:
40.5
範例2:
# import numpy and scipy.integrate
import numpy as np
from scipy import integrate
x = np.arange(0, 10)
y = np.sqrt(x)
# using scipy.integrate.simps() method
gfg = integrate.simps(y, x)
print(gfg)
輸出:
17.875036119764566
相關用法
- Python Scipy stats.hypsecant.mean()用法及代碼示例
- Python Scipy integrate.romb()用法及代碼示例
- Python Scipy stats.hypsecant.ppf()用法及代碼示例
- Python Scipy stats.hypsecant.sf()用法及代碼示例
- Python Scipy stats.halfgennorm.ppf()用法及代碼示例
- Python Scipy stats.hypsecant.var()用法及代碼示例
- Python Scipy stats.halfgennorm.fit()用法及代碼示例
- Python Scipy stats.hypsecant.cdf()用法及代碼示例
- Python Scipy stats.invgamma.rvs()用法及代碼示例
- Python Scipy stats.halfgennorm.pdf()用法及代碼示例
- Python Scipy stats.hypsecant.rvs()用法及代碼示例
- Python Scipy stats.hypsecant.pdf()用法及代碼示例
- Python Scipy stats.halfgennorm.mean()用法及代碼示例
- Python Scipy stats.hypsecant.fit()用法及代碼示例
- Python Scipy stats.hypsecant.isf()用法及代碼示例
注:本文由純淨天空篩選整理自Jitender_1998大神的英文原創作品 Python | Scipy integrate.simps() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。