I just did something amazingly similar a couple weeks ago, and I used mysql to do the calculations. I was ridiculed and told that I was expecting too much of MySQL and it wasn't ment to be that powerful!!! Muhahaha....
what I did was
preform a datediff (you'd want to use timediff) and devide by my span (15 in your case) and floor it... then group by that colum. this will allow you do do any math functions, on that grouping, (like averaging).
now, if you are not using a database, this information is worthless to you, but you didn't specify so :p
BTW datediff and timediff were added in mysql 4.1.1