Source: https://www.stat.berkeley.edu/~aldous/206-LD/source-coding.pdf