Skip to content

Instantly share code, notes, and snippets.

@D3MZ
Last active September 9, 2025 18:09
Show Gist options
  • Save D3MZ/f2321cf40e09e6ceb3acf6a28c980db8 to your computer and use it in GitHub Desktop.
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.
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)
@D3MZ
Copy link
Author

D3MZ commented Sep 9, 2025

Screenshot 2025-09-09 at 2 09 39 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment