Page 18-15
B. If n⋅p is an integer, say k, calculate the mean of the k-th and (k-1) th
ordered observations.
This algorithm can be implemented in the following program typed in RPN
mode (See Chapter 21 for programming information):
« SORT DUP SIZE p X n « n p * k « IF k CEIL k FLOOR - NOT THEN X k
GET X k 1 + GET + 2 / ELSE k 0 RND X SWAP GET END » » »
which we’ll store in variable %TILE (percent-tile). This program requires as
input a value p within 0 and 1, representing the 100p percentile, and a list of
values. The program returns the 100p percentile of the list.
Example 1 - Determine the 27% percentile of the list { 2 1 0 1 3 5 1 2 3 6 7 9}.
In RPN mode, enter 0.27 ` { 2 1 0 1 3 5 1 2 3 6 7 9} ` @%TILE. In ALG
mode, enter %TILE(0.27,{2,1,0,1,3,5,1,2,3,6,7,9}. The result is 1.
The STAT soft menu
All the pre-programmed statistical functions described above are accessible
through a STAT soft menu. The STAT soft menu can be accessed by using, in
RPN mode, the command: 96 MENU
You can create your own program, say @STATm, to activate the STAT soft menu
directly. The contents of this program are simply: « 96 MENU ».
The STAT soft menu contains the following functions:
Pressing the key corresponding to any of these menus provides access to
different functions as described below.
Note: Integer rounding rule, for a non-integer x.yz…, if y ≥ 5, round up to
x+1; if y < 5, round up to x.