Adapted code samples for the "Think Stats" book.