Source: https://conference.scipy.org/proceedings/scipy2010/pdfs/floehr.pdf