Source: https://www.stat.auckland.ac.nz/~ihaka/787/lectures-quantiles.pdf