Source: https://www.i3s.unice.fr/~nlt/cours/licence/pdist/pdist2_slides.pdf