3

How Steam calculates the AVGRATE stats in it's api implementation?

https://partner.steamgames.com/doc/features/achievements#AVGRATE

When I call update method with a window size of 3600 the result is something that I can not understand how calculated by Steam:

UpdateAvgRateStat("avg", 50, 100) -> 0.5
UpdateAvgRateStat("avg", 25, 100) -> 0.469988

and calling the second update multiple times make the result converge to 0.25

HojjatJafary
  • 316
  • 1
  • 10

1 Answers1

1

Because UpdateAvgRateStat computes the average over a sliding window, calling it a second time does not immediately update the value to the average that last call would imply. Values passed in previous calls are not immediately thrown out or ignored. They'll stop being a factor in the calculation once they've aged enough and are no longer in the window.

If your intent is to set an instantaneous rate value, this is not the proper way.

1201ProgramAlarm
  • 30,320
  • 7
  • 40
  • 49