function error = lsq_error(parameter, x, y) % parameter(1) is the slope % parameter(2) is the intercept f_x = x .* parameter(1) + parameter(2); error = mean((f_x - y).^2);