-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
The average over last errors, this class uses a std::deque to maintain a sliding window of previous errors:
| last_errors.push_back(error); |
| last_errors.pop_front(); |
While this approach is semantically correct, it is highly inefficient, copying 50 values around in each call.
There are much more efficient ways to just a compute a sliding average:
- Use a circular buffer, maintain the average sum, and just subtract the popped and add the pushed value (all others values remain the same).
- Use estimated sliding average (which should be sufficient here):
avg_error = (1.0 - lambda) * avg_error + lambda * error
where lambda adjusts the smoothing and should be chosenlambda=1.0/nb_errors_for_avghere.
I strongly suggest the latter method and storing lambda once in the class (nb_errors_for_avg shouldn't change over time anyway!) As this requires API changes, I leave it to you to decide on this and implement it.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels