SUBROUTINE LAMPLT(X,N,ALAMBA)
C
C     PURPOSE--THIS SUBROUTINE GENERATES A (TUKEY) LAMBDA DISTRIBUTION
C              PROBABILITY PLOT
C              (WITH TAIL LENGTH PARAMETER VALUE = ALAMBA). 
C              IN GENERAL, THE PROBABILITY DENSITY FUNCTION 
C              FOR THIS DISTRIBUTION IS NOT SIMPLE.
C              THE PERCENT POINT FUNCTION FOR THIS DISTRIBUTION IS
C              G(P) = ((P**ALAMBA)-((1-P)**ALAMBA)) / ALAMBA
C              AS USED HEREIN, A PROBABILITY PLOT FOR A DISTRIBUTION
C              IS A PLOT OF THE ORDERED OBSERVATIONS VERSUS 
C              THE ORDER STATISTIC MEDIANS FOR THAT DISTRIBUTION.
C              THE LAMBDA PROBABILITY PLOT IS USEFUL IN
C              GRAPHICALLY TESTING THE COMPOSITE (THAT IS,
C              LOCATION AND SCALE PARAMETERS NEED NOT BE SPECIFIED)
C              HYPOTHESIS THAT THE UNDERLYING DISTRIBUTION
C              FROM WHICH THE DATA HAVE BEEN RANDOMLY DRAWN 
C              IS THE LAMBDA DISTRIBUTION
C              WITH TAIL LENGTH PARAMETER VALUE = ALAMBA.
C              IF THE HYPOTHESIS IS TRUE, THE PROBABILITY PLOT
C              SHOULD BE NEAR-LINEAR.
C              A MEASURE OF SUCH LINEARITY IS GIVEN BY THE
C              CALCULATED PROBABILITY PLOT CORRELATION COEFFICIENT.
C     INPUT  ARGUMENTS--X      = THE SINGLE PRECISION VECTOR OF
C                                (UNSORTED OR SORTED) OBSERVATIONS.
C                     --N      = THE INTEGER NUMBER OF OBSERVATIONS
C                                IN THE VECTOR X. 
C                     --ALAMBA = THE SINGLE PRECISION VALUE OF LAMBDA 
C                                (THE TAIL LENGTH PARAMETER).
C     OUTPUT--A ONE-PAGE LAMBDA PROBABILITY PLOT. 
C     PRINTING--YES.
C     RESTRICTIONS--THE MAXIMUM ALLOWABLE VALUE OF N
C                   FOR THIS SUBROUTINE IS 7500.
C     OTHER DATAPAC   SUBROUTINES NEEDED--SORT, UNIMED, PLOT.
C     FORTRAN LIBRARY SUBROUTINES NEEDED--SQRT, ALOG.
C     MODE OF INTERNAL OPERATIONS--SINGLE PRECISION.
C     LANGUAGE--ANSI FORTRAN. 
C     REFERENCES--FILLIBEN, 'TECHNIQUES FOR TAIL LENGTH ANALYSIS',
C                 PROCEEDINGS OF THE EIGHTEENTH CONFERENCE
C                 ON THE DESIGN OF EXPERIMENTS IN ARMY RESEARCH
C                 DEVELOPMENT AND TESTING (ABERDEEN, MARYLAND,
C                 OCTOBER, 1972), PAGES 425-450.
C               --HAHN AND SHAPIRO, STATISTICAL METHODS IN ENGINEERING,
C                 1967, PAGES 260-308.
C               --FILLIBEN, SIMPLE AND ROBUST LINEAR ESTIMATION
C                 OF THE LOCATION PARAMETER OF A SYMMETRIC
C                 DISTRIBUTION (UNPUBLISHED PH.D. DISSERTATION,
C                 PRINCETON UNIVERSITY, 1969), PAGES 21-44, 229-231,
C                 PAGES 53-58.
C               --HASTINGS, MOSTELLER, TUKEY, AND WINDSOR,
C                 'LOW MOMENTS FOR SMALL SAMPLES:  A COMPARATIVE
C                 STUDY OF ORDER STATISTICS', ANNALS OF
C                 MATHEMATICAL STATISTICS, 18, 1947,
C                 PAGES 413-426.
C     WRITTEN BY--JAMES J. FILLIBEN
C                 STATISTICAL ENGINEERING LABORATORY (205.03)
C                 NATIONAL BUREAU OF STANDARDS
C                 WASHINGTON, D. C. 20234
C                 PHONE:  301-921-2315
C     ORIGINAL VERSION--JUNE      1972. 
C     UPDATED         --SEPTEMBER 1975. 
C     UPDATED         --NOVEMBER  1975. 
C     UPDATED         --FEBRUARY  1976. 
C
C---------------------------------------------------------------------
C
      DIMENSION X(1)
      DIMENSION Y(7500),W(7500)
      COMMON /BLOCK2/ WS(15000)
      EQUIVALENCE (Y(1),WS(1)),(W(1),WS(7501))
C
      IPR=6
      IUPPER=7500
C
C     CHECK THE INPUT ARGUMENTS FOR ERRORS
C
      IF(N.LT.1.OR.N.GT.IUPPER)GOTO50
      IF(N.EQ.1)GOTO55
      HOLD=X(1)
      DO60I=2,N
      IF(X(I).NE.HOLD)GOTO90
   60 CONTINUE
      WRITE(IPR, 9)HOLD
      GOTO90
   50 WRITE(IPR,17)IUPPER
      WRITE(IPR,47)N
      RETURN
   55 WRITE(IPR,18) 
      RETURN
   90 CONTINUE
    9 FORMAT(1H ,109H***** NON-FATAL DIAGNOSTIC--THE FIRST  INPUT ARGUME
     1NT (A VECTOR) TO THE LAMPLT SUBROUTINE HAS ALL ELEMENTS = ,E15.8,6
     1H *****)
   17 FORMAT(1H , 98H***** FATAL ERROR--THE SECOND INPUT ARGUMENT TO THE
     1 LAMPLT SUBROUTINE IS OUTSIDE THE ALLOWABLE (1,,I6,16H) INTERVAL *
     1****)
   18 FORMAT(1H ,100H***** NON-FATAL DIAGNOSTIC--THE SECOND INPUT ARGUME
     1NT TO THE LAMPLT SUBROUTINE HAS THE VALUE 1 *****)
   47 FORMAT(1H , 35H***** THE VALUE OF THE ARGUMENT IS ,I8   ,6H *****)
C
C-----START POINT-----------------------------------------------------
C
      AN=N
C
C     SORT THE DATA 
C
      CALL SORT(X,N,Y)
C
C     GENERATE UNIFORM ORDER STATISTIC MEDIANS
C
      CALL UNIMED(N,W)
C
C     COMPUTE LAMBDA DISTRIBUTION ORDER STATISTIC MEDIANS
C
      DO100I=1,N
      Q=W(I)
      IF(-0.001.LT.ALAMBA.AND.ALAMBA.LT.0.001)W(I)=ALOG(Q/(1.0-Q))
      IF(-0.001.LT.ALAMBA.AND.ALAMBA.LT.0.001)GOTO100
      W(I)=(Q**ALAMBA-(1.0-Q)**ALAMBA)/ALAMBA
  100 CONTINUE
C
C     PLOT THE ORDERED OBSERVATIONS VERSUS ORDER STATISTICS MEDIANS.
C     COMPUTE THE TAIL LENGTH MEASURE OF THE DISTRIBUTION.
C     WRITE OUT THE TAIL LENGTH MEASURE OF THE DISTRIBUTION 
C     AND THE SAMPLE SIZE.
C
      CALL PLOT(Y,W,N)
      IF(-0.001.LT.ALAMBA.AND.ALAMBA.LT.0.001)TAU=1.63473745
      IF(-0.001.LT.ALAMBA.AND.ALAMBA.LT.0.001)GOTO150
      Q=.9975
      PP9975=(Q**ALAMBA-(1.0-Q)**ALAMBA)/ALAMBA
      Q=.0025
      PP0025=(Q**ALAMBA-(1.0-Q)**ALAMBA)/ALAMBA
      Q=.975
      PP975 =(Q**ALAMBA-(1.0-Q)**ALAMBA)/ALAMBA
      Q=.025
      PP025 =(Q**ALAMBA-(1.0-Q)**ALAMBA)/ALAMBA
      TAU=(PP9975-PP0025)/(PP975-PP025) 
  150 WRITE(IPR,105)ALAMBA,TAU,N
C
C     COMPUTE THE PROBABILITY PLOT CORRELATION COEFFICIENT. 
C     COMPUTE LOCATION AND SCALE ESTIMATES
C     FROM THE INTERCEPT AND SLOPE OF THE PROBABILITY PLOT. 
C     THEN WRITE THEM OUT.
C
      SUM1=0.0
      DO200I=1,N
      SUM1=SUM1+Y(I)
  200 CONTINUE
      YBAR=SUM1/AN
      WBAR=0.0
      SUM1=0.0
      SUM2=0.0
      SUM3=0.0
      DO300I=1,N
      SUM1=SUM1+(Y(I)-YBAR)*(Y(I)-YBAR) 
      SUM2=SUM2+W(I)*Y(I)
      SUM3=SUM3+W(I)*W(I)
  300 CONTINUE
      CC=SUM2/SQRT(SUM3*SUM1) 
      YSLOPE=SUM2/SUM3
      YINT=YBAR-YSLOPE*WBAR
      WRITE(IPR,305)CC,YINT,YSLOPE
C
  105 FORMAT(1H ,38HLAMBDA PROBABILITY PLOT WITH LAMBDA = ,E17.10,1X,7H(
     1TAU = ,E15.8,1H),24X,20HTHE SAMPLE SIZE N = ,I7)
  305 FORMAT(1H ,43HPROBABILITY PLOT CORRELATION COEFFICIENT = ,F8.5,5X,
     122HESTIMATED INTERCEPT = ,E15.8,3X,18HESTIMATED SLOPE = ,E15.8) 
C
      RETURN
      END