Currently, The lifetime distribution function assumes that all input to the DSM happens on 1 January at once.
This is irrelevant for longer $lifetimes >> 1 year$. But for plastics packaging we have much shorter lifetimes.
If instead we take time averages of the lifetime distribution functions, we would get
One with "time instant" like now, which receives a vector of points in time, such that the survival function at input year = output year is always zero.
One with "time average", where each time step represents the average stock and flow in that period.
Time instant implementation:
first get a difference matrix (previously called "remaining ages") $D_{o,i} = \max(0, t_o - t_i)$, where $i$ and $o$ are input year and output year indices and $t$ is the time vector.
get a matrix "end of life share by year" $E_{o,i} = \rhoi(D{o,i})$ with the lifetime distribution function $\rho$ (e.g. log-normal; NOT the survival function), the parameters of which may depend on the input year.
Get the survival function $S{o,i} = 1 - \sum{\tilde{o}=1,...,o} (E_{\tilde{o},i})$, i.e. one minus the cumsum over $o$.
Changes for average formulation
instead of a vector of time instants, this method needs a vector of time interval lengths $l$ and a vector $s$ with the starting points of the time intervals. Since we can't assume that such a vector is passed, I'd add a method to create it from a vector of time instances, where each interval bound is in the midpoint between two time instances. The starting point vector is one element longer than $t$, as $s_{n+1}$ is needed as the end point of the interval $n$.
I assume that $t$ indices run from 1 to $n$. Then $s_i=(ti + t{i-1})/2$ for $i=2,...,n$, and extrapolation yields $s_1=s_2 - (t_2 - t1)$ as well as $s{n+1}=s_n + (tn - t{n-1})$. . The vector of interval lengths is then $li = (s{i+1}-s_{i})$ for $i=1,...n$.
$\tilde{D}_{o,i} = \max(0, s_o - s_i)$ is also required in the adapted/extended version.
instead of getting $E_{o,i} = \rhoi(R{o,i})$, we now get it via the integral average formulation
$E_{o,i} = [Pi (\tilde{D} {o,i})-Pi(\tilde{D} {o+1,i})]/l_i$ . Here, $P$ is the scipy survival function belonging to each ldf. Its parameters (mean, std) can be dependent on $t_i$.
The calculation of $S_{o,i}$ remains the same as for the time instant implementation
Currently, The lifetime distribution function assumes that all input to the DSM happens on 1 January at once. This is irrelevant for longer $lifetimes >> 1 year$. But for plastics packaging we have much shorter lifetimes. If instead we take time averages of the lifetime distribution functions, we would get
$\lim_{lifetime\rightarrow 0} stock = annual\_inflow * lifetime\_in\_years$,
which is the actual limit, instead of some other, incorrect value of the LDF.
However, we should make this behaviour optional.