Source: https://www.lifl.fr/~pietquin/teaching/FAACours9.pdf