Last active
December 15, 2015 02:19
-
-
Save berikv/5186106 to your computer and use it in GitHub Desktop.
Running average as implemented in the Linux/Unix kernels (shown with the `w` command).
Usages can be frame rate, accelerometer, etc.
This file contains 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
// A factor of 0.5 means that every newValue will have a 50% impact on the average | |
// Usage: self.average = updateRunningAverage(self.average, newValue, 0.3); | |
#define updateRunningAverage(average, newValue, factor) (((newValue) * (factor)) + ((average) * (1.0 - (factor)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment