Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use incremental moving average calculation #10

Closed
markusressel opened this issue Mar 3, 2021 · 0 comments · Fixed by #11
Closed

Use incremental moving average calculation #10

markusressel opened this issue Mar 3, 2021 · 0 comments · Fixed by #11
Assignees
Labels
enhancement New feature or request

Comments

@markusressel
Copy link
Owner

markusressel commented Mar 3, 2021

Currently sensor values are simply stored in a big buffer and the average is fully calculated each time it is needed by accessing and summing up all values in the buffer. This is unnecessarily expensive, since in this scenario the average can be calculated much more easily using this formula:
image
See Wikipedia - Moving average

Since we don't need the individual sensor values anyway, using this formula it should also be possible to remove the buffer altogether, and only store the current moving average.

It might also be interesting to see if a simple moving median is better suited, but it would require more performance and memory.

@markusressel markusressel added the enhancement New feature or request label Mar 3, 2021
@markusressel markusressel self-assigned this Mar 3, 2021
markusressel added a commit that referenced this issue Mar 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant