Playground
§ Tool 03 — Signal Processing

P-Spline Curvature

A penalized B-spline (P-spline) smoother for noisy signals. The same machinery that underlies inertial-measurement-unit (IMU) bend detection on long-distance pipelines: smooth the angle signal, take a derivative for curvature, and find the bends.

01

Data

Each bend is a smooth step in pitch angle modelled as an error function. The displayed curvature is the analytical derivative; the smoother is asked to recover it from the noisy angle signal alone.
02

Smoother

03

Smoothed signal

Noisy measurements (gray), penalized B-spline fit (bronze). For synthetic data, the true underlying signal is shown in black for comparison.
04

First derivative (curvature)

Closed-form analytical derivative of the B-spline fit (no numerical differentiation of noisy data). Vertical lines mark detected bends from peak-finding on the absolute curvature; for synthetic data, the true bend locations are shown for reference.
05

Second derivative

Closed-form second derivative of the B-spline fit, useful for identifying bend start / end and inflection points.
06

GCV / AIC scan

Generalized cross-validation and Akaike-information-criterion curves over a log-spaced grid of λ. The minimum is the data-driven choice used by the auto button.
07

Bend table

08

Method

The fit is a penalized B-spline (Eilers and Marx, 1996). Given noisy observations yi at locations xi, we represent the unknown function as a linear combination of M = K + p evenly-spaced B-splines of degree p: f(x) = Σ αj Bj(x). The coefficients α are found by minimizing

||y - Bα||² + λ · ||D α||²

where D is the d-th order finite-difference operator and λ ≥ 0 controls the trade-off between fidelity and smoothness. The solution is α = (BTB + λ DTD)-1 BTy and the smoothed values are ŷ = Bα.

Derivatives of the fit are obtained analytically using the B-spline derivative recursion dBi,p/dx = (p/h)(Bi,p-1 - Bi+1,p-1), which is much more reliable than finite-differencing the noisy data. The first derivative is the local curvature for an IMU pitch / yaw signal along a pipeline.

Optimal λ is chosen by Generalized Cross-Validation: GCV(λ) = (n · RSS) / (n - tr(H))², with H = B (BTB + λ DTD)-1 BT the hat matrix. AIC = n · log(RSS/n) + 2·tr(H) is shown alongside for reference.

Bend detection: peak finding on the absolute first derivative with a height threshold equal to a multiple of the residual standard deviation propagated through the derivative basis.

09

Related publications