How to calculate continuous smooth event rate based on event times?

前端 未结 2 1915
我在风中等你
我在风中等你 2021-01-13 23:04

Based on a continuous realtime event stream (where time of every event is easily known, but each event has no value, they are all identical), how program a filter/process th

相关标签:
2条回答
  • 2021-01-13 23:43

    By averaging. for example everytime you get an event add one to a. every second remove 1/60 of a. it will give you a simple average with a sliding window of about one minute.

    0 讨论(0)
  • 2021-01-13 23:53

    This can be implemented with a moving average. Take your last N events where N is the size of your averaging window. Compute the time difference between the first and the last of these N events. If you are measuring in seconds and want the rate in event per minute you would then divide 60 seconds by your time difference expressed in seconds and you multiply by N-1.

    currentAvgRate = (N-1) * 60 / (time different between last N events)

    The greater the value of N the smoother your curve will be, but also the less it will react to local changes.

    0 讨论(0)
提交回复
热议问题