dexcdf Subroutine

public subroutine dexcdf(X, Cdf)

NAME

dexcdf(3f) - [M_datapac:CUMULATIVE_DISTRIBUTION] compute the double
exponential cumulative distribution function

SYNOPSIS

   SUBROUTINE DEXCDF(X,Cdf)

    real(kind=wp),intent(in)  :: X
    real(kind=wp),intent(out) :: Cdf

DESCRIPTION

DEXCDF(3f) computes the cumulative distribution function value for the
double exponential (Laplace) distribution with mean = 0 and standard
deviation = sqrt(2).

This distribution is defined for all X and has the probability
density function

    f(x) = 0.5*exp(-abs(x))

INPUT ARGUMENTS

X     The REAL value at which the cumulative distribution
      function is to be evaluated.

OUTPUT ARGUMENTS

CDF   The REAL cumulative distribution function value.

EXAMPLES

Sample program:

program demo_dexcdf
!@(#) line plotter graph of cumulative distribution function
use M_datapac, only : dexcdf, plott, label
implicit none
real,allocatable  :: x(:), y(:)
integer           :: i
   call label('dexcdf')
   x=[(real(i),i=-100,100,1)]
   if(allocated(y))deallocate(y)
   allocate(y(size(x)))
   do i=1,size(x)
      call dexcdf(x(i)/10.0,y(i))
   enddo
   call plott(x,y,size(x))
end program demo_dexcdf

Results:

 The following is a plot of Y(I) (vertically) versus X(I) (horizontally)
                   I-----------I-----------I-----------I-----------I
  0.1000000E+03 -                                                  X
  0.9166666E+02 I                                                  X
  0.8333334E+02 I                                                  X
  0.7500000E+02 I                                                  X
  0.6666667E+02 I                                                  X
  0.5833334E+02 I                                                  X
  0.5000000E+02 -                                                  X
  0.4166667E+02 I                                                 XX
  0.3333334E+02 I                                                 X
  0.2500000E+02 I                                               XXX
  0.1666667E+02 I                                           XXXXX
  0.8333336E+01 I                                   X XXXXXXX
  0.0000000E+00 -                  X X X X X X X X X
 -0.8333328E+01 I         XXXXXXX X
 -0.1666666E+02 I     XXXXX
 -0.2499999E+02 I   XXX
 -0.3333333E+02 I   X
 -0.4166666E+02 I  XX
 -0.5000000E+02 -  X
 -0.5833333E+02 I  X
 -0.6666666E+02 I  X
 -0.7500000E+02 I  X
 -0.8333333E+02 I  X
 -0.9166666E+02 I  X
 -0.1000000E+03 -  X
                   I-----------I-----------I-----------I-----------I
            0.2270E-04  0.2500E+00  0.5000E+00  0.7500E+00  0.1000E+01

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

  • Johnson and Kotz, Continuous Univariate Distributions–2, 1970, pages 22-36.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: X
real(kind=wp), intent(out) :: Cdf

Source Code

subroutine dexcdf(X,Cdf)
real(kind=wp),intent(in)  :: X
real(kind=wp),intent(out) :: Cdf
!
!     CHECK THE INPUT ARGUMENTS FOR ERRORS -- NO INPUT ARGUMENT ERRORS POSSIBLE FOR THIS DISTRIBUTION.
!
      if ( X<=0.0_wp ) Cdf = 0.5_wp*exp(X)
      if ( X>0.0_wp ) Cdf = 1.0_wp - (0.5_wp*exp(-X))

end subroutine dexcdf