example (confidence limits in simple linear regressionthe following program draws samples from simple linear regression model with parameters [ ]and where the -coordinates are evenly spaced on the interval [ the parameters are estimated in the third block of the code estimates for and are [ ]and respectively the program then proceeds by calculating the numeric confidence and prediction intervals for various values of the explanatory variable figure shows the results confpred py import numpy as np import matplotlib pyplot as plt from scipy stats import from numpy linalg import inv lstsq norm np random seed ( np linspace ( , , reshape ( , parameters beta np array ([ , ]sigma xmat np hstack (np ones (( , )) )design matrix xmat beta sigma *np random randn (nsolve the normal equations betahat lstsq (xmat yrcond =none)[ estimate for sigma sqmse norm( xmat betahat )/np sqrt( - tquant ppf ( , - quantile ucl np zeros (nupper conf limits lcl np zeros (nlower conf limits upl np zeros (nlpl np zeros (nrl np zeros ( (trueregression line for in range ( ) /nxvec np array ([ , ]sqc np sqrt(xvec inv(xmat xmatxvecsqp np sqrt ( xvec inv(xmat xmatxvecrl[ixvec betaucl[ixvec betahat tquant sqmse *sqclcl[ixvec betahat tquant sqmse *sqcupl[ixvec betahat tquant sqmse *sqplpl[ixvec betahat tquant sqmse *sqpplt plot( , 'plt plot( ,rl ,' 'plt plot( ,ucl ,' :'plt plot( ,lcl ,' :'plt plot( ,upl ,' --'plt plot( ,lpl ,' --'