Please consider the following: I have to deliver the weekly customer demand data
on time. I can start to produce my products one week in advance. So I was thinking of producing always one third (=1/Length@data
) of the customer demand of week i
in week i-1
:
data={500.`, 5000.`, 6000.};
result=data /.
{a_, b_, c_} :>
{(a + (b + c*1/3)*1/3)*1/3, (a + (b + c*1/3)*1/3)*2/3, (b + c*1/3)*2/3, c*2/3}
As in reality Length@data
differs from 3 I need a function which takes Length@data
somehow into consideration.
I was thinking about:
MyFunction[data_List]:=
Module[
{L=Length@data},
data/.{list1}:>{list2}
]
Whereas list1
represents the pattern of length L
and list2
the replacement function of length L+1
(as I start to produce one week in advance).
Has anyone an idea of the easiest way of defining such a recursive function?
EDIT:
To see the difference between the stretched and non-stretched customer demand, please consider the following plot. Here you can see that the production level per week is lower when stretched (green line) resulting in lower average weekly capacity demand within the factory.
ListLinePlot[{Prepend[data,0],result},PlotStyle->{Dashed,Green}]
(a + (b + c*1/3)*1/3)*2/3
as you have always to pick the result of the element at the right hand side. Maybe I can useReverse
to simplify $\endgroup${a_,b_,c_,d_}
? Where do the1/4
,2/4
, etc get multiplied? $\endgroup$