Category Archives: math

mathclock

I was wondering how to calculate the average of a series of times for a project I’m working on. In fact, it’s quiet simple.

Here’s how I did it.

Imagine you have 4 times you want to know the average of.

08:30:56 – 08:45:12 – 09:32:28 – 10:20:07

You can calculate an average by adding the different values and divide those by the amount of added values. In this case, since we’re working with times, simply adding the values won’t work. To do this I first convert each time into seconds:

08 * 3600 + 30 * 60 + 56 = 28800 + 1800 + 56 = 30656 seconds

08 *3600 + 45 * 60 + 12 = 28800 + 2700 + 12 = 31512 seconds

09*3600 + 32*60 + 28 = 32400 + 1920 + 28 = 34348 seconds

10*3600 + 20*60 + 07 = 36000 + 1200 + 7 = 37207 seconds

Now we add those results together and divide it by the amount of times, 4 in this case.

(30656 + 31512 + 34348 + 37207) / 4 = 33430,75 seconds

Now we convert this result back to hours, minutes and seconds

First the hours

33430,75 / 3600 = 9.286 (9 hours + 0.286 hours)

Then the minutes

0.286h * 3600 = 1029.6 seconds

1029.6/60 = 17.16 (17 minutes + 0,16 minutes)

And finally the seconds

0.16 * 60 = 9.6 seconds or ~10 seconds

So, the result is 9:17:10. I thinks it’s right, nevertheless, if I made mistakes or if you know a better solution thanks to let me know.