(71B) Quantum Shammas Polynomials for curve fitting (#2)
|
01-11-2024, 11:41 AM
Post: #1
|
|||
|
|||
(71B) Quantum Shammas Polynomials for curve fitting (#2)
The Quantum Shammas Polynomial Curve Fitting for the HP-71B (#2)
Note: This presentation is part of a small series of related topics about curve fitting with quasi-polynomials with the HP-71B calculator. I have often posted in the Not remotely HP Calculators comments section about using various types of quasi-polynomials with non-integer powers. Recently I introduced the term polyterms to define these polynomials more formally. I use MATLAB code in my web site when I present results for using these polyterms. Well, I am glad to share here an HP-71B program for one of these polyterms. A Quantum Shammas Polynomial has a general form of: Pn(x) = a0 + a1*x^p(1) + a2*x^p(2) + ... + an*x^p(n) Where p(i) = i-1+r(i), with r(i) is a random number in the range of (0.6, 1.3). This range is not set in stone and can be fine-tuned by the user. Each r(i) is different. Choosing values for each r(i) in an arbitrary way and expecting excellent results is a pipe dream! Thus, fitting data with the above equation requires optimization to find the best values of for each r(i). The BASIC code listing below performs the calculations for the Quantum Shammas Polynomials. I coded the program so that it uses labels instead of line numbers in branching. The program uses a MATH ROM. The program works much faster with the Windows version of the HP-71B simulator (for which the MATH ROM is easy found and installed) with the Authentic Calculator Speed option checked off (found in the File => Settings menu). Notice the following program segments: 1) Line 30 has a READ statement that reads the number of data points (N), the order of the polynomials (M), and the maximum number of iterations for the random search (K9). Line 40 has a DATA statement that supplies the values for the three inputs. You can edit the values to suite your own case that you are studying, or alter the operational parameters for the example in the listing. 2) The label 'GETDATA' calculates the values for arrays X and Y. The current code is set to calculate each Y(I) as LOG(X(I))/SQR(X(I)). You need to edit the assignment statement in line 370 for Y(I) to reflect the function you want to fit. Also edit line 360 to set the sampling of array X, Alternatively, you can replace the statements after label 'GETDATA' with READ and DATA statements to supply values for arrays X and Y. Replace line 370 with: 370 READ X(I),Y(I) And delete line 380. You need to insert an adequate number of DATA statements, say after line 650. 3) The label 'CALC' calculates the regression coefficients and adjusted coefficient of determination for the Shammas Polynomial and the regular polynomial. You need not change the code in this segment. The BASIC code shown below is ready to run as a demo program. Remember that since it uses random numbers the results will vary each time you run the program. Once you have performed any edits, you run the program by pressing the [RUN] key. The program performs the following: 1) Displays intermediate results which shows the iteration number and current adjusted coefficient of determination and a message that a better point was found. The program uses the WAIT command to auto-resume excution. 2) The final results start to appear when the program displays "SHAMMAS POLYNOMIAL". The sequence of output is: 2.1) The program displays the value of the adjusted coefficient of determination: R2ADJ= .974727628685 2.2) Press [f][+] to resume the program. The program displays the constant term: C0=-.608423568928 2.3) Press [f][+] to resume the program. The program displays the coefficient for the first term: C1= .856937996154 2.4) Press [f][+] to resume the program. The program displays the power for the first term: *X^.60894732893 2.5) Repeat steps 2.3 and 2.4 for the other terms to obtain the following LCD output: C2=-8.35985156185E-2 *X^1.65694731315 C3= 3.87567991994E-3 *X^2.62744974863 2.6) Press [f][+] to resume the program. The program displays "REGULAR POLYNOMIAL" before displaying the results for the regular polynomial regression. 2.7) The program displays the value of the adjusted coefficient of determination: R2ADJ= .950314751473 2.8) Press [f][+] to resume the program. The program displays the constant term: C0=-9.10950919331E-2 2.9 Press [f][+] to resume the program. The program displays the coefficient for the first term: C1= .363826983255 2.10) Press [f][+] to resume the program. The program displays the power for the first term: *X^1 2.11) Repeat steps 2.09 and 2.10 for the other terms to obtain the following LCD output: C2=-5.05940470771E-2 *X^2 C3= 2.23138815699E-3 *X^3 2.12) The program stops after displaying the last output. The adjusted coefficient of determination of the Quantum Shammas Polynomial is higher than that of the regular polynomial. Keep in mind since the program uses random search optimization, the results will be different each time you run the program. Here is the program listing. Code: 10 REM QUANTUM SHAMMAS POLYNOMIALS VER 1 |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(71B) Quantum Shammas Polynomials for curve fitting (#2) - Namir - 01-11-2024 11:41 AM
|
User(s) browsing this thread: 1 Guest(s)