rem Linear Regression cls print "Linear Regression" print rem variables j=0 k=0 l=0 m=0 r2=0 rem data entry input "number of known points? ";n for t=1 to n print print "x(";t;")= "; input " ";x print "y(";t;")= "; input " ";y if n=2 and t=1 then x1=x y1=y end if j=j+x k=k+y l=l+x^2 m=m+y^2 r2=r2+x*y next t rem compute curve coefficient if n=2 then b=(y1-y)/(x1-x) a=y-b*x else b=(n*r2-k*j)/(n*l-j^2) a=(k-b*j)/n end if print print "f(x)=";a;"+(";b;"*x)" print rem compute regression j=b*(r2-j*k/n) m=m-k^2/n k=m-j r2=j/m if n>2 then print "Coefficient of Determination (r^2)= ";r2 print "Coefficient of correlation (r^.5)= ";(r2^.5) print "Standard error of estimate (k/(n-2)^.5= ";(k/(n-2))^.5 end if rem "estimate y coordinate" [again] print print "Interpolation (enter x=q to end program) "; input "x= ";x$ if x$="q" then end end if x=val(x$) print "y= ";a+b*x goto [again]