[英]Difference(s) between scipy.stats.linregress, numpy.polynomial.polynomial.polyfit and statsmodels.api.OLS
[英]Difference between Chebyshev polynomial implementation in scipy and numpy
任何人都可以告訴我切比雪夫在numpy-之間的區別
numpy.polynomial.Chebyshev.basis(deg)
和切比雪夫的scipy解釋 -
scipy.special.chebyt(deg)
這將是非常有幫助的。 提前致謝!
scipy.special
多項式函數使用np.poly1d
, 它過時且容易出錯 - 特別是,它將x0
的索引存儲在poly.coeffs[-1]
numpy.polynomial.Chebyshev
不僅以更合理的順序存儲系數,而且根據它們的基礎保存它們,這提高了精度。 您可以使用cast
轉換方法進行轉換:
>>> from numpy.polynomial import Chebyshev, Polynomial
# note loss of precision
>>> sc_che = scipy.special.chebyt(4); sc_che
poly1d([ 8.000000e+00, 0.000000e+00, -8.000000e+00, 8.881784e-16, 1.000000e+00])
# using the numpy functions - note that the result is just in terms of basis 4
>>> np_che = Chebyshev.basis(4); np_che
Chebyshev([ 0., 0., 0., 0., 1.], [-1., 1.], [-1., 1.])
# converting to a standard polynomial - note that these store the
# coefficient of x^i in .coeffs[i] - so are reversed when compared to above
>>> Polynomial.cast(np_che)
Polynomial([ 1., 0., -8., 0., 8.], [-1., 1.], [-1., 1.])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.