当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python Numpy np.laggauss()用法及代码示例


np.laggauss()计算Gauss-Laguerre正交的采样点和权重。这些采样点和权重将正确积分度的多项式2*deg - 1 在间隔内或更少[0, inf]配重函数f(x) = exp(-x)

用法: np.laggauss(deg)
参数:
deg :[int] Number of sample points and weights. It must be >= 1.

返回:1. [ndarray]包含样本点的一维ndarray。
2. [ndarray]包含权重的一维ndarray。


代码1:

# Python program explaining 
# numpy.laggauss() method  
    
# importing numpy as np   
# and numpy.polynomial.laguerre module as geek  
import numpy as np  
import numpy.polynomial.laguerre as geek 
    
# Input degree = 2 
  
degree = 2 
     
# using np.laggauss() method  
res = geek.laggauss(degree)  
  
# Resulting array of sample point and weight 
print (res) 
输出:
(array([ 0.58578644,  3.41421356]), array([ 0.85355339,  0.14644661]))

代码2:

# Python program explaining 
# numpy.laggauss() method  
    
# importing numpy as np   
# and numpy.polynomial.laguerre module as geek  
import numpy as np  
import numpy.polynomial.laguerre as geek 
    
# Input degree 
degree = 3
    
# using np.laggauss() method  
res = geek.laggauss(degree)  
  
# Resulting array of sample point and weight 
print (res) 
输出:
(array([ 0.41577456,  2.29428036,  6.28994508]), array([ 0.71109301,  0.27851773,  0.01038926]))



相关用法


注:本文由纯净天空筛选整理自jana_sayantan大神的英文原创作品 Python | Numpy np.laggauss() method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。