Gaplad › Free tools & guides › Linear vs spline interpolation

Live demo · runs in your browser

Linear, spline or PCHIP? Watch them fill the same gap.

Every interpolation method looks convincing on a chart. The only fair question is how close it gets to what really happened. Here the truth is known: pick a signal and a gap length, and the gap is carved out of real-looking data, filled blind by four methods and scored.

Method (best first)RMSEMean abs. errorWorst error

One gap proves nothing. Test a few hundred.

Any method can win one gap by luck. The honest test carves up to 40 gaps of each length out of stretches where the truth was observed, fills each blind with every method and averages the error. This is the synthetic-gap validation Gaplad runs on your own data.

The four methods

Linear interpolation

A straight line from the last reading before the gap to the first reading after it. It cannot overshoot and it has nothing to tune. Its weakness is anything that happened inside the gap: a missing afternoon becomes a flat line through the daily peak.

Cubic spline

A smooth curve through the 4 readings either side of the gap (a natural cubic spline). It follows curvature that linear misses, but it is free to swing beyond the data: next to a sudden rise it overshoots, and across a long gap it can wander far from anything plausible.

PCHIP

A shape-preserving cubic: smooth like a spline, but its slopes are chosen so that it never goes above or below its neighbouring readings where the data are monotone. It is the safe smooth option for short gaps.

Daily profile

The average value at the same time of day over the nearest days, shifted so it meets the readings at both ends of the gap. It keeps the shape of the daily cycle that every interpolation erases, which is why it usually wins for temperature or radiation gaps of a day or more. It still cannot know the weather of the missing day.

What the honest test usually shows

That pattern is the reason Gaplad does not pick a method for you in advance. It validates on your record, per gap length, and uses a model trained on your other sensors where that beats interpolation, and interpolation where it does not.

Questions

Is linear or spline interpolation better for filling gaps in time series?

For short gaps, usually linear. Across thousands of synthetic gaps in sensor records, a straight line between the two bracketing readings is hard to beat for gaps of a few hours, and it never invents a bump. Cubic splines look smoother but can overshoot, especially next to a sudden change. For gaps longer than the signal's natural cycle, neither works; you need a second sensor or a model.

What is PCHIP and why would I use it?

Piecewise cubic Hermite interpolation with slopes chosen so the curve never overshoots its data (Fritsch-Carlson). It is smooth like a spline but behaves like linear interpolation next to steps and peaks. A good choice when you want a smooth curve over short gaps without inventing extremes.

How do I know which method is honest for my data?

Test it. Carve gaps of the length you need to fill out of stretches where you do have data, fill them blind, and compare with what was really there. That is what the honest test button on this page does, and what Gaplad does on your own file, per gap length, before it fills anything.

Why does every method fail on a storm?

Because the storm is not in the data around the gap. Interpolation only knows the readings at the edges. Reconstructing a flood peak needs a related series that saw it (rainfall, an upstream gauge) and a model trained on how the two relate.

Run the honest test on your own data

Gaplad carves synthetic gaps out of your record, scores a gradient-boosted model on your other sensors against linear interpolation per gap length (NSE, KGE, RMSE), and fills each real gap with the winner. All in your browser.

Open Gaplad, free How to choose a method