This is a pre-release version (2.0.0.dev0+git20260907.41eeb59).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / signal / _spline_filters / cspline1d

function

scipy.signal._spline_filters:cspline1d

source: build-install/usr/lib/python3.14/site-packages/scipy/signal/_spline_filters.py:306

Signature

def cspline1d(signal, lamb = 0.0)

Summary

Compute cubic spline coefficients for rank-1 array.

Extended Summary

Find the cubic spline coefficients for a 1-D signal assuming mirror-symmetric boundary conditions. To obtain the signal back from the spline representation mirror-symmetric-convolve these coefficients with a length 3 FIR window [1.0, 4.0, 1.0]/ 6.0 .

Parameters

signal : ndarray

A rank-1 array representing samples of a signal.

lamb : float, optional

Smoothing coefficient, default is 0.0.

Returns

c : ndarray

Cubic spline coefficients.

Examples

We can filter a signal to reduce and smooth out high-frequency noise with a cubic spline:
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import cspline1d, cspline1d_eval
rng = np.random.default_rng()
sig = np.repeat([0., 1., 0.], 100)
sig += rng.standard_normal(len(sig))*0.05  # add noise
time = np.linspace(0, len(sig))
filtered = cspline1d_eval(cspline1d(sig), time)
✓
plt.plot(sig, label="signal")
plt.plot(time, filtered, label="filtered")
plt.legend()
✗
<matplotlib.legend.Legend object at 0x7f3f6858ae40>
plt.show()
✓
fig-5dc2ae6b518ae784.png

See also

cspline1d_eval

Evaluate a cubic spline at the new set of points.

Aliases

  • scipy.signal.cspline1d