Added linfit function for linear least squares fitting