User Tools

Site Tools


percentile_pth_percentile_value_of_a_set_.htm
Navigation:  Templates > Guide to all Templates > Additional Libraries and Templates > Statistics Library >====== PERCENTILE (pth percentile value of a set) ====== Previous pageReturn to chapter overviewNext page

PERCENTILE(dataset,percentile)

blk2blue.jpg

PERCENTILE Returns a value that divides an ordered numeric data set into two portions of specified relative size.
dataset The label of a QUEUE with its first component field defined as a REAL.
percentile A numeric constant or variable containing an integer value in the range: 1 >= p <;= 99 .

PERCENTILE computes a value such that at most pth% of the set's values are less than the amount, and at most 100 - pth% of the set's values are greater than the amount. The function operates on the numeric set defined by all the entries in the first component of the designated QUEUE (dataset).

For example, given the data set: [1,2,3,4,5,6], the 50th Percentile value is 3.5.

In general, the PERCENTILE function is only meaningful when the number of elements in the data set is large (ie. greater than 20).

See also:

LOWERQUARTILE

UPPERQUARTILE.

NoteBox.jpg

The passed data set does not have to be sorted. The function copies the passed set. The passed data set is unchanged.

Return DataType:     REAL

Example:

StatSetX   QUEUE,PRE()

X           REAL

          END

PercentileOfX   REAL

DividePoint   REAL(90)

CODE

FREE(StatSetX)                   !free the QUEUE

CLEAR(STADAT:RECORD)             !clear the record buffer

STADAT:Id = STA:Id               !prime the record buffer

STADAT:ItemNumber = 1

SET(STADAT:KeyIdItemNumber,STADAT:KeyIdItemNumber !position file pointer

LOOP                             !load the QUEUE

  NEXT(StatisticsData)           !read next record

  IF ERRORCODE() OR STADAT:Id NOT = STA:Id

    BREAK

  ELSE

    StatSetX:X = STADAT:X         !load the QUEUE buffer

    ADD(StatSetX)                 !add to the QUEUE

  END

END

PercentileOfX = PERCENTILE(StatSetX,DividePoint) !call PERCENTILE

percentile_pth_percentile_value_of_a_set_.htm.txt · Last modified: 2021/04/15 15:57 (external edit)