Code for ThinkStats2