## Saturday, June 3, 2017

### HP 20S and HP 21S: Simple Logistic Regression

HP 20S and HP 21S:  Simple Logistic Regression

This program attempts to fit a simple logistic curve of data (X, Y) to the equation:

y = 1/(A + B*e^(-x))

By the following transformations:

X’ = e^(-X)
Y’ = 1/Y

And performing linear regression analysis on X’ and Y’.   Note that the data point which includes Y = 0 is not allowed.

The keystrokes for the HP 20S and HP 21S are slightly different.  Each program will be shown separately.

Input:
Initialize the data:  XEQ A
For each data point:  x, [INPUT], y, XEQ B
Calculate the parameters:  XEQ C.  B is shown first, then A.

HP 20S Program: Simple Logistic Regression

 STEP CODE KEY 01 61, 41, A LBL A 02 61, 75 CLRΣ 03 61, 26 RTN 04 61, 41, B LBL B 05 15 1/X 06 51, 31 SWAP 07 32 +/- 08 12 e^x 09 51, 31 SWAP 10 16 Σ+ 11 61, 26 RTN 12 61, 41, C LBL C 13 61, 16 m, b 14 26 R/S 15 51, 31 SWAP 16 61, 26 RTN

HP 21S Program: Simple Logistic Regression

 STEP CODE KEY 01 61, 41, A LBL A 02 61, 75 CLRΣ 03 61, 26 RTN 04 61, 41, B LBL B 05 15 1/X 06 51, 31 SWAP 07 32 +/- 08 12 e^x 09 51, 31 SWAP 10 16 Σ+ 11 61, 26 RTN 12 61, 41, C LBL C 13 51, 14 m, b 14 26 R/S 15 51, 31 SWAP 16 61, 26 RTN

Like the last post (minimum and maximum), this is one of my favorite programs I have done this year.  I think the Wheatstone circuit would also make the list.

Eddie

This blog is property of Edward Shore, 2017

1. 2. 