This is R code recreated from the lecture notes of "Computational Methods for Data Analysis"