I have a problem where i need to calculate the running average of the number of trucks passing through a given road.
Naturally, on a good day there is a high demand for a given product, so the number of trucks increases due to an attempt to increase the supply, and vice versa.
Quoting the excellent answer given by Henry on the question: Incremental Average. I think it is reasonable to use one of the following formulas:
For a running average you need to keep at least two pieces of information: the number of terms so far and the running mean (or something equivalent to it).
Let's suppose the $n$th component of the vector is $a_n$ and the running mean up to this is $m_n$ so $$m_n= \frac{1}{n}\sum_{i=1}^n a_i.$$
Starting with $m_0=0$, you can use the obvious single pass $$m_n = \frac{(n-1)m_{n-1}+a_n}{n}$$ but precision errors are likely to be smaller if you use the equivalent $$m_n = m_{n-1} + \frac{a_{n}-m_{n-1}}{n}.$$
Using weights, instead of keeping the number of terms so far you need to keep the sum of weights so far
$$m_n = m_{n-1} + \dfrac{w_n(a_{n}-m_{n-1})}{w_n + \sum_{i=1}^{n-1} w_i}.$$
My question is: Given the above "truck-scenario" what type of running average is most suitable, a weighted or non-weighted one. If I were to weight the data, how would I determine the weights? I have read that Inverse-variance weighting is a famous method and sometimes standard deviation or coefficient of variation is used as weights.Is there better methods?