本文簡要介紹 python 語言中 scipy.interpolate.pchip_interpolate
的用法。
用法:
scipy.interpolate.pchip_interpolate(xi, yi, x, der=0, axis=0)#
pchip插值的便利函數。
xi 和 yi 是用於逼近某個函數 f 的值數組,其中
yi = f(xi)
。插值器使用單調三次樣條來找到新點 x 的值和那裏的導數。有關詳細信息,請參閱
scipy.interpolate.PchipInterpolator
。- xi: array_like
x 坐標的排序列表,長度為 N。
- yi: array_like
一維實數值數組。 yi 沿插值軸的長度必須等於 xi 的長度。如果N-D數組,使用軸參數選擇正確的軸。
- x: 標量或類似數組
長度為 M。
- der: int 或列表,可選
要提取的衍生物。可以包含 0 次導數以返回函數值。
- axis: 整數,可選
yi 數組中對應於 x 坐標值的軸。
- y: 標量或類似數組
長度 R 或長度 M 或 M by R 的結果。
參數 ::
返回 ::
例子:
我們可以使用 pchip 插值對 2D 觀測數據進行插值:
>>> import numpy as np >>> import matplotlib.pyplot as plt >>> from scipy.interpolate import pchip_interpolate >>> x_observed = np.linspace(0.0, 10.0, 11) >>> y_observed = np.sin(x_observed) >>> x = np.linspace(min(x_observed), max(x_observed), num=100) >>> y = pchip_interpolate(x_observed, y_observed, x) >>> plt.plot(x_observed, y_observed, "o", label="observation") >>> plt.plot(x, y, label="pchip interpolation") >>> plt.legend() >>> plt.show()
相關用法
- Python SciPy interpolate.pade用法及代碼示例
- Python SciPy interpolate.make_interp_spline用法及代碼示例
- Python SciPy interpolate.krogh_interpolate用法及代碼示例
- Python SciPy interpolate.InterpolatedUnivariateSpline用法及代碼示例
- Python SciPy interpolate.BSpline用法及代碼示例
- Python SciPy interpolate.LSQSphereBivariateSpline用法及代碼示例
- Python SciPy interpolate.griddata用法及代碼示例
- Python SciPy interpolate.splder用法及代碼示例
- Python SciPy interpolate.LinearNDInterpolator用法及代碼示例
- Python SciPy interpolate.PPoly用法及代碼示例
- Python SciPy interpolate.NdBSpline用法及代碼示例
- Python SciPy interpolate.barycentric_interpolate用法及代碼示例
- Python SciPy interpolate.RegularGridInterpolator用法及代碼示例
- Python SciPy interpolate.NdPPoly用法及代碼示例
- Python SciPy interpolate.interp2d用法及代碼示例
- Python SciPy interpolate.approximate_taylor_polynomial用法及代碼示例
- Python SciPy interpolate.RectSphereBivariateSpline用法及代碼示例
- Python SciPy interpolate.sproot用法及代碼示例
- Python SciPy interpolate.splantider用法及代碼示例
- Python SciPy interpolate.CloughTocher2DInterpolator用法及代碼示例
- Python SciPy interpolate.interp1d用法及代碼示例
- Python SciPy interpolate.BPoly用法及代碼示例
- Python SciPy interpolate.BarycentricInterpolator用法及代碼示例
- Python SciPy interpolate.splrep用法及代碼示例
- Python SciPy interpolate.make_smoothing_spline用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.interpolate.pchip_interpolate。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。