This program is Copyright © 1976 by Hewlett-Packard and is used here by permission. This program was originally published in the HP-67 Math Pac 1.
This program is supplied without representation or warranty of any kind. Hewlett-Packard Company 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.
Chi-Square Evaluation | |||||
Shift | Oi (Σ+) | Oh (Σ-) | →X22 | →E | |
Label | Start | P? | Oi↑Ei(Σ+) | Ok↑Ek(Σ-) | →X12 |
Key | A | B | C | D | E |
This program calculates the value of the X2 statistic for the goodness of fit test by the equation
X12 = ∑(i=1..n)(Oi - Ei)2/Ei
where
Oi = observed frequency
Ei = expected frequency
If the expected values are equal
(E = Ei = (ΣOi)/n for all i)
then X22 = (nΣOi2)/(ΣOi) - ΣOi
Note: In order to apply the goodness of fit test to a set of given data, combining some classes may be necessary to make sure that each expected frequency is not too small (say, not less than 5).
Reference: Mathematical Statistics. J. E. Freund. Prentice Hall. 1962
Step | Instructions | Input Data/Units | Keys | Output Data/Units |
1 | Load side 1 and side 2. | |||
2 | Initialize | A | 0.00 | |
3 | To set print mode. * | B | 1.00 | |
4 | For equal expected values, go to 10 | |||
5 | Do 6~7 for i = 1,2, ...., n | |||
6 | Input: Oi | Oi | ENTER | |
Ei | Ei | C | i | |
7 | If you made a mistake in inputting Ok and Ek, then correct by → | Ok | ENTER↑ | |
Ek | D | i-1 | ||
8 | Calculate: X12 | E | X12 | |
9 | For a new case, go to 2 | |||
10 | Do 11~12 for i = 1,2, . . ., n | |||
11 | Input: Oi | Oi | f A | i |
12 | If you made a mistake in inputting Oh, then correct by → | Oh | f B | i-1 |
13 | Calculate: X22 | f C | X22 | |
E | f D | E | ||
*Note: to clear print mode press → | CLF 0 |
Find the value of x2 statistic for the goodness of fit for the following data set:
Oi 8 50 47 56 5 14 Ei 9.6 46.75 51.85 54.4 8.25 9.15
X12 = 4.84
Keystrokes Outputs
A 0.00 B 1.00 8 ENTER↑ 9.6 C 8.00 *** 9.60 *** 1.00 *** 50 ENTER↑ 46.75 C 50.00 *** 46.75 *** 2.00 *** 47 ENTER↑ 51.85 C 47.00 *** 51.85 *** 3.00 *** 56 ENTER↑ 54.4 C 56.00 *** 54.40 *** 4.00 *** 5 ENTER↑ 8.25 C 5.00 *** 8.25 *** 5.00 *** 100 ENTER↑ 100 C 100.00 *** (error) 100.00 *** 6.00 *** 100 ENTER↑ 100 D 100.00 *** (correction) 100.00 *** 5.00 *** 14 ENTER↑ 9.15 C 14.00 *** 9.15 *** 6.00 *** E 4.84 *** (X12)
The following table shows the observed frequencies in tossing a die 120 times. X2 can be used to test if the die is fair. Note: Assume that the expected frequencies are equal.
Number 1 2 3 4 5 6 frequency Oi 25 17 15 23 24 16
X22 = 5.00
E = 20.00
Keystrokes Outputs A 0.00 B 1.00 25 f A 25.00 *** 1.00 *** 17 f A 17.00 *** 2.00 *** 19 f A 19.00 *** (error) 3.00 *** 19 f B 19.00 *** (correction) 2.00 *** 15 f A 15.00 *** 3.00 *** 23 f A 23.00 *** 4.00 *** 24 f A 24.00 *** 5.00 *** 16 f A 16.00 *** 6.00 *** f C 5.00 *** (x22) f D 20.00 *** (E)
LINE KEYS 001 *LBL A Initilize 002 CF 0 003 CF 1 004 0 005 STO 1 006 STO 2 007 STO 3 008 RTN 009 *LBL C 010 F0? 011 GSB 9 012 STO 3 Σ + 013 - 014 X2 015 RCL 3 016 ÷ 017 STO + 2 018 RCL 1 019 1 020 + 021 STO 1 022 GSB 8 023 RTN 024 *LBL E 025 F1? 026 GTO 1 X12 027 RCL 2 028 GSB 7 029 GSB 8 030 GSB 7 031 RTN 032 *LBL 1 033 1 034 RCL 1 035 RCL 3 X22 036 × 037 RCL 2 038 ÷ 039 RCL 2 040 - 041 GSB 7 042 GSB 8 043 RTN 044 *LBL d 045 RCL 2 046 RCL 1 047 ÷ 048 GSB 8 049 GSB 7 050 RTN 051 *LBL D For correction Oj, Ej. 052 F0? 053 GSB 9 054 STO 3 055 - 056 X2 057 RCL 3 058 ÷ 059 STO - 2 060 RCL 1 061 1 062 - 063 STO 1 064 GSB 8 065 RTN 066 *LBL a For equal expected frequency. 067 GSB 8 068 STO + 2 069 X2 070 STO + 3 071 RCL 1 072 1 073 + 074 STO 1 075 GSB 8 076 GSB 7 077 SF 1 078 RTN 079 *LBL b 080 GSB 8 For correction Oj. 081 STO - 2 082 X2 083 STO - 3 084 RCL 1 085 1 086 - 087 STO 1 088 GSB 8 089 GSB 7 090 RTN 091 *LBL B Set flag 0 for print. 092 SF 0 093 1 094 RTN 095 *LBL 9 096 PRT SPC Print Oj, Ej. 097 X⇔Y 098 PRTX 099 X⇔Y 100 PRTX 101 RTN 102 *LBL c 103 SF 1 Set flag 1 for equally expected frequency. 104 GTO E 105 RTN 106 *LBL 8 Subroutine for print x. 107 F0? 108 PRTX 109 RTN 110 *LBL 7 111 F0? Subroutine for space. 112 PRT SPC 113 RTN
R1 n R2 Used R3 Used
Go back to the software library
Go back to the main exhibit hall