Skip to content

Instantly share code, notes, and snippets.

@bvssvni
Created August 24, 2014 11:40
Show Gist options
  • Save bvssvni/b7db96953a9ae09e0425 to your computer and use it in GitHub Desktop.
Save bvssvni/b7db96953a9ae09e0425 to your computer and use it in GitHub Desktop.
Moving average:
avg * n / (n + 1) + x / (n + 1)
= (avg * n + x) / (n + 1)
substitue 1 with k:
(avg * n + x) / (n + k)
where k is `if n * dt > sample_range { 0 } else { 1 }`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment