Source: https://www.jstatsoft.org/article/view/v069b05/980.pdf