C Library Functions  - rank (3)

NAME

rank(3f) - [M_datapac:SORT] rank a vector of sample observations

CONTENTS

Synopsis
Description
Notes
Input Arguments
Output Arguments
Examples
Author
Maintainer
License
References

SYNOPSIS

SUBROUTINE RANK(X,N,Xr)

       REAL(kind=wp),intent(in)  :: X(:)
       INTEGER,intent(in)        :: N
       REAL(kind=wp),intent(out) :: Xr(:)

DESCRIPTION

RANK(3f) ranks (in ascending order) the N elements of the precision precision vector X, and puts the resulting N ranks into the precision precision vector XR.

RANK(3f) gives the data analyst the ability to (for example) rank the data preliminary to certain distribution-free analyses.

NOTES

The rank of the first element of the vector X will be placed in the first position of the vector XR, the rank of the second element of the vector X will be placed in the second position of the vector XR, etc.

The smallest element in the vector X will have a rank of 1 (unless
ties exist).
  the largest element in the vector X will have a rank of N (unless ties exist).
Although ranks are usually (unless ties exist) integral values from 1 to N, it is to be noted that they are outputted as REAL values in
the vector XR.
  XR is so as to be consistent with the fact that all vector arguments in all other datapac subroutines are REAL; but more importantly, because ties frequently do exist in data sets and so some of the resulting ranks will be non-integral and so the output vector of ranks must necessarily be REAL and not INTEGER.
The input vector X remains unaltered.
Due to conflicting use of labeled common /block2_real64/ by this rank subroutine and the SPCORR (Spearman rank correlation coefficient) subroutine, the vector XS of this rank subroutine has been placed in labeled common /block4_real64/
The first and third arguments in the calling sequence may be identical; that is, an ’in place’ ranking is permitted. The calling sequence call RANK(X,N,X) is valid, if desired.
The sorting algorthm used herein is the binary sort. This algorthim
is extremely fast as the following time trials indicate.
  These time trials were carried out on the UNIVAC 1108 EXEC 8 system at NBS in
August of 1974.
  by way of comparison, the time trial values for the easy-to-program but extremely inefficient bubble sort algorithm have also been included--
Number of random
  Binary sort Bubble sort numbers sorted
n = 10 [char46]002 sec .002 sec
n = 100 [char46]011 sec .045 sec
n = 1000
  [char46]141 sec 4.332 sec
n = 3000
  [char46]476 sec 37.683 sec
n = 10000
  1.887 sec not computed

INPUT ARGUMENTS

X The vector of observations to be ranked.
N The integer number of observations in the vector X. The maximum allowable value of N for this subroutine is 7500.

OUTPUT ARGUMENTS

XR The vector into which the ranks of the X values will be placed (in ascending order)

EXAMPLES

Sample program:

   program demo_rank
   use M_datapac, only : rank
   implicit none
   ! call rank(x,y)
   end program demo_rank

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

o CACM March 1969, page 186 (Binary Sort Algorithm by Richard C. Singleton).
o CACM January 1970, page 54.
o CACM October 1970, page 624.
o JACM January 1961, page 41.


Nemo Release 3.1 rank (3) July 22, 2023
Generated by manServer 1.08 from fe16e91b-7063-46d3-88f0-b4a7be8f5479 using man macros.