I have sales data in weekly buckets like this:
weekID product SoldQty
1 1 10
2 1 20
3 1 30
4 1 40
5 1 50
6 1 60
7 1 70
1 2 10
2 2 20
Calculating the standard deviation of weekly sales per product is pretty straightforward.
Now, I am asking the question: how do you calculate the standard deviation for the same data, but bi-weekly bucketed? x-weekly bucketed?
Question 2: is there an efficient algorithm for calculating it on weekly data instead of materializing the x-weekly combinations?
From the business side it means that I have various forecast horizons (1wk, 4 wks, 6wks...) per product. And I would like to build the confidence intervals for predictions of SoldQty within the forecast horizon.
It all seems very similar to the Safety Stock calculations from logistics, but I would like to be sure.
UPDATE:
Please consider there are multiple ways to re-bucket (re-combine) this data. I think that if the new bucket contains W weeks, there are W ways to re-bucket data. For an example of 2-weekly buckets.
Way 1:
bucket wkid prod sold
1 1 1 10
1 2 1 20
2 3 1 30
2 4 1 40
3 5 1 50
3 6 1 60
4 7 1 70
...
Way 2:
bucket wkid prod sold
1 1 1 10
2 2 1 20
2 3 1 30
3 4 1 40
3 5 1 50
4 6 1 60
4 7 1 70
...
Both options make sense business-wise. Essentially you need to calculate standard deviations between sales during fortnights. And, standard deviation in way 2 should be different from way 1.
Thanks in advance for your suggestions!