Situation (example only):

I have 10 steps that each have a start and end time, the steps occur in order. I'll refer to the steps as steps 1 through 10.

I have between 1 and infinite (inclusive) records that each contain exactly 1 copy of each step.

I want to calculate what % of the total time is taken on any given step (on average), with the total time being calculated from the average of the difference between the start of step 1 and the end of step 10.

When I try to do this currently, I get obviously incorrect results, such as steps taking >100% of the time and the total % values adding up to >100% even when all individual values are <100%. The values appear to show generally the sort of ratio that I might expect however.

Example (all durations in milliseconds):
Record 1: step 1 start 8:30:00.000 step 3 duration 1200 step 10 end 8:30:47.230
Record 2: step 1 start 8:31:12.455 step 3 duration 2200 step 10 end 8:31:20.000
Record 3: step 1 start 8:33:02.213 step 3 duration 500 step 10 end 8:33:30.100
Record 4: step 1 start 8:28:30.670 step 3 duration 3800 step 10 end 8:28:45.002
Record 5: step 1 start 8:38:17.345 step 3 duration 9000 step 10 end 8:38:56.690

We can see that the total duration based off step 10 end - step 1 start is as follows:
Record 1: 47230
Record 2: 7545
Record 3: 27887
Record 4: 14332
Record 5: 39345
The average of which is 27267.8
The average of times at step 3 is 3340

If I were to have data for each of the other steps and get the average of the data as I have shown for step 3 here, and then calculated the % of the total that is represented by each step, the result would be incorrect.

Things I have tried:

I have tried adding up all values for each step in each record and using that instead of the difference between step 1 start and step 10 end, although this had similar results unsurprisingly.

I have also tried adding up the averages of each step together and using that, however, having read about why the average of an average is usually incorrect, I can see why this would not work. I also suspect this is the reason what I am attempting doesn't work currently.

What do I have to do to get the results I am after? That is the % of the average total time taken by a step on average. Can I even realistically do what I'm asking or am I barking up the wrong tree here?

Apologies if I have asked this question in a roundabout way or forgotten something specific to the maths stack exchange as this is my first post here and I'm no mathematician. Feel free to add tags to the post as I'm not sure what this should be tagged as.

  • $\begingroup$ So do I understand correctly, that you have some process that has 10 steps, and then you have a large number of runs of these processes? And then you want to figure out what percentage (on average) each of the steps take of the process? What I would do is, for each run of the process, calculate the total time of the process and divide the length of each of the 10 steps by this. Then you get the percentages for one run. And then you repeat this for the "many" runs that you have ... And in the end you can just calculate the average percentages for each of the 10 columns of data. $\endgroup$ – Matti P. Apr 11 at 8:08
  • $\begingroup$ Thanks for the input, will it be likely that this method will result in ~100% if I added all those average % values together? $\endgroup$ – Brett Jeffreson Apr 12 at 0:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.