Sunday, March 19, 2023

HP 12C: An Improved Linear Regression Function (from Curvee RPN-45 SD)

HP 12C:  An Improved Linear Regression Function (from Curvee RPN-45 SD)



Curvee RPN-45 Simulator 


The Curvee RPN-45 from Curvee Software is an excellent app.  The RPN-45 SD app is the Super-45.   The Super-45 is a emulator of the classic HP 45 calculator from 1973 with the following enhancements:


*  The gold shift key becomes a double-shift key (gold/purple)

*  Complex Numbers

*  10 additional registers

*  Days between dates

*  Four solvers: 2 x 2 system of linear equations, 3 x 3 system of linear equations, quadratic equation, cubic equation

*  Expanded statistics including full linear regression analysis


I have purchased one on my iPod Touch (that is an iPhone without the "phone" part) for $1.99 (prices may vary).  There are versions for the iPhone and iPad.  


For more information:  http://cuveesoft.ch/rpn45/en/index.html


The enhanced linear regression (L.R.) function on the Super-45 returns the following calculations to the four-level stack:


T:  covariance

Z:  correlation

Y:  slope

X:  intercept


The relationship between correlation (r) and covariance (cov):


cov(x,y) = r * sx * sy

sx = standard deviation of x-data

sy = standard deviation of y-data


The HP 12C mimics the enhanced L.R. function.   Yes, check out this app!



HP 12C Program:  Enhanced Linear Regression



The results are stored in the following registers:


R7 = intercept

R8 = Slope

R9 = correlation

R.0 = covariance


In addition, I added code to calculate population deviation:  σx in the x-stack, σy in the y-stack.


Step #: Code [ key ]


// linear regression function 

01:  1  [ 1 ]

02:  43, 1  [ x^,r ]

03:  34  [ x<>y ]

04:  44, 9 [ STO 9 ]

05:  43, 48  [ s ]

06:  20  [ × ]

07:  20  [ × ]

08:  44, 48, 0   [ STO  .  0  (decimal point, zero) ]

09:  0  [ 0 ]

10:  43, 2  [ y^, r ]

11:  44, 7  [ STO 7 ]

12:  1   [  1 ]

13:  43, 2  [ y^, r ]

14:  34  [ x<>y ]

15:  33  [ R↓ ]

16:  34  [ x<>y ]

17:  30  [ - ]

18:  44, 8 [ STO 8 ]

19:  45, 48, 0 [  RCL . 0  (decimal point, zero) ]

20:  45, 9  [ RCL 9 ]

21:  45, 8  [ RCL 8 ]

22:  45, 7  [ RCL 7 ]

23:  43, 33, 00 [ GTO 00 ]


// population deviation

24:  45, 1 [ RCL 1 ]

25:  36  [ ENTER ]

26:  36  [ ENTER ]

27:  1  [ 1 ]

28:  30  [ - ]

29:  10  [ ÷ ]

30:  43, 21  [ √ ]

31:  44, 0  [ STO 0 ]

32:  43, 48  [ s ]

33:  45, 0  [ RCL 0 ]

34:  10  [ ÷ ]

35:  34  [ x<>y ]

36:  45, 0  [ RCL 0 ]

37:  10  [ ÷ ]

38:  34  [ x<>y ]

39:  43, 33, 00 [ GTO 00 ]



Example


Fix 6 mode is set.  


Data:

(5.35, 10)

(5,70, 11)

(6.18, 12)

(6.55, 13)

(6.97, 14)

(7.36, 15)


After entering the data points:

[ f ] (PRGM) [ R/S ]

-3.162788 (intercept), [ R↓ ]

2.465287 (slope), [ R↓ ]

0.999396 (correlation, r), [ R↓ ]

1.418000 (covariance)  ( [ R↓ ] to return the stack to it's original configuration )


[ g ] (GTO) 24 [ R/S ]

0.692331 ( σx ) [ x<>y ]

1.707825 ( σy )



Eddie


All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation

  Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation The HP 16C’s #B Function The #B function is the HP 16C’s number of...