Repository navigation
Add find_delay, fix vector aic, and improve the delay estimation example - #212
Merged
Merged
Conversation
- Add find_delay, which sweeps the input delay of an ARX model and compares the candidates on validation data, together with a plot recipe. - Normalize aic for vector residuals by the number of samples. The previous method used size(x, 2) = 1 for vectors and thus penalized the number of parameters by 2d instead of 2d/N, which affected find_na and find_nanb. - Delay example: use the inputdelay convention of arx consistently, prewhiten the input before cross-correlation, start the experiments at rest, select the FIR regularization from validation data, use find_delay, correct the model order and echo-gain statements, evaluate the internal-delay examples with the delay sweep, seed the random number generator and fix typos. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…onvention, use validation data for the closed-loop sweep Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…eep only corrections and additions Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…zation parameter Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
baggepinnen
referenced
this pull request
Nov 24, 2026
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
New function
find_delay(src/delay.jl, exported together withDelaySweep): fits anarxmodel for each candidateinputdelay, scores the candidates on validation data (simulation or one-step prediction error) and returns the best delay together with the loss curve.plot(sweep)plots the loss as a function of the delay. Tests intest/test_delay.jl.Bug fix in
aic: for vector residuals the method used2d / size(x, 2), which equals2dsincesize(x, 2) == 1. The penalty was therefore not normalized by the number of samples, which affectedfind_naandfind_nanb. The method now computeslog(sse(e) / N) + 2d / N. Test added intest/test_utils.jl.Delay estimation example (
docs/src/examples/delayest.md):inputdelayconvention ofarxis stated explicitly and used consistently (a pure delay ofnsamples corresponds toinputdelay = n + 1). The previous example usedinputdelay = τ_samples, which is one sample short.find_delay;find_nanbis applied to noisy data since information criteria are not informative for noise-free data.na = 4is order 4), the echo example (low-frequency gain of 0.6 instead of an energy fraction), and the internal-delay conclusions (delay sweep including zero delay) are corrected.DelimitedFilesremoved,τ_samplesderived fromτ / Ts, distinct names for the shifted dataset, typos.Verification
Notes
arxis biased by output noise. In the example (noise standard deviation 0.1 relative to an output of standard deviation of about 3) the delay is recovered exactly, whereas for larger noise levels and smallnait deviated by several samples. This is documented in the docstring.Host: demeter2, session 5b64e4e0-6634-41ce-b4c4-90775881ee48, working directory
~/repos/CSI-delay🤖 Generated with Claude Code