Techniques used in %TILE
FLOOR and CEIL. For an integer, FLOOR and CEIL both return that integer; for a noninteger, FLOOR and CEIL return successive integers that bracket the noninteger.
SORT. The SORT command sorts the list elements into ascending order.
%TILE program listing |
| |
|
|
|
| Program: | Comments: |
|
|
|
| « |
|
| SWAP SORT | Brings the list to level 1 and sorts it. |
| DUP SIZE | Copies the list, then finds its size. |
| 1 + ROT % | Calculates the position of the specified percentile. |
| DUP2 | Makes a copy of the list and the percentile. |
| FLOOR | Rounds the position to the lower integer. |
| 1 MAX OVER SIZE MIN | Ensures it is between 1 and the size of the list. |
| GET | Gets the corresponding number. |
| ROT ROT | Moves the list to level 1. |
| CEIL | Rounds the position to the upper integer. |
| 1 MAX OVER SIZE MIN | Ensures it is between 1 and the size of the list. |
| GET | Gets the corresponding number. |
| + 2 / | Calculates the average of the two numbers. |
| » |
|
|
|
|
| `O%TILE K | Stores the program in %TILE. |
|
| |
|
|
|
Checksum: # 3805d |
| |
Bytes: | 92.5 |
|
Example: Calculate the median of the list {8 3 1 5 2}. !Ä8 3 1 5 2`
J50 %©TILE%
MEDIAN (Median of Statistics Data)
MEDIAN returns a vector containing the medians of the columns of the statistics data. Note that for a sorted list with an odd number of elements, the median is the value of the center element; for a list with an even number of elements, the median is the average value of the elements just above and below the center.
Level 1 | → | Level 1 |
|
|
|
| → | [ x1 x2 xm ] |
|
|
|
RPL Programming Examples