bundles / scipy 1.17.1 / scipy / signal / _savitzky_golay / savgol_coeffs
function
scipy.signal._savitzky_golay:savgol_coeffs
Signature
def savgol_coeffs ( window_length , polyorder , deriv = 0 , delta = 1.0 , pos = None , use = conv , * , xp = None , device = None ) Summary
Compute the coefficients for a 1-D Savitzky-Golay FIR filter.
Parameters
window_length: intThe length of the filter window (i.e., the number of coefficients).
polyorder: intThe order of the polynomial used to fit the samples.
polyordermust be less thanwindow_length.deriv: int, optionalThe order of the derivative to compute. This must be a nonnegative integer. The default is 0, which means to filter the data without differentiating.
delta: float, optionalThe spacing of the samples to which the filter will be applied. This is only used if deriv > 0.
pos: int or None, optionalIf pos is not None, it specifies evaluation position within the window. The default is the middle of the window.
use: str, optionalEither 'conv' or 'dot'. This argument chooses the order of the coefficients. The default is 'conv', which means that the coefficients are ordered to be used in a convolution. With use='dot', the order is reversed, so the filter is applied by dotting the coefficients with the data set.
Returns
coeffs: 1-D ndarrayThe filter coefficients.
Notes
Array API Standard Support
savgol_coeffs has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.
==================== ==================== ==================== Library CPU GPU ==================== ==================== ==================== NumPy ✅ n/a CuPy n/a ✅ PyTorch ✅ ✅ JAX ✅ ✅ Dask ✅ n/a ==================== ==================== ====================
See
dev-arrayapifor more information.
Examples
import numpy as np from scipy.signal import savgol_coeffs savgol_coeffs(5, 2)✓
savgol_coeffs(5, 2, deriv=1)
✗savgol_coeffs(5, 2, pos=3) savgol_coeffs(5, 2, pos=3, use='dot')✓
savgol_coeffs(4, 2, pos=3, deriv=1, use='dot')
✗x = np.array([1, 0, 1, 4, 9]) c = savgol_coeffs(5, 2, pos=4, deriv=1, use='dot')✓
c.dot(x)
✗See also
Aliases
-
scipy.signal.savgol_coeffs