The Museum of HP Calculators

# Quantiles for the HP-41

This program is by Jean-Marc Baillard and is used here by permission.

This program is supplied without representation or warranty of any kind. Jean-Marc Baillard and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.

## Overview

-This program calculates the median, quartiles, or any other quantile,  by linear interpolation.
-The data are supposed to be grouped like this:

 xi frequencies [ x1 ;  x2 [ n1 [ x2 ;  x3 [ n2 .......... ....... [ xp; xp+1] np

Data Registers:  All the following registers are to be initialized before executing "QTLE"

•  R00:  p   •  R01:   x1       •  R02:   x2  ..........   • Rpp:   xp  •  Rpp+1:    xp+1
•  Rpp+2:   n1  • Rpp+3:   n2  ........  •  R2p+2:    np

Flags:  none

Subroutine:  none

01  LBL "QTLE"
02  STO M
03  RCL 00
04  ENTER^
05  ST+ X
06  1
07  +
08  0
09  LBL 00
10  RCL IND Y
11  +
12  DSE Y
13  DSE Z
14  GTO 00
15  RCL M
16  *
17  0
18  LBL 01
19  ISG Z
20  CL X
21  RCL IND Z
22  +
23  X<Y?
24  GTO 01
25  ST- Y
26  X<> L
27  /
28  X<>Y
29  RCL 00
30  -
31  ENTER^
32  DSE X
33  X<> Z
34  RCL IND Y
35  RCL IND T
36  -
37  *
38  RCL IND Y
39  +
40  0
41  X<> M
42  SIGN
43  CLA
44  END

( 71 bytes / SIZE 2p+2 )

 STACK INPUTS OUTPUTS Y / 1 X r  ( 0 < r < 1 ) quantile L / r

Example:   Find the median Me , the first and last quartile Q1 and Q3 , the first decile d1  and the third centile c3  of the following data:

 x n [ 10 ; 12 [ 1 [ 12 ; 15 [ 3 [ 15 ; 20 [ 7 [ 20 ; 24 [ 4 [ 24 ; 30 [ 2

-There are 5 classes:                  5     STO 00
then we store the 11 numbers  10 ; 12 ; 15 ; 20 ; 24 ; 30 ; 1 ; 3 ; 7 ; 4 ; 2  into registers R01 thru R11 respectively and

.5     XEQ "QTLE"   yields    Me = Q2 = 18.2143
.25        R/S              -----              Q1 = 15.1786
.75        R/S              -----              Q3 = 21.75
.1          R/S              -----               d1 = 12.7
.03        R/S              -----               c3 = 11.02