當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python Numpy np.chebfit()用法及代碼示例

借助np.chebfit()方法,我們可以通過使用得到chebyshev級數的最小二乘擬合np.chebfit()方法。

用法: np.chebfit(x, y, degree)
返回:Return the array of chebyshev series coefficient values.

範例1:
在這個例子中,我們可以看到np.chebfit()方法,我們能夠使用此方法獲得契比雪夫係列的最小二乘擬合。


# import numpy 
import numpy as np 
import numpy.polynomial.chebyshev as cheb 
  
# using np.chebfit() method 
gfg = cheb.chebfit((4, -5), (5, 7), 1) 
  
print(gfg)

輸出:

[5.88888889, -0.22222222]

範例2:

# import numpy 
import numpy as np 
import numpy.polynomial.chebyshev as cheb 
  
# using np.chebfit() method 
gfg = cheb.chebfit((-3, 4, 10), (1, 2, 3), 3) 
  
print(gfg)

輸出:

[1.39458146e+00 1.41166773e-01 1.53673202e-03 -2.82264138e-05]



相關用法


注:本文由純淨天空篩選整理自Jitender_1998大神的英文原創作品 Python | Numpy np.chebfit() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。