I have a stream of (x,y) data that I want to determine velocity and acceleration from. The data is pretty typical and can be thought to represent say a car driving around.
A new data point comes every 2ms and I would prefer to not accumulate/store unnecessary values so I thought to use a boost::accumulator
.
Is there a simpler way to handle this type of task? or perhaps other libraries that already exist which already does this? or am I on the right track with my thinking. Not yet sure what tags I'm going to use but I like the idea that the container keeps an updated value for a given property and doesn't store the old positional data.
Another idea is to use a circular buffer (e.g size 200) and calculate the acceleration based off the last 50 values and velocity based off all the values in the buffer. However if the buffer stores raw positional data this would require looping over all elements every time to calculate the acceleration and velocity. This could be improved by instead keeping some sort of rolling acceleration and velocity value which recalculates by removing the value from the end element and adding the value from the new element to insert (with weight 1/elements in buffer). However this to me seems like some sort of boost rolling weighted accumulator.