HP 49g+ User Manual

Page 571

Advertising
background image

Page 18-4

(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.

Measures of spread

The variance (Var) of the sample is defined as

=

=

n

i

i

x

x

x

n

s

1

2

2

)

(

1

1

.


The standard deviation (St Dev) of the sample is just the square root of the
variance, i.e., s

x

.


The range of the sample is the difference between the maximum and minimum
values of the sample. Since the calculator, through the pre-programmed
statistical functions provides the maximum and minimum values of the sample,
you can easily calculate the range.

Advertising
This manual is related to the following products: