BPoly#
- class scipy.interpolate.BPoly(c, x, extrapolate=None, axis=0)[source]#
分段多項式,以係數和斷點表示。
The polynomial between
x[i]
andx[i + 1]
is written in the Bernstein polynomial basisS = sum(c[a, i] * b(a, k; x) for a in range(k+1)),
where
k
is the degree of the polynomial, andb(a, k; x) = binom(k, a) * t**a * (1 - t)**(k - a),
with
t = (x - x[i]) / (x[i+1] - x[i])
andbinom
is the binomial coefficient.- 參數:
- cndarray,形狀 (k, m, …)
多項式係數,階數 k 和 m 個區間
- xndarray,形狀 (m+1,)
多項式斷點。必須以遞增或遞減順序排序。
- extrapolatebool,選用
如果是布林值,則決定是否基於第一個和最後一個區間外插到超出範圍的點,還是返回 NaN。如果是 ‘periodic’,則使用週期性外插。預設值為 True。
- axisint,選用
插值軸。預設值為零。
另請參閱
PPoly
幂基底中的分段多項式
註解
Bernstein 多項式的特性在文獻中已有充分記載,例如參見 [1] [2] [3]。
參考文獻
[2]Kenneth I. Joy, Bernstein 多項式, http://www.idav.ucdavis.edu/education/CAGDNotes/Bernstein-Polynomials.pdf
[3]E. H. Doha, A. H. Bhrawy 和 M. A. Saker, 邊界值問題, vol 2011, article ID 829546, DOI:10.1155/2011/829543。
範例
>>> from scipy.interpolate import BPoly >>> x = [0, 1] >>> c = [[1], [2], [3]] >>> bp = BPoly(c, x)
這會建立一個 2 階多項式
\[\begin{split}B(x) = 1 \times b_{0, 2}(x) + 2 \times b_{1, 2}(x) + 3 \times b_{2, 2}(x) \\ = 1 \times (1-x)^2 + 2 \times 2 x (1 - x) + 3 \times x^2\end{split}\]- 屬性:
- xndarray
斷點。
- cndarray
多項式的係數。它們被重塑為 3 維陣列,最後一個維度表示原始係數陣列的尾隨維度。
- axisint
插值軸。
方法
__call__
(x[, nu, extrapolate])評估分段多項式或其導數。
extend
(c, x)向多項式添加額外的斷點和係數。
derivative
([nu])建構一個新的分段多項式,表示導數。
antiderivative
([nu])建構一個新的分段多項式,表示反導數。
integrate
(a, b[, extrapolate])計算分段多項式上的定積分。
construct_fast
(c, x[, extrapolate, axis])建構分段多項式,不進行檢查。
from_power_basis
(pp[, extrapolate])從幂基底多項式建構 Bernstein 基底中的分段多項式。
from_derivatives
(xi, yi[, orders, extrapolate])在 Bernstein 基底中建構一個分段多項式,與斷點處的指定值和導數相容。