cleaned up linear regregression and fixed a few small errors in the math