Calculate the exponentially weighted moving average (otherwise known as Unix 'load average') of a counter in Javascript