calculate linearity uncertainty calculate residuals