# Analytics average time from each second count

So to visualise the problem heres the mocked data that i use.

1s => 2840,
2s => 2042,
3s => 1106,
4s => 269,
5s => 409,
6s => 0,
7s => 449,
8s => 531,
9s => 910


What i would like to achieve is to get the time value (s) which applies to the all counts average, thats been weighted depending on the time and count.

As for simpler example to understand what i mean

1s => 10,
2s => 0,
3s => 10


The output would be 2s

In this case, one simply takes the weighted average: $$\frac{2840+4084+3318+1076+2045+0+3143+4248+8190}{2840+2042+1106+269+409+0+449+531+910} = 3.38288920056\dots.$$