Fuel chart smoothing algorithm

前端 未结 3 609
无人共我
无人共我 2021-01-12 08:06

I am developing a fleet management system and one of the tasks is to show a chart representing the fuel consumption of the vehicle (based on a data that is coming from the C

3条回答
  •  梦毁少年i
    2021-01-12 08:40

    Are there ways to determine when fueling/draining are occurring? If so, then you could change your algorithm at those times dynamically.

    Otherwise, I would recommend using exponential smoothing.

    Let d (0 <= d < 1) be weight factor for previous number. So displayed_number = prev_data*d + new_data*(1-d)

    With a proper weight factor, it would seem the "bumpiness" would be removed, yet at the same time the result would reflect fuel events.

    This isn't the only option, more of an example algorithm, but I hope you find it useful.

    Small edit: I had not realized that exponential smoothing had a proper name. I had merely used the technique when displaying frame rates within games I create. So, thank you Kemper.

提交回复
热议问题