Source: https://remi.flamary.com/cours/sig_alea/TD4.pdf