compute_history function

Computes cumulative history for the time-series