When a Hydraulic Forecasting Model Is Wrong, the Cause May Not Be the Model


A residual means little until you know how much surprise is normal.
At 10:15 a.m., a pressure forecasting system reports a discrepancy. At one monitoring point in a water distribution network, the model expects 34.0 mca. The sensor reports 36.5 mca, a residual of +2.5 m. Fifteen minutes later, it is still there.
Why would 2.5 mca matter? In a distribution network, pressure is a managed quantity. Too little affects service, too much stresses pipes and typically increases leakage, and an unexplained shift can point to a burst, a valve problem or a failing sensor. Whether a few meters is material depends on the network and its pressure targets.
The tempting reaction is to ask how large the error is and whether the model needs retraining. This article proposes a different first question: how large a residual is normal here, at this time of day? The answer is a band, and the band changes what the evidence means.
1. Some error is always there
Pressure sensors are noisy, and demand changes faster than a 5- or 15-minute sample can show. Each sample is a snapshot of a signal that moved in between. Part of what the model misses is therefore not a failure: it is variation that no model built from this data could predict. Call it the noise floor.
That has a consequence for evaluation. A scalar score such as RMSE or MAE averages everything into one number. It is useful for comparing two models on the same data, but it cannot say whether a particular residual is surprising, and it hides the fact that surprise depends on the time of day. The question that matters is not how small the error is, but whether this residual is unusual given the expected variation.
With a calibrated 95% band, about one sample in twenty falls outside it by construction. At 5-minute sampling that is about 14 samples per day (288 × 5%), and about 5 per day at 15 minutes, with nothing wrong in the network.

2. What the model knows
To build a band you need an expected value, and the expected value comes from patterns the model can name. A common and readable choice is an additive decomposition:
ŷ(t) = g(t) + s_day(t) + s_week(t) + h(t)
Here g is the trend, s_day and s_week are the daily and weekly seasonalities, and h collects calendar effects such as holidays and known operations. Each seasonality is a Fourier series, a sum of sine and cosine terms whose period P is the length of the cycle:
s(t) = Σ (aₙ cos(2πnt/P) + bₙ sin(2πnt/P)), n = 1 … N
A handful of terms captures the smooth daily cycle of demand. More terms capture sharper peaks, but they also start fitting noise, so N is a trade-off. The trend is piecewise: it may bend at a limited number of change points, and regularization keeps it from bending at every wiggle.
This helps diagnosis, not only prediction. Each component can be inspected and tested on its own, so when a residual appears you can ask which component should have explained it.

3. A band, not a number
The band has two ingredients: the spread of the residuals under normal operation, estimated for each time of day, and the uncertainty about where the trend will be. In the short term the first dominates, and it is not constant. Pressure varies more when demand is volatile, so the band is wider at the morning and evening peaks than at night.
Back to 10:15. With an expected value of 34.0 mca and a spread of about 0.6 mca at that hour, the 95% band runs from about 32.8 to 35.2 mca. The measurement of 36.5 m is outside it. The standardized residual makes this explicit:
z(t) = (y(t) − ŷ(t)) / σ(t) → 2.5 / 0.6 ≈ 4
But the same +2.5 mca means different things at different times of day:
Time | Expected (m) | σ (m) | 95% band | Measured (m) | z | Reading |
03:00 | 38.0 | 0.4 | ± 0.8 m | 40.5 | ≈ 6.3 | Outside: anomaly candidate |
08:00 | 34.4 | 1.3 | ± 2.5 m | 36.9 | ≈ 1.9 | Inside: ordinary variation |

All values are illustrative. The band is a modeling choice that must be checked: on clean data, the share of observations inside the nominal 95% band should be close to 95%. A band that is too narrow floods the operator with false alarms. One that is too wide hides real events.
4. Persistence turns an exceedance into evidence
One sample outside the band is expected several times a day, so it carries little information. What carries information is persistence and direction: several consecutive samples on the same side, or a residual whose mean has shifted. Two simple tools capture this. The first counts consecutive exceedances. The second is a cumulative sum, which accumulates standardized residuals beyond a small allowance k:
S(t) = max(0, S(t−1) + z(t) − k)
A decision threshold on S responds to small, sustained shifts that no single point would trigger. Because real residuals are autocorrelated, thresholds should be tuned on historical clean data rather than taken from formulas that assume independence. This is also where trend matters: a slow drift can stay inside the band for days while the cumulative sum quietly grows.

Residual-based detection in water networks follows this general logic: compare observed and expected behavior and flag residuals that are statistically unusual, for example with a Z-score on forecasting residuals. See a recent benchmarking methodology and a survey of machine learning in water distribution networks.
5. Reading the signature
Once a residual is persistent, its shape suggests where to look. A level shift often points to a physical change or a sensor offset. A gradual drift often points to sensor drift or a slow change in demand. Isolated spikes that return to the band are usually noise or outliers. Exceedances only at demand peaks often point to a limit of the model, such as a band that is too narrow there or a missing input. A signature suggests a cause; it does not prove it.

This maps onto three working hypotheses:

These hypotheses are not mutually exclusive. A valve operation can coexist with a biased sensor. And if the forecasting model never receives the valve state as an input, a physical change and a model limitation are the same event seen from two angles. The goal is to weigh the evidence for each explanation, not to force exactly one to be true.
Two kinds of model appear here. The forecasting model is data-driven and produced the expected value. The hydraulic model is physics-based, a simulation of the network such as EPANET, and we use it below to test physical scenarios. When we ask whether “the model” is wrong, the second can be wrong too.
6. Testing the explanations
A pressure sensor does not give direct access to the physical state. It gives a measurement produced by an instrument. A simple model of that is:
y(t) = p(t) + b(t) + ε(t)
where p is the actual pressure, b is systematic bias and ε is noise.
Where does the independent reference come from? It is a second measurement of the same pressure, taken by a different instrument: for example, a calibrated portable pressure logger or gauge installed by a field crew at the same hydrant or tap, a recently calibrated reference instrument, or a redundant sensor at the same location. “Independent” means it does not share the failure mode of the installed sensor: a different device, a different calibration history and, ideally, a different signal path. It must also measure the same thing, at the same point (or the same elevation, since pressure changes with height) and in the same time window, and its own accuracy must be known. A reference accurate only to ±2 mca could not settle a 2.5 mca disagreement.
In our case the independent reference reads 34.2 mca: inside the band and close to the forecast, while the installed sensor reads 36.5 mca. That supports a positive sensor bias.

A single comparison is not enough. We need the instruments’ accuracy, the conditions of the comparison, and repeated observations. If the bias is confirmed, the practical steps are:
Inspect the sensor and installation
Check calibration and maintenance records
Mark affected data as unreliable where appropriate
Reassess the model using trustworthy observations
Now change one piece of evidence. Suppose the reference confirms the higher pressure and a valve adjustment was recorded shortly before the shift. The bias hypothesis loses weight, and a hydraulic simulation can compare the valve in its previous and recorded positions. If the second scenario reproduces the observed change at the affected point, and plausible changes elsewhere, the physical explanation gains support.

Agreement strengthens the hypothesis; it does not prove causation. The simulation depends on assumptions about demand, pipe properties, boundary conditions and network representation, so the next step is to test sensitivity and look for alternative explanations.
Sometimes the evidence cannot separate the causes. This is a question of observability (can the internal state be inferred from the outputs?) and identifiability (can different explanations be distinguished from the available observations?). Methods based on model invalidation, such as Vrachimis et al. (2021), use the same logic at a larger scale: they ask whether the measurements are compatible with what the model can explain given its uncertainty. When the answer is unclear, useful next steps are a new measurement, an operational record, better demand estimates or a component inspection.
7. Retraining can hide the anomaly
If the model is retrained on recent data that include the anomaly, it can absorb it. The expected value moves toward the biased measurement, the residual shrinks, the scalar error improves and the alarm goes quiet. The model is now less accurate relative to the actual pressure, and nobody is being told.

Some practical rules follow from this:
Exclude flagged windows from training until their cause is understood.
Keep a frozen baseline to compare against after any retraining.
Evaluate by band coverage and by behavior on known events, not only by a scalar error.
Retrain to fix a diagnosed limitation (missing input, insufficient data, too long a horizon, representation), not to silence a residual.
8. A diagnostic order
Put together, the investigation follows an order that protects the model: align the data, standardize the residual, validate the measurement, test physical explanations, check the model’s limits and only then retrain. Different evidence leads to different conclusions, and different conclusions lead to different interventions.

When a prediction disagrees with reality, the first task is not to force the two to agree. It is to ask how much disagreement is normal, and what the rest can tell us.
References and notes
All numerical values and chart examples in this article are illustrative and are not presented as measurements from a real network.












Comentários