Assuming that Count and Average are indexed values, you can compute your aggregate average this way:
TotalCount = Sum(Count)
TotalAverage = Sum(Average * (Count/TotalCount))
If you want to calculate the values in a single iteration over your serialized data, you can sum successive weighted averages in a manner that looks like exponential averages.
TotalCount = 0
TotalAverage = 0
for each index in data-set of [Average, Count]
TotalCount = TotalCount + Count[index]
Weight = Count[index]/TotalCount
TotalAverage = TotalAverage * (1 - Weight)
+ Average[index] * Weight
You can derive the right approach by considering the first two pairs.
If there was only the first pair:
TotalCount = Count[1]
TotalAverage = Average[1]
But, if there are two pairs:
TotalCount = Count[1] + Count[2]
TotalAverage = Average[1] * (Count[1]/TotalCount)
+ Average[2] * (Count[2]/TotalCount)
If we were iterating from the first pair into the second pair, then the two pair calculation could look like:
TotalCount = TotalCount + Count[2]
TotalAverage = TotalAverage * (TotalCount - Count[2])/TotalCount
+ Average[2] * (Count[2]/TotalCount)
If we let Weight represent Count[2]/TotalCount, the above simplifies to:
TotalCount = TotalCount + Count[2]
Weight = Count[2]/TotalCount
TotalAverage = TotalAverage * (1 - Weight)
+ Average[2] * Weight
Since TotalCount and TotalAverage is correct at each step that takes on a new pair of the serialized data, the [2] can be replaced with an iteration index.