Stat4P - J E Patterson

Description

Stat4P.15c - jepspectro.com - J E Patterson - version 20180609

hp-15c Program Index and documentation

This program provides linear, logarithmic, power and exponential regressions with a single entry of a data set.
An option to invert x data, when entered, is included.
After r is displayed you can enter x' for an estimated y'. Repeat for more values of x'.

This program is an adaptation of software I wrote for a personal computer in 1984. For most statistical work a personal computer is best, but this program is good for a first look at experimental data.

Entered numbers should be positive and greater than 0. Enter 1 EEX 9 CHS, or lower, if zero is required. For linear regressions the built-in function can be used if a wider number range is required.

The most recent data pair can be deleted with GSB 7. The statistics counter n is also decremented by 1.

Introduction:

GSB 0 - zero registers and clear flag 1.
If there is an obvious inverse relationship between x and y press GSB 8 which sets flag 1 to 1. This inverts any x data entered.
y ENTER x GSB A
Repeat to enter more data.

GSB B for linear regression
GSB C for logarithmic regression
GSB D for power regression
GSB E for exponential regression
in each case b is shown
R/S for a
R/S for r
x' R/S displays a y' estimate.
GSB B, C, D, and E can be repeated at any time without entering new data.


Example:

y = 2, 4, 5, 6
x = 2, 5, 8, 13

GSB 0 to clear registers
2 ENTER 2 GSB A
4 ENTER 5 GSB A
5 ENTER 8 GSB A
6 ENTER 13 GSB A

GSB B
Linear regression y = ax+b
b = 1.8106
R/S a = 0.3485
R/S r = 0.9571

GSB C
Logarithmic regression y = a ln(x) + b
b = 0.5318
R/S a = 2.1409
R/S r = 0.9999

GSB D
Power regression y = xa * b
b = 1.4005
R/S a = 0.5950
R/S r = 0.9870

GSB E
Exponential regression y = eax * b
b = 2.0563
R/S a = 0.0928
R/S r = 0.9048

Clearly a logarithmic fit to the data is reasonable because the correlation coefficient r is closest to 1.
Once r is displayed x' can be entered to estimate y'.

5 R/S displays 3.9774 as the y' estimate instead of the original y entry of 4.
Repeat for more values of x'. This applies for all regression models.
Note that even with r = 0.9999 the fit is not quite perfect. To 6 places r = 0.999911.
It is easy to compare different regression models. Just press any label from B to E as often as required to show b, a and r, and then enter x' to estimate y'.

Test data sets

Linear y = ax+b
x = 1, 2, 3, 4
y = 7, 9, 11, 13
b = 5.0000
a = 2.0000
r = 1.0000
3 R/S displays 11.0000


Logarithmic y = a ln(x) + b
x = 1, 2, 3, 4
y = 5, 6.3863, 7.1972, 7.7726
b = 5.0000
a = 2.0000
r = 1.0000
3 R/S displays 7.1972.


Power y = xa * b
x = 1, 2, 3, 4
y = 5, 20, 45, 80
b = 5.0000
a = 2.0000
r = 1.0000
3 R/S displays 45.0000.


Exponential y = eax * b
x = 1, 2, 3, 4
y = 36.9453, 272.9908, 2017.1440, 14904.7899
b = 5.0000
a = 2.0000
r = 1.0000
3 R/S displays 2017.1442.

Program Resources

Labels

Name Description Name Description
 A Data Entry, y ENTER x.  2 Power or exponential regression subroutine
 B Linear regression y = ax + b  3 Linear, estimate y' from x' loop
 C Logarithmic regression y = a ln(x) + b  4 Logarithmic, estimate y' from x' loop
 D Power regression y = x^a * b  5 Power, estimate y' from x' loop
 E Exponential regression y = e^ax * b  6 Exponential, estimate y' from x' loop
 0 Initialise - zero registers, set flag 1 to zero  7 Delete most recent data pair and decrement n by 1
 1 Linear or logarithmic regression subroutine  8 Set flag 1 to 1

Storage Registers

Name Description Name Description Name Description
 0 ∑x  7 ∑xy" copied from appropriate registers .4 ∑(lnx)^2
 1 ∑x^2  8 ∑y .5 ∑lny
 2 n  9 ∑y^2 .6 ∑(lny)^2
 3 ∑x" copied from appropriate registers .0 Temporary x and b storage .7 ∑((lnx) * (Lny))
 4 ∑x^2" copied from appropriate registers .1 Temporary y and a storage .8 ∑(x * lny)
 5 ∑y" copied from appropriate registers .2 ∑xy .9 ∑(lnx *y)
 6 ∑y^2" copied from appropriate registers .3 ∑lnx

Flags

Number Description
1

Program

Line Display Key Sequence Line Display Key Sequence Line Display Key Sequence
000 070 40 + 140 42 49 f L.R.
001 42,21, 0 f LBL 0 071 22 3 GTO 3 141 44 .0 STO . 0
002 42 34 f REG 072 43 32 g RTN 142 31 R/S
003 43, 5, 1 g CF 1 073 42,21,13 f LBL C 143 34 x↔y
004 43 35 g CLx 074 45 .3 RCL . 3 144 44 .1 STO . 1
005 43 32 g RTN 075 44 3 STO 3 145 31 R/S
006 42,21,11 f LBL A 076 45 .4 RCL . 4 146 1 1
007 43, 6, 1 g F? 1 077 44 4 STO 4 147 42 48 f ŷ,r
008 15 1/x 078 45 8 RCL 8 148 34 x↔y
009 44 .0 STO . 0 079 44 5 STO 5 149 43 32 g RTN
010 34 x↔y 080 45 9 RCL 9 150 42,21, 2 f LBL 2
011 44 .1 STO . 1 081 44 6 STO 6 151 42 49 f L.R.
012 44,40, 8 STO + 8 082 45 .9 RCL . 9 152 12
013 43 11 g 083 44 7 STO 7 153 44 .0 STO . 0
014 44,40, 9 STO + 9 084 32 1 GSB 1 154 31 R/S
015 11 √x̅ 085 42,21, 4 f LBL 4 155 34 x↔y
016 43 12 g LN 086 31 R/S 156 44 .1 STO . 1
017 44,40, .5 STO + . 5 087 43 12 g LN 157 31 R/S
018 43 11 g 088 45 .1 RCL . 1 158 1 1
019 44,40, .6 STO + . 6 089 20 × 159 42 48 f ŷ,r
020 45 .0 RCL . 0 090 45 .0 RCL . 0 160 34 x↔y
021 44,40, 0 STO + 0 091 40 + 161 43 32 g RTN
022 43 11 g 092 22 4 GTO 4 162 42,21, 7 f LBL 7
023 44,40, 1 STO + 1 093 43 32 g RTN 163 45 .1 RCL . 1
024 11 √x̅ 094 42,21,14 f LBL D 164 44,30, 8 STO 8
025 43 12 g LN 095 45 .3 RCL . 3 165 43 11 g
026 44,40, .3 STO + . 3 096 44 3 STO 3 166 44,30, 9 STO 9
027 43 11 g 097 45 .5 RCL . 5 167 11 √x̅
028 44,40, .4 STO + . 4 098 44 5 STO 5 168 43 12 g LN
029 45 .0 RCL . 0 099 45 .4 RCL . 4 169 44,30, .5 STO . 5
030 45 .1 RCL . 1 100 44 4 STO 4 170 43 11 g
031 20 × 101 45 .6 RCL . 6 171 44,30, .6 STO . 6
032 44,40, .2 STO + . 2 102 44 6 STO 6 172 45 .0 RCL . 0
033 45 .0 RCL . 0 103 45 .7 RCL . 7 173 44,30, 0 STO 0
034 45 .1 RCL . 1 104 44 7 STO 7 174 43 11 g
035 43 12 g LN 105 32 2 GSB 2 175 44,30, 1 STO 1
036 20 × 106 42,21, 5 f LBL 5 176 11 √x̅
037 44,40, .8 STO + . 8 107 31 R/S 177 43 12 g LN
038 45 .0 RCL . 0 108 45 .1 RCL . 1 178 44,30, .3 STO . 3
039 43 12 g LN 109 14 179 43 11 g
040 45 .1 RCL . 1 110 45 .0 RCL . 0 180 44,30, .4 STO . 4
041 20 × 111 20 × 181 45 .0 RCL . 0
042 44,40, .9 STO + . 9 112 22 5 GTO 5 182 45 .1 RCL . 1
043 45 .0 RCL . 0 113 43 32 g RTN 183 20 ×
044 43 12 g LN 114 42,21,15 f LBL E 184 44,30, .2 STO . 2
045 45 .1 RCL . 1 115 45 0 RCL 0 185 45 .0 RCL . 0
046 43 12 g LN 116 44 3 STO 3 186 45 .1 RCL . 1
047 20 × 117 45 .5 RCL . 5 187 43 12 g LN
048 44,40, .7 STO + . 7 118 44 5 STO 5 188 20 ×
049 1 1 119 45 1 RCL 1 189 44,30, .8 STO . 8
050 44,40, 2 STO + 2 120 44 4 STO 4 190 45 .0 RCL . 0
051 45 2 RCL 2 121 45 .6 RCL . 6 191 43 12 g LN
052 43 32 g RTN 122 44 6 STO 6 192 45 .1 RCL . 1
053 42,21,12 f LBL B 123 45 .8 RCL . 8 193 20 ×
054 45 0 RCL 0 124 44 7 STO 7 194 44,30, .9 STO . 9
055 44 3 STO 3 125 32 2 GSB 2 195 45 .0 RCL . 0
056 45 8 RCL 8 126 42,21, 6 f LBL 6 196 43 12 g LN
057 44 5 STO 5 127 31 R/S 197 45 .1 RCL . 1
058 45 1 RCL 1 128 45 .1 RCL . 1 198 43 12 g LN
059 44 4 STO 4 129 20 × 199 20 ×
060 45 9 RCL 9 130 12 200 44,30, .7 STO . 7
061 44 6 STO 6 131 45 .0 RCL . 0 201 1 1
062 45 .2 RCL . 2 132 20 × 202 44,30, 2 STO 2
063 44 7 STO 7 133 22 6 GTO 6 203 45 2 RCL 2
064 32 1 GSB 1 134 43 32 g RTN 204 43 32 g RTN
065 42,21, 3 f LBL 3 135 42,21, 0 f LBL 0 205 42,21, 8 f LBL 8
066 31 R/S 136 42 34 f REG 206 43, 4, 1 g SF 1
067 45 .1 RCL . 1 137 43 35 g CLx 207 43 32 g RTN
068 20 × 138 43 32 g RTN
069 45 .0 RCL . 0 139 42,21, 1 f LBL 1