C Library Functions  - median (3)

NAME

median(3f) - [M_datapac:STATISTICS] compute the median of a data vector

CONTENTS

Synopsis
Description
Input Arguments
Output Arguments
Examples
Author
Maintainer
License
References

SYNOPSIS

SUBROUTINE MEDIAN(X,N,Iwrite,Xmed)

       REAL(kind=wp) :: WS , X(:) , Xmed
       INTEGER :: Iwrite , N

DESCRIPTION

MEDIAN(3f) computes the sample median of the data in the input vector X.

The sample median equals that value such that half the data set is below it and half above it.

INPUT ARGUMENTS

X The vector of (unsorted or sorted) observations.
N The integer number of observations in the vector X.
            The maximum allowable value of N for this subroutine is 15000.

IWRITE An integer flag code which (if set to 0) will suppress the printing of the sample median as it is computed; or (if set to some integer value not equal to 0), like, say, 1) will cause the printing of the sample median at the time it is computed.

OUTPUT ARGUMENTS

XMED The value of the computed sample median.

EXAMPLES

Sample program:

   program demo_median
   use M_datapac, only : median, label
   implicit none
   character(len=*),parameter :: g=’(*(g0,1x))’
   real,allocatable :: x(:)
   real :: xmed
   integer :: iwrite , n

call label(’median’) x=[ -10.0, 10.0, 0.0, 1.0, 2.0 ] n=size(x) call median(x, n, 1, xmed) write(*,g)’ median of’,x,’is’,xmed

x=[ 10.0, 20.0, 3.0, 40.0 ] n=size(x) call median(x, n, 1, xmed) write(*,g)’ median of’,x,’is’,xmed

end program demo_median

Results:

   The sample median of the 5 observations is  0.10000000E+01
   median of  -10.00000 10.00000 .000000 1.000000 2.000000 is  1.000000

The sample median of the 4 observations is 0.15000000E+02 median of 10.00000 20.00000 3.000000 40.00000 is 15.00000

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

o Kendall and Stuart, The Advanced Theory of Statistics, Volume 1, Edition 2, 1963, page 326.
o Kendall and Stuart, The Advanced Theory of Statistics, Volume 2, Edition 1, 1961, page 49.
o David, Order Statistics, 1970, page 139.
o Snedecor and Cochran, Statistical Methods, Edition 6, 1967, page 123.
o Dixon and Massey, Introduction to Statistical Analysis, Edition 2, 1957, page 70.


Nemo Release 3.1 median (3) July 22, 2023
Generated by manServer 1.08 from e1774eb6-7471-4308-bea0-21b31c888897 using man macros.