Python implementation of Cumule algorithm