HP Forums
Multiple Curve Fitting Program HP-41 - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: Multiple Curve Fitting Program HP-41 (/thread-9911.html)

Pages: 1 2


Multiple Curve Fitting Program HP-41 - Graan - 01-12-2018 05:39 AM

Hello

Just came over the book(pdf): Curve Fitting for Programmable Calculators by William M. Colb. In the book is a multiple curve fitting program for HP-41 that seems interesting. I was thinking to convert it to HP42 code, if possible, and then use it with my DM42. The program is 927 lines however and the pdf is not selectable text so copying the program is not that easy. Guess I could do an OCR.
Anyone has this program in selectable text format?

/Andreas


RE: Multiple Curve Fitting Program HP-41 - Namir - 01-12-2018 07:06 AM

I had contributed to Tom Okken's library a program that uses matrix commands to perform multiple linear regression. Check it out.


RE: Multiple Curve Fitting Program HP-41 - Graan - 01-12-2018 08:48 AM

Hello Namir

Is it under HP-42S/Free42 Programs? I cannot se it there. What's the name? Or is it in the DM42 Calculator?


RE: Multiple Curve Fitting Program HP-41 - Graan - 01-12-2018 01:43 PM

Ok Nice.

Checking the program I find some code I dont recognize (have a 41CX but never used it):
RESZFL
SEEKPTA
FLSIZE
PRAXIS
and some other...
Have to check if there is some equal code in 42S


RE: Multiple Curve Fitting Program HP-41 - Dave Britten - 01-12-2018 03:53 PM

(01-12-2018 01:43 PM)Graan Wrote:  Ok Nice.

Checking the program I find some code I dont recognize (have a 41CX but never used it):
RESZFL
SEEKPTA
FLSIZE
PRAXIS
and some other...
Have to check if there is some equal code in 42S

Those first three would be functions for working with files in extended memory (I'm guessing this program stores the stat data there, rather than just accumulating sums). There's no direct equivalent on the 42S, but you can get similar results by using a matrix to store stat data. There's a program which does this in chapter 6 of HP 42S Programming Examples and Techniques. Combining that with the program in Kolb's book would probably be the simplest approach.


RE: Multiple Curve Fitting Program HP-41 - Thomas Okken - 01-12-2018 04:17 PM

(01-12-2018 08:48 AM)Graan Wrote:  Hello Namir

Is it under HP-42S/Free42 Programs? I cannot se it there. What's the name? Or is it in the DM42 Calculator?

Look for "mlran" (at, yes, http://thomasokken.com/free42/42progs/).


RE: Multiple Curve Fitting Program HP-41 - Thomas Okken - 01-12-2018 04:24 PM

(01-12-2018 01:43 PM)Graan Wrote:  Ok Nice.

Checking the program I find some code I dont recognize (have a 41CX but never used it):
RESZFL
SEEKPTA
FLSIZE
PRAXIS
and some other...
Have to check if there is some equal code in 42S

PRAXIS is a command for the HP-82143A and HP-82162A printers. It prints an axis, and is used as part of the built-in PRPLOT program. It sounds like the program you're looking at can plot its results; translating that functionality to the HP-42S / Free42 / DM42 is not going to be easy, but plotting programs for the 42S do exist, including the PLOT and DPLOT programs from the HP-42S manual, and the slightly fancier versions plot_thomas and dplot_thomas on my web site.


RE: Multiple Curve Fitting Program HP-41 - Graan - 01-12-2018 04:54 PM

I was just thinking to do some simple curvfit since I use to do it in excel for different sensors like NTC resistors etc. connected to microcontrollers. Namirs program seems quite advance. I just need to analyze say 10 to 15 X Y values.
Looking at Colbs program it seems not that hard to translate to HP42 code.
Im not familiar to curvfit theory just a user.


RE: Multiple Curve Fitting Program HP-41 - Dieter - 01-12-2018 06:04 PM

(01-12-2018 04:54 PM)Graan Wrote:  I was just thinking to do some simple curvfit since I use to do it in excel for different sensors like NTC resistors etc. connected to microcontrollers. Namirs program seems quite advance. I just need to analyze say 10 to 15 X Y values.
Looking at Colbs program it seems not that hard to translate to HP42 code.
Im not familiar to curvfit theory just a user.

Maybe you should now explain what exactly you are looking for. The term "multiple" in your subject line is a bit misleading here.

If you say you have only X and Y-values you are obviously NOT looking for a program that does a multiple (sic!) linear regression. The latter means that the result is a linear combination of multiple independent variables, i.e. y = a + b·x1 + c·x2 + d·x3 + ...

So it looks like you need a program that calculates multiple styles of regression functions, e.g. linear, logarithmic, an exponential or power function, etc. Such a program is included in the HP-41 Standard Applications booklet that comes with the calculator. And it is also listed on this website (but without documentation and instructions).

Dieter


RE: Multiple Curve Fitting Program HP-41 - Graan - 01-13-2018 09:42 AM

Yes thats more what Im looking for.

When working in excel I feed in some measured X and Y values and then select what regression fits the values best. Then I can use the function to get values from different sensors etc.

What I thought however when looking at Kolb's program was that I could feed in X and Y values and the program would select the function with best fit automatically. Is this the case?


RE: Multiple Curve Fitting Program HP-41 - Dieter - 01-13-2018 11:17 AM

(01-13-2018 09:42 AM)Graan Wrote:  Yes thats more what Im looking for.
...
What I thought however when looking at Kolb's program was that I could feed in X and Y values and the program would select the function with best fit automatically. Is this the case?

Of course I can't say anything about the program in the Kolb book, but if you only want to fit an XY-curve with two parameters and choose between a linear, logarithmic, exponential and power fit, and you already have a DM42, why do you think you need a special program? The HP42s (and I suppose DM42 as well) can do this on their own, including the selection of the best fitting model:

Clear the summation registers with CLΣ
For all data pairs: enter Yi ENTER Xi and press Σ+
Press STAT > CFIT > MODL > BEST and see the best-fitting model marked with a "▪"
Of course you can also select a different model if you prefer
Return to the previous menu with EXIT
SLOPE and YINT show the two regression coefficients
CORR shows the correlation coefficient (indicates how well the model fits the data)
FCSTY calculates the y-estimate for a given x
FCSTX calculates the x-estimate for a given y

Example:

Code:
X:  1   3   5   8
Y:  1   5   10  20

CLEAR > CLΣ
 1 ENTER 1  Σ+
 5 ENTER 3  Σ+
10 ENTER 5  Σ+
20 ENTER 8  Σ+

STAT > CFIT > MODL > BEST 
=>  LINF  LOGF  EXPF  PWR▪

So the best fit is a power function.

Code:
EXIT

SLOPE => 1,4367...
YINT  => 1,0073...

CORR  => 0,9999...

So the regression function is  y = 1,007 · x1,437.
And the correlation coefficient shows that this is a very good fit.

Now check how well this model fits the given data:

Code:
1 FCSTY =>  1,007...
3 FCSTY =>  4,883...
5 FCSTY => 10,172...
8 FCSTY => 19,985...

Is this what you are looking for?

Dieter


RE: Multiple Curve Fitting Program HP-41 - SlideRule - 01-13-2018 02:15 PM

Are you familiar with ALSTAT2 Algorithmen der Statistik für Hewlett-Packard HP-41C and the KURV algorithm/program contained in chapter 6 (pgs. 92-107)? Perhaps a member can share this specific content, if it has utility for your purpose(s). You may even be inclined to purchase a personal copy for your continued edification.
[attachment=5557] [attachment=5558]
BEST!
SlideRule


RE: Multiple Curve Fitting Program HP-41 - Graan - 01-13-2018 07:50 PM

Dieter, that looks good. Will try it. Thanks!


RE: Multiple Curve Fitting Program HP-41 - Dieter - 01-14-2018 05:59 PM

(01-14-2018 09:04 AM)Mike (Stgt) Wrote:  I suppose you are fit in theory of your subject you messure. So you do know what correlation theoretically exists for the x and y values of your messured points. In this case you don't need a program that tells you 'for this cloud of points (linear | logarithmic | exponential | power) fits best'.

These were also my thoughts. I assume that – for his particular application – Graan will know what kind of physical relation between his X- and Y-values exists. And maybe this is completely different from the standard models that Excel or the 42s CFIT function offer. In this case one could set up an dedicated program for a special regression function.

Dieter


RE: Multiple Curve Fitting Program HP-41 - Graan - 01-14-2018 08:52 PM

I have used curvfit for adapting signals from sensors to microprocessors. In simplest case a linear position potentiometer giving position readouts and also tried fitting non linear values from a NTC resistor giving temperature readouts. So its not anything special. I used excel for this trying different models.
Getting my DM42 I just wanted to see if I can do a curvefit on the calculator. Its nothing I have to do, but just of interest. Dieter pointed out the built in functions for curvfit in HP42S.

In Excel there is polynomial curvfit. I have used it some times. I dont know if there is a program for polynomial curvfit for calculators?

Guess I was a bit unclear with my intent. I just found the program by Kolb in a PDF and thought it looked useful, but seems there are other ways as well.


RE: Multiple Curve Fitting Program HP-41 - SlideRule - 01-14-2018 09:26 PM

(01-14-2018 08:52 PM)Graan Wrote:  … I just wanted to see if I can do a curvefit on the calculator … if there is a program for polynomial curvfit for calculators … other ways as well.
You might reference Linear Regression Analysis Using a Programable Pocket Calculator by Paul Evanson (1978) from South Dakota State University for the HP-97 desktop calculator (yes, the title has a typo). This publication might be of some interest/utiltiy, is only 9 pages and has excellent documentation with legible program listing; enjoy.

BEST!
SlideRule


RE: Multiple Curve Fitting Program HP-41 - Dieter - 01-14-2018 09:52 PM

(01-14-2018 08:52 PM)Graan Wrote:  In Excel there is polynomial curvfit. I have used it some times. I dont know if there is a program for polynomial curvfit for calculators?

Most probably, yes. Fitting a k-degree polynomial does not require much more than solving a linear equation system with k+1 unknowns. The 42s can do this with its built-in matrix functions. The program would accumulate all sums of x0 to x2k as well as y·x0 to y·xk, generate a symmetric matrix from this and the rest is trivial.

Dieter


RE: Multiple Curve Fitting Program HP-41 - Graan - 01-15-2018 11:25 AM

Found this Pascal program regarding Akima spline fitting:

http://jean-pierre.moreau.pagesperso-orange.fr/Pascal/akima_pas.txt

Since I do some Pascal programming I will check it out.


RE: Multiple Curve Fitting Program HP-41 - PedroLeiva - 08-21-2019 12:10 AM

(01-12-2018 05:39 AM)Graan Wrote:  Hello

Just came over the book(pdf): Curve Fitting for Programmable Calculators by William M. Colb. In the book is a multiple curve fitting program for HP-41 that seems interesting. I was thinking to convert it to HP42 code, if possible, and then use it with my DM42. The program is 927 lines however and the pdf is not selectable text so copying the program is not that easy. Guess I could do an OCR.
Anyone has this program in selectable text format?

/Andreas

Graan, I also have this PDF and a BASIC version under going for DOS. One independent variable only but 25 alternative fit options, automatic best fit selection. I will like to have this on my HP 35s calculator that accepts unlimited program steps (almost). Maybe you were intersted in some kind of joint effort? I know nothing about HP41C coding. Pedro


RE: Multiple Curve Fitting Program HP-41 - MNH - 12-11-2021 12:25 PM

(01-14-2018 09:26 PM)SlideRule Wrote:  Linear Regression Analysis Using a Programmable Pocket Calculator by Paul Evanson (1978) from South Dakota State University for the HP-97 desktop calculator.

I tried to find this on the school website, but I failed. Can you share a copy with me?