本文簡要介紹 python 語言中 scipy.interpolate.BSpline.basis_element
的用法。
用法:
classmethod BSpline.basis_element(t, extrapolate=True)#
返回 B-spline 基礎元素
B(x | t[0], ..., t[k+1])
。- t: ndarray, 形狀 (k+2,)
內部結
- extrapolate: bool 或 ‘periodic’,可選
是推斷超出基本區間
t[0] .. t[k+1]
還是返回 nans。如果‘periodic’,使用周期性外推。默認為真。
- basis_element: 可調用的
代表節點向量 t 的 B-spline 基元素的可調用對象。
參數 ::
返回 ::
注意:
B-spline 的度數,k, 由長度推斷t作為
len(t)-2
.節點向量是通過 appending 和 prepend 構造的k+1
內部結的元素t.例子:
構造一個立方B-spline:
>>> import numpy as np >>> from scipy.interpolate import BSpline >>> b = BSpline.basis_element([0, 1, 2, 3, 4]) >>> k = b.k >>> b.t[k:-k] array([ 0., 1., 2., 3., 4.]) >>> k 3
在
[0, 1, 1, 2]
上構造一個二次 B-spline,並與其顯式形式進行比較:>>> t = [0, 1, 1, 2] >>> b = BSpline.basis_element(t) >>> def f(x): ... return np.where(x < 1, x*x, (2. - x)**2)
>>> import matplotlib.pyplot as plt >>> fig, ax = plt.subplots() >>> x = np.linspace(0, 2, 51) >>> ax.plot(x, b(x), 'g', lw=3) >>> ax.plot(x, f(x), 'r', lw=8, alpha=0.4) >>> ax.grid(True) >>> plt.show()
相關用法
- Python SciPy BSpline.integrate用法及代碼示例
- Python SciPy BSpline.design_matrix用法及代碼示例
- Python SciPy BivariateSpline.ev用法及代碼示例
- Python SciPy BPoly.from_derivatives用法及代碼示例
- Python SciPy Bounds.residual用法及代碼示例
- Python SciPy BivariateSpline.__call__用法及代碼示例
- Python SciPy BinomTestResult.proportion_ci用法及代碼示例
- Python SciPy BarycentricInterpolator.derivatives用法及代碼示例
- Python SciPy interpolate.make_interp_spline用法及代碼示例
- Python SciPy stats.anderson用法及代碼示例
- Python SciPy ClusterNode.pre_order用法及代碼示例
- Python SciPy stats.iqr用法及代碼示例
- Python SciPy FortranFile.read_record用法及代碼示例
- Python SciPy ndimage.correlate用法及代碼示例
- Python SciPy special.exp1用法及代碼示例
- Python SciPy special.expn用法及代碼示例
- Python SciPy signal.czt_points用法及代碼示例
- Python SciPy interpolate.krogh_interpolate用法及代碼示例
- Python SciPy ndimage.morphological_gradient用法及代碼示例
- Python SciPy distance.sokalmichener用法及代碼示例
- Python SciPy linalg.eigvalsh_tridiagonal用法及代碼示例
- Python SciPy linalg.cdf2rdf用法及代碼示例
- Python SciPy csc_array.diagonal用法及代碼示例
- Python SciPy fft.idctn用法及代碼示例
- Python SciPy linalg.LaplacianNd用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.interpolate.BSpline.basis_element。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。