Last active
September 9, 2025 18:09
-
-
Save D3MZ/f2321cf40e09e6ceb3acf6a28c980db8 to your computer and use it in GitHub Desktop.
In the example, the residuals subtract a walk from a random walk. This could be used for evaluating a model to find the reference pattern.
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
| using Plots | |
| walk(n_steps; start=0.0, step_std=1.0) = cumsum([start; randn(n_steps) .* step_std]) | |
| residual(y) = walk(length(y) - 1) .- y | |
| residuals(y, n) = [residual(y) for _ in 1:n] | |
| #Example | |
| reference = walk(100) | |
| plot(reference, linewidth=4, label="Reference") | |
| plot!(residuals(reference, 10), alpha=0.7, label=false) |
Author
D3MZ
commented
Sep 9, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment