!******************************************************************** !* This Program tests Module STATS for basic statistical Functions * !* ---------------------------------------------------------------- * !* SAMPLE RUN: * !* * !* Population mean and standard deviation: 0.1288112 0.9453266 * !* * !* Sample mean and standard deviation: 0.1288112 0.9500890 * !* * !* For full regression: * !* regression coefficients: 4.6191972E-02 2.024592 * !* standard error of estimate of y on x: 9.522273 * !* correlation coefficient: 0.9871089 * !* * !* For regression forced through (0,0): * !* regression coefficients: 0.0000000E+00 2.025507 * !* standard error of estimate of y on x: 9.522309 * !* correlation coefficient: 0.9871088 * !* * !* ---------------------------------------------------------------- * !* Ref.: "Problem Solving with Fortran 90 By David R.Brooks, * !* Springer-Verlag New York, 1997". * !******************************************************************** Program Tstats Use Stats Implicit None !All variables must be declared Real x(500), y(500), avg, std_dev Real a, b !for linear regression y=ax+b Real s_yx !standard error of estimate of y on x Real corr !correlation coefficient Integer n !# of points in array Integer i Data n/100/ ! Test basic statistics Call NormalArray(x,n) Call NormalStats(x,n,'p',avg,std_dev) print *,' ' print *,' Population mean and standard deviation: ',avg, std_dev Call NormalStats(x,n,'s',avg,std_dev) print *,' ' print *,' Sample mean and standard deviation: ',avg, std_dev print *,' ' ! Test linear regression Call NormalArray(y,n) ! Create a linear relationship with 'noise' Do i=1,n x(i) = i y(i) = 2.*i + 10.*y(i) End Do ! Set a <> zero for full regression analysis a=1. Call LinearReg(x,y,n,'s',a,b,s_yx,corr) print *,' For full regression:' print *,' regression coefficients: ', a, b print *,' standard error of estimate of y on x: ', s_yx print *,' correlation coefficient: ', corr print *,' ' ! Set a = zero for full regression forced through (0,0) a=0. Call LinearReg(x,y,n,'s',a,b,s_yx,corr) print *,' For regression forced through (0,0):' print *,' regression coefficients: ', a, b print *,' standard error of estimate of y on x: ', s_yx print *,' correlation coefficient: ', corr print *,' ' End !end of file tsats.f90