# HP 50g User Manual Page 571

Graphing calculator.

Examples of calculation of these measures, using lists, are available in Chapter
8.
The median is the value that splits the data set in the middle when the elements
are placed in increasing order. If you have an odd number, n, of ordered
elements, the median of this sample is the value located in position (n+1)/2. If
you have an even number, n, of elements, the median is the average of the
elements located in positions n/2 and (n+1)/2. Although the pre-programmed
statistical features of the calculator do not include the calculation of the median,
it is very easily to write a program to calculate such quantity by working with
lists. For example, if you want to use the data in DAT to find the median, type
the following program in RPN mode (see Chapter 21 for more information on
programming in User RPL language).:
«
nC « RCL
DUP SIZE 2 GET IF 1 > THEN nC COL
SWAP DROP OBJ
1 +
ARRY END OBJ
OBJ
DROP DROP DUP
n «
LIST SORT IF 'n
MOD 2 == 0' THEN DUP 'n/2' EVAL GET SWAP '(n+1)/2' EVAL GET + 2 /
ELSE '(n+1)/2' EVAL GET END "Median"
TAG " " "
Store this program under the name MED. An example of application of this
program is shown next.
Example 2 – To run the program, first you need to prepare your DAT matrix.
Then, enter the number of the column in DAT whose median you want to find,
and press @@MED@@. For the data currently in DAT (entered in an earlier example),
use program MED to show that
.
Median: 2.15
The mode of a sample is better determined from histograms, therefore, we leave
its definition for a later section.
1
n
2
2
s
(
x
x
)
The variance (Var) of the sample is defined as
.
x
i
n
1
i
1
The standard deviation (St Dev) of the sample is just the square root of the
variance, i.e., s
.
x
Page 18-4