Source: https://www.inference.org.uk/itprnn/book.pdf