LGNPLT Subroutine

public subroutine LGNPLT(X, N)

NAME

lgnplt(3f) - [M_datapac:LINE_PLOT] generates a lognormal probability
plot

SYNOPSIS

   SUBROUTINE LGNPLT(X,N)

DESCRIPTION

lgnplt(3f) generates a lognormal probability plot.

the prototype lognormal distribution used herein has mean = sqrt(e)
= 1.64872127 and standard deviation = sqrt(e*(e-1)) = 2.16119742.
this distribution is defined for all positive x and has the probability
density function

    f(x) = (1/(x*sqrt(2*pi))) * exp(-log(x)*log(x)/2)

the prototype lognormal distribution used herein is the distribution
of the variate x = exp(z) where the variate z is normally distributed
with mean = 0 and standard deviation = 1.

as used herein, a probability plot for a distribution is a plot
of the ordered observations versus the order statistic medians for
that distribution.

the lognormal probability plot is useful in graphically testing
the composite (that is, location and scale parameters need not be
specified) hypothesis that the underlying distribution from which
the data have been randomly drawn is the lognormal distribution.

if the hypothesis is true, the probability plot should be near-linear.

a measure of such linearity is given by the calculated probability
plot correlation coefficient.

OPTIONS

 X   description of parameter
 Y   description of parameter

EXAMPLES

Sample program:

program demo_lgnplt
use M_datapac, only : lgnplt
implicit none
! call lgnplt(x,y)
end program demo_lgnplt

Results:

AUTHOR

The original DATAPAC library was written by James Filliben of the
Statistical Engineering Division, National Institute of Standards
and Technology.

MAINTAINER

John Urban, 2022.05.31

LICENSE

CC0-1.0

REFERENCES

  • FILLIBEN, ‘TECHNIQUES FOR TAIL LENGTH ANALYSIS’, PROCEEDINGS OF THE EIGHTEENTH CONFERENCE ON THE DESIGN OF EXPERIMENTS IN ARMY RESEARCH DEVELOPMENT AND TESTING (ABERDEEN, MARYLAND, OCTOBER, 1972), pages 425-450.
  • HAHN AND SHAPIRO, STATISTICAL METHODS IN ENGINEERING, 1967, pages 260-308.
  • JOHNSON AND KOTZ, CONTINUOUS UNIVARIATE DISTRIBUTIONS–1, 1970, pages 112-136.
  • CRAMER, MATHEMATICAL METHODS OF STATISTICS, 1946, pages 219-220.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), dimension(:) :: X
integer :: N

Common Blocks

CAUPLT (subroutine)
CHSCDF (subroutine)
CODE (subroutine)
DECOMP (subroutine)
DEMOD (subroutine)
DEXPLT (subroutine)
EV1PLT (subroutine)
EV2PLT (subroutine)
EXPPLT (subroutine)
EXTREM (subroutine)
EXTREM (subroutine)
FREQ (subroutine)
GAMPLT (subroutine)
GEOPLT (subroutine)
HFNPLT (subroutine)
INVXWX (subroutine)
LAMPLT (subroutine)
LOGPLT (subroutine)
MEDIAN (subroutine)
norout (subroutine)
NORPLT (subroutine)
PARPLT (subroutine)
PLOTU (subroutine)
POIPLT (subroutine)
RUNS (subroutine)
SAMPP (subroutine)
SPCORR (subroutine)
TAIL (subroutine)
TPLT (subroutine)
TRIM (subroutine)
UNIPLT (subroutine)
WEIB (subroutine)
WEIPLT (subroutine)
WIND (subroutine)
"> common /BLOCK2_real32/

Type Attributes Name Initial
real :: WS(15000)

Source Code

SUBROUTINE LGNPLT(X,N)
REAL(kind=wp) :: an , cc , hold , q , sum1 , sum2 , sum3 , tau , W , wbar , WS , X , Y , ybar , yint , yslope
INTEGER :: i , iupper , N
!
!     INPUT ARGUMENTS--X      = THE  VECTOR OF
!                                (UNSORTED OR SORTED) OBSERVATIONS.
!                     --N      = THE INTEGER NUMBER OF OBSERVATIONS
!                                IN THE VECTOR X.
!     OUTPUT--A ONE-page LOGNORMAL PROBABILITY PLOT.
!     PRINTING--YES.
!     RESTRICTIONS--THE MAXIMUM ALLOWABLE VALUE OF N
!                   FOR THIS SUBROUTINE IS 7500.

!     ORIGINAL VERSION--JUNE      1972.
!     UPDATED         --SEPTEMBER 1975.
!     UPDATED         --NOVEMBER  1975.
!     UPDATED         --FEBRUARY  1976.
!
!---------------------------------------------------------------------
!
      DIMENSION X(:)
      DIMENSION Y(7500) , W(7500)
      COMMON /BLOCK2_real32/ WS(15000)
      EQUIVALENCE (Y(1),WS(1))
      EQUIVALENCE (W(1),WS(7501))
!
      DATA tau/2.37134890_wp/
!
      iupper = 7500
!
!     CHECK THE INPUT ARGUMENTS FOR ERRORS
!
      IF ( N<1 .OR. N>iupper ) THEN
         WRITE (G_IO,99001) iupper
99001    FORMAT (' ',                                                   &
     &'***** FATAL ERROR--THE SECOND INPUT ARGUMENT TO THE LGNPLT SUBROU&
     &TINE IS OUTSIDE THE ALLOWABLE (1,',I0,') INTERVAL *****')
         WRITE (G_IO,99002) N
99002    FORMAT (' ','***** THE VALUE OF THE ARGUMENT IS ',I0,' *****')
         RETURN
      ELSEIF ( N==1 ) THEN
         WRITE (G_IO,99003)
99003    FORMAT (' ',                                                   &
     &'***** NON-FATAL DIAGNOSTIC--THE SECOND INPUT ARGUMENT TO THE LGNP&
     &LT SUBROUTINE HAS THE VALUE 1 *****')
         RETURN
      ELSE
         hold = X(1)
         DO i = 2 , N
            IF ( X(i)/=hold ) GOTO 50
         ENDDO
         WRITE (G_IO,99004) hold
99004    FORMAT (' ',                                                   &
     &'***** NON-FATAL DIAGNOSTIC--THE FIRST  INPUT ARGUMENT (A VECTOR) &
     &TO THE LGNPLT SUBROUTINE HAS ALL ELEMENTS = ',E15.8,' *****')
!
!-----START POINT-----------------------------------------------------
!
 50      an = N
!
!     SORT THE DATA
!
         CALL SORT(X,N,Y)
!
!     GENERATE UNIFORM ORDER STATISTIC MEDIANS
!
         CALL UNIMED(N,W)
!
!     COMPUTE LOGNORMAL ORDER STATISTIC MEDIANS
!
         DO i = 1 , N
            q = W(i)
            CALL NORPPF(q,q)
            W(i) = EXP(q)
         ENDDO
!
!     PLOT THE ORDERED OBSERVATIONS VERSUS ORDER STATISTICS MEDIANS.
!     WRITE OUT THE TAIL LENGTH MEASURE OF THE DISTRIBUTION
!     AND THE SAMPLE SIZE.
!
         CALL PLOT(Y,W,N)
         WRITE (G_IO,99005) tau , N
!
99005    FORMAT (' ','LOGNORMAL PROBABILITY PLOT (TAU = ',E15.8,')',53X,&
     &           'THE SAMPLE SIZE N = ',I0)
!
!     COMPUTE THE PROBABILITY PLOT CORRELATION COEFFICIENT.
!     COMPUTE LOCATION AND SCALE ESTIMATES
!     FROM THE INTERCEPT AND SLOPE OF THE PROBABILITY PLOT.
!     THEN WRITE THEM OUT.
!
         sum1 = 0.0_wp
         sum2 = 0.0_wp
         DO i = 1 , N
            sum1 = sum1 + Y(i)
            sum2 = sum2 + W(i)
         ENDDO
         ybar = sum1/an
         wbar = sum2/an
         sum1 = 0.0_wp
         sum2 = 0.0_wp
         sum3 = 0.0_wp
         DO i = 1 , N
            sum1 = sum1 + (Y(i)-ybar)*(Y(i)-ybar)
            sum2 = sum2 + (Y(i)-ybar)*(W(i)-wbar)
            sum3 = sum3 + (W(i)-wbar)*(W(i)-wbar)
         ENDDO
         cc = sum2/SQRT(sum3*sum1)
         yslope = sum2/sum3
         yint = ybar - yslope*wbar
         WRITE (G_IO,99006) cc , yint , yslope
99006    FORMAT (' ','PROBABILITY PLOT CORRELATION COEFFICIENT = ',F8.5,&
     &           5X,'ESTIMATED INTERCEPT = ',E15.8,3X,                  &
     &           'ESTIMATED SLOPE = ',E15.8)
      ENDIF
!
END SUBROUTINE LGNPLT