Source: https://www.jstatsoft.org/article/view/v082i01/v82i01.pdf