Slides and codes for lecture 10 (model fitting)