Translated from Matlab to Python and modified from https://github.com/jdherman/Qsynth.
Original publication: Kirsch, B. R., G. W. Characklis, and H. B. Zeff (2013), Evaluating the impact of alternative hydro-climate scenarios on transfer agreements: Practical improvement for generating synthetic streamflows, Journal of Water Resources Planning and Management, 139(4), 396–406.