Showing posts with label covariance. Show all posts
Showing posts with label covariance. Show all posts

Sunday, March 26, 2023

HP 32S II Statistical Formulas

HP 32S II Statistical Formulas



Statistics Formulas


The 32S II can store formulas for evaluations, including formulas involving stat variables.  


Covariance:

C = r × sx × sy


Root Mean Square Based on X Variable Statistics:

R = SQRT( Σx^2 ÷ n )


Z-Score Based on X Variable Statistics:  

Z = (X - x-bar) ÷ sx


Accessing Stat variables:


r:  [ right shift ]  [ LN ] (L.R.) [ y^x ] (r)

sx:  [ right shift ] [ 1/x ] (s, σ), [ √x ] (sx)

sy:  [ right shift ] [ 1/x ] (s, σ), [ LN ] (sy)

Σx^2:  [ right shift ] [ Σ+ ] (SUMS) [ e^x ] (x)

n:  [ right shift ] [ Σ+ ] (SUMS) [ √x ] (n)

x-bar:  [ right shift ] [ y^x ] (x-bar,y-bar) [ √x ] (x-bar)


Example


Data:  (x, y)

(10.4, 20)

(13.5, 18)

(16.8, 15)

(19.1, 13.9)


Enter statistical data:  y [ENTER] x [ Σ+ ]


Some stats:

x-bar = 14.95

y-bar = 16.725

r = -9.9503133E-1


Covariance:  Solve for C

C = -10.555

Result is stored in C


Root Mean Square:  Solve for R

R = 15.3089842903

Result is stored in R


Z-Score Based on X Variable Statistics:   Solve for Z

X?  15,  Z = 1.31382E-2

X?  17,  Z = 5.38666E-1

Result is stored in Z



Formulas vs. Programs


If we are going to evaluate formulas (that is, solve for the variable left of the equals sign), we could also enter and use programs.   The programs for the above three formulas:


Covariance:

C01  LBL C

C02  r

C03  sx

C04  ×

C05  sy

C06  ×

C07  RTN


Root Mean Square:

R01  LBL R

R02  Σx^2

R03  n

R04  ÷

R05  SQRT

R06  RTN


Z Score:  (x is in the X stack)

Z01  LBL Z

Z02  x-bar

Z03  -

Z04  sx

Z05  ÷

Z06  RTN


Byte Consumption Comparison


Covariance

Formula:  12 bytes

Program:  10.5 bytes


Root Mean Square

Formula:  12 bytes

Program:  9 bytes


Z Score

Formula: 15 bytes

Program:  9 bytes


From sample set, programs are shorter than formulas.  Is this true in general?


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. 


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. 


Earth's Radius by Latitude

Earth's Radius by Latitude Introduction: Calculating the Earth’s Radius In quick, general calculations, we assume that the...