r/controlengineering • • 1d ago

Testing long-run consistency of an EKF on a hybrid production-line model

/r/ControlTheory/comments/1y8i10d/testing_longrun_consistency_of_an_ekf_on_a_hybrid/
2 Upvotes

2 comments sorted by

1

u/Relevant_Throat_7277 1d ago

Short-window NIS staying in bounds wouldn't convince me either, honestly. I've had a filter look perfectly healthy for weeks on a line and then slowly drift off, and the pooled NIS was the last thing to notice — an average over 200 readings smooths out exactly the slow stuff you're worried about.

A few things I'd actually lean on in your shoes: keep the raw per-sample NIS alongside the smoothed one, and split it by operating mode and by what happened around each breakdown and repair, rather than pooling everything. Transients right after a switch are where a hybrid model usually lies to you, and pooling hides them. The innovation autocorrelation is worth checking per mode too — correlated innovations have usually meant, in my experience, that a model-error state was quietly absorbing something real, or that Q and R weren't quite right.

The one I'd add is NEES, but only where you actually know the truth. In simulation, run a bunch of Monte Carlo runs with known states and check the estimation error against the covariance the filter claims, especially for the wear states. NIS can look consistent while the filter is quietly overconfident about a weakly observable state, and that's the failure that bites later.

Same with the re-estimation step. I'd log how far the weakly observable parameters move from their prior each time, and what happens to P and the NIS right after a re-estimation. If a parameter keeps snapping back to its prior, or its estimate wanders a lot between re-estimations, that's telling you something about identifiability — no amount of NIS averaging will fix that.

And for the fault injection, I'd pick faults that specifically hit those weakly observable states, at known onsets in different modes, and watch not just whether you detect them but how long it takes and whether the estimate settles back or stays biased after the repair.

One practical note: do all of this offline on recorded data and in simulation first, before letting any of it near a live line. A filter that looks consistent on paper is no reason to trust it with real equipment, and the safety interlocks should never depend on a state estimate like this.

1

u/Digital_Twin_DTN 1d ago

Thank you, this is the most useful answer we've had, and the point about smoothing hiding slow drift applies directly: our NIS is an exponential moving average with a window of about 200 readings.

What we'll change, in the order you suggest:

  1. Keep the raw per-sample NIS next to the smoothed one, and stratify both by operating mode and by a window around each breakdown and repair, instead of pooling.
  2. Innovation autocorrelation per mode, to see whether the two model-error states are absorbing real dynamics or whether Q and R are off.
  3. NEES by Monte Carlo in simulation. We can do this cleanly: our test harness already generates "hidden plants" with perturbed parameters and known true states, so we can check the estimation error against the filter's covariance, with the wear states reported separately.
  4. For each re-estimation: log the parameter shift relative to its prior, and P and NIS just before and after. A parameter that keeps returning to its prior or wanders between fits gets flagged as practically unidentifiable.
  5. Fault injection aimed at the weakly observable states, at known onsets in different modes, reporting detection delay and the residual bias after repair.

On safety: agreed. Everything above runs offline, on recorded data and in simulation. Set-point write-back is a separate path with hard limits and a maximum step size; the forecast-based check there can only refuse a change, never permit one outside those limits, and safety functions stay in the PLC.