I am developing a fleet management system, and one of the tasks is to show a graph reflecting the fuel consumption on the vehicle (based on data from CANBUS).
If the data value is between 0 and 100, this means a percentage. So, if I get an integer equal to 45, this means that the fuel in the tank is 45%.
However, if the car is moving, conflicting data may arise due to the physics of the ship. For example, a series of data might be:
76,76,75,74,73,73,71,70 <- this is a good model, because it shows how the fuel is reduced.
76,70,75,76,77,76,74,74,73,72,69,72,73,73,72,71 - this is not a good model due to fuel surges in the tank is not consistent, and the data which I receive are not suitable for display to the user.
I want to smooth out the values, but depending on how many values I select on average at a time, the result is different.
The key problem is that sometimes there are drainage and refueling points that I MUST show on the graph and should not be smoothed out.
What algorithm can I use to analyze and present my chart in a convincing way for the user?