Imagine I have a collection of data, let's say the travel time for a road segment. On this collection I want to calculate the mean and the standard deviation. Nothing hard so far.
Now imagine that instead of having my collection of values for one road segment, I have multiple collections of values that correspond to the multiple sub segments that compose the road segment.
For each of these collections, I know the average and the standard deviation. From that, I want to aggregate these multiple average and standard deviation in order to get the average and standard deviation for the whole road segment.
For example, let's suppose I have the following dataset :
subSegmentA , subSegmentB , subSegmentC , subSegmentD
values 20 45 25 70
30 55 10 60
10 10 10 80
15 50 30 75
15 40 15 75
20 40 20 80
30 45 20 65
10 40 25 70
average 18.75 40.625 19.375 71.875
stddev 7.90569415 13.47948176 7.288689869 7.039429766
expected_global_average : 150.625
expected_global_stddev : 18.40758772
For the average there is no problem, a simple sum do the job, but I have trouble with the global_stddev.
I tried multiple solutions from here, without success.
Edit : After further research, it seems mathematicaly impossible to calculate the standard deviation of a set based only from the standard deviation and average of subsets.
So I am trying to calculate a new metric, that would approximate this global standard deviation.
To do so, I can use in addition to the avg/stddev per subsegments, the length ratio of the subsegment to the road.