Code to fit a line to data