1 / 19

HP-41C Regression Program Generator

HP-41C Regression Program Generator. Presented by Namir Shammas. William Kolb’s Book. Kolb published a book in 1982 titled Curve Fitting for Programmable Calculators. Aimed at HP-41C programmers. Presented a wide and comprehensive set of regression models.

emery
Télécharger la présentation

HP-41C Regression Program Generator

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. HP-41C Regression Program Generator Presented by NamirShammas

  2. William Kolb’s Book Kolb published a book in 1982 titled Curve Fitting for Programmable Calculators. Aimed at HP-41C programmers. Presented a wide and comprehensive set of regression models. Used a special register-numbering scheme to store statistical summations for different variables and different transformations. Scheme allowed to select best curve fit without re-entering or reprocessing input data.

  3. William Kolb’s Book (cont.) Presented equations to calculate regression coefficients in terms of memory registers. I was interested in the programs that did basic multiple regression for two and three independent variables. Did not want to adhere by Kolb’s register numbering scheme. Decide to write an Excel application and have the VBA code write documented HP-41C programs for multiple regression. The Excel application would support user-defined register indices for the statistical summations. Also supports linear and polynomial curve fitting models.

  4. Typical Worksheet

  5. App Worksheets App that generates HP-41C regression programs uses a consistent and simple interface for the different regression models. Column A lists the names of statistical summations, variables used to store intermediate results, coefficients of determination (R2), adjusted R2, input values, and transformed input values. Column B contains the new register indices for the names in column A

  6. App Worksheets (cont.) Cell D1 contains the regression model supported by that worksheet. Cell D2 store the name of the output file. You are welcome to change that filename as you see fit. Cell D3 allows you to specify whether or not to include comments in the HP-41C listing. Excluding comments makes it easier to compile the listing’s text to create a .raw file that run on certain HP-41C emulators.

  7. App Worksheets (cont.) Linear regression set: LR worksheet handles general linear regression. Label 00 allows you to include your own custom transformations for the variables. LR2 worksheet handles special regression model using the model Y^yp = a + b*X^xp. The values for the powers can be positive, negative (as long as they do not generate runtime errors), and zero (which is translated as taking the natural logarithm). LR3 worksheet handles a power fit.

  8. App Worksheets (cont.) Multiple linear regression set for two independent variables: MLR2 worksheet handles general multiple linear regression. Label 00 allows you to include your own custom transformations for the variables. MLR22 worksheet handles special regression model using the model Z^zp = a + b*X^xp + c*Y^yp. MLR23 worksheet handles a multiple power fit.

  9. App Worksheets (cont.) Multiple linear regression set for three independent variables: MLR3 worksheet handles general multiple linear regression. Label 00 allows you to include your own custom transformations for the variables. MLR32 worksheet handles special regression model using the model T^tp = a + b*X^xp + c*Y^yp + d*Z^zp. MLR33 worksheet handles a multiple power fit.

  10. App Worksheets (cont.) Polynomial regression set for two variables: Poly2 worksheet handles quadratic regression. The VBA code for this worksheet is based on that of MLR2. Poly3 worksheet handles cubic regression. The VBA code for this worksheet is based on that of MLR3.

  11. Notes of the VBA Code The various Make41Prgm_xxx subroutines contain HP-41C meta-code programs stored as strings of comma-delimited commands. The subroutines use multiple statements to build the meta-code before translating it into readable HP-41C statements. The subroutines builds an array of records, each storing the name of a program variable, its new register index, and the register index that appeared in Kolb’s book. I have added a few records with my own version of the “Kolb indices” since I needed a complete list of variables that appear in the final HP-41C programs

  12. Notes of the VBA Code The subroutines use variable Listing to build the HP-41C meta-code. The intended HP-41C statements are separated by commas. The meta-code uses the letters, s, s+, s-, s*, s/, r, and a as abbreviations for STO, ST+, ST-, ST*, ST/, RCL, and ARCL statements. These abbreviations trigger the register index mapping and shorten the length of the internal HP-41C program listing. In many cases, the VBA source code uses the register indices that appear in Kolb’s book. I have added registers when necessary.

  13. Notes of the VBA Code If you want to store and recall values using or in a stack register, you must enter their commands as they appear in the generated HP-41C program. You can insert a comment that must start with # in a separate string that appears, after the meta-code that you intent to comment. This comment must appear as a separate comma-delimited meta-command.

  14. Notes of the VBA Code The alpha strings start with a single quote. A closing single quote is optional. The VBA program will enclose alpha strings in double quote. You can use the characters |- followed by a single quote to append text. A closing single quote is optional. Labels, GTO, and XEQ statements that use alphanumeric label names must have these names begin with a single quote. A closing single quote is optional. All other HP-41C commands must appear as in their normal name and syntax.

  15. User Interface Press [f][A] to clear all registers. In the case of programs generated by subroutines Make41Prgm_LR2, Make41Prgm_MLR22, and Make41Prgm_MLR32, the HP-41C programs prompt you for the powers used to raise the regression variables. The power of zero is interpreted as a request to calculate the natural logarithm. Press [A] to add the values for an observation point. The program will prompt you to enter the values for the observations.

  16. User Interface Press [B] to delete the values for an observation point. The program will prompt you to enter the values for the observations to be deleted. If you want to delete the last observation you entered in step 2, just press [f][B] to perform this task without re-entering data. The HP-41C programs use flag 00 to make sure that pressing the keys [f][B] delete the last input data only once.

  17. User Interface Press [C] to perform the statistical calculations and view the regression coefficients, the coefficient of determination (R2), and its adjusted value. Press [f][C] to review the results in step 4.

  18. Output Regression model (as it appears in worksheet). Memory map (as it appears in worksheet). HP-41C listing.

  19. Thank You!

More Related