np.leggauss()
計算Gauss-legendre正交的采樣點和權重。這些采樣點和權重將正確積分度的多項式2*deg - 1
在間隔內或更少[-1, 1]
配重函數f(x) = 1
用法:np.leggauss(deg)
參數:
deg :[int] Number of sample points and weights. It must be >= 1.
返回:1. [ndarray]包含樣本點的一維ndarray。
2. [ndarray]包含權重的一維ndarray。
代碼1:
# Python program explaining
# numpy.leggauss() method
# importing numpy as np
# and numpy.polynomial.legendre module as geek
import numpy as np
import numpy.polynomial.legendre as geek
# Input degree = 2
degree = 2
# using np.leggauss() method
res = geek.leggauss(degree)
# Resulting array of sample point and weight
print (res)
輸出:
(array([-0.57735027, 0.57735027]), array([ 1., 1.]))
代碼2:
# Python program explaining
# numpy.leggauss() method
# importing numpy as np
# and numpy.polynomial.legendre module as geek
import numpy as np
import numpy.polynomial.legendre as geek
# Input degree
degree = 3
# using np.leggauss() method
res = geek.leggauss(degree)
# Resulting array of sample point and weight
print (res)
輸出:
(array([-0.77459667, 0., 0.77459667]), array([ 0.55555556, 0.88888889, 0.55555556]))
相關用法
- Python Numpy np.fft()用法及代碼示例
- Python numpy.ma.ids()用法及代碼示例
- Python Numpy np.hermeroots()用法及代碼示例
- Python Numpy np.lagvander()用法及代碼示例
- Python Numpy np.lagadd()用法及代碼示例
- Python Numpy np.lagdiv()用法及代碼示例
- Python Numpy np.lagsub()用法及代碼示例
- Python Numpy np.lagmul()用法及代碼示例
- Python Numpy np.hermegrid2d()用法及代碼示例
- Python Numpy np.lagone()用法及代碼示例
- Python Numpy np.lagzero()用法及代碼示例
- Python Numpy np.lagcompanion()用法及代碼示例
- Python Numpy np.lag2poly()用法及代碼示例
- Python Numpy np.hermegrid3d()用法及代碼示例
- Python Numpy np.hermefromroots()用法及代碼示例
注:本文由純淨天空篩選整理自jana_sayantan大神的英文原創作品 Python | Numpy np.leggauss() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。