# How to measure the time-decayed rate of independent event

I have events arriving in a software system at a variable rate. Imagine these events are, say, hits on a website.

I'd like to periodically report on the rate of arrival of events over a number of sliding windows.

That is, every second I'd like to be able to say there were n events/second over the last second, m events/second over the last $5$ seconds and $p$ events/second over the last $30$ seconds.

I'd prefer to do this without keeping large amounts of history (because I may want to make quite large time windows, events occur at the rate of $1000$s per second, and I will want to be measuring lots of different metrics).

I'd also prefer to not to simply keep a counter for each window and reset it to zero with each report, because the rate will be quite spiky, so I'd prefer some kind of smoothed result.

Finally, how would I modify this so that instead of counting the number of events, I could instead associate a "weight" or "score" with each event, and report the average of these numbers over each window. Imagine that each event represents a delivery truck passing by on the highway and instead of counting the number of trucks per window, I instead want to count the number of packages passing by per window.

(PS. I'm a programmer, not a mathematician as you can probably tell!)

• Did you figure it out? I have a very similar problem. – Jirka-x1 Aug 13 '13 at 12:38