Skip to content

Instantly share code, notes, and snippets.

@0xPIT
Created December 20, 2021 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xPIT/2f58cfc2e3ef01ac75fd79b29e6ac6d1 to your computer and use it in GitHub Desktop.
Save 0xPIT/2f58cfc2e3ef01ac75fd79b29e6ac6d1 to your computer and use it in GitHub Desktop.
Exponential Moving Average Filter
template<typename T>
T exponentialAverageFilter(const T& value, T& pastValue, const float& filterWeight = 0.8) {
return static_cast<T>((1.0 - filterWeight) * pastValue + (filterWeight * value));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment