I'm not a data scientist. Spent quite some time on this thing. Ended up using a thing called "backward expanding weighted moving average", but the trick was to calculate the weights iteratively (i.e. amount/number_of_intervals). Might be able to refactor and use np.convolve instead which should be more performant but there's no need for that at the moment.