Code from Cosma's advanced data analysis class