Post Reply 
HP 48G Linear Regression Best Fit Line
12-24-2021, 01:06 AM (This post was last modified: 12-24-2021 01:08 AM by Rodger Rosenbaum.)
Post: #61
RE: HP 48G Linear Regression Best Fit Line
I've typed in these data:

Pt.--- Northing(y)--Easting(x)

248 1529945.480 521921.773
249 1530002.951 521922.245
251 1530058.926 521921.687
252 1530114.903 521923.001
254 1530221.977 521924.059
600 1529945.482 521921.526
601 1530221.979 521923.827

But I treated Northing as X and Easting as Y. If this done than the offsets will come out the same as the result from the office software. It can certainly be done the other way, but some changes to the OFIT program will be necessary.

These data have more digits and we won't get 8 accurate digits, but we get as many as the office software gives.

Points 600 and 601 must not be included in the ΣDAT matrix but they can be included in the X and Y matrices; then the offsets for those two points will be zero.
Find all posts by this user
Quote this message in a reply
12-24-2021, 10:34 AM
Post: #62
RE: HP 48G Linear Regression Best Fit Line
(12-24-2021 01:06 AM)Rodger Rosenbaum Wrote:  Points 600 and 601 must not be included in the ΣDAT matrix but they can be included in the X and Y matrices; then the offsets for those two points will be zero.

Concerning points 600 and 601. I just wanted to show you what the office software came up with for the end points of the BFL. I have to figure out, using your suggestions, how to calculate the end points of a BFL. I figure I can reverse engineer the method used by the authors of my office software. What do you think?
Find all posts by this user
Quote this message in a reply
12-24-2021, 01:42 PM (This post was last modified: 12-24-2021 02:04 PM by Rodger Rosenbaum.)
Post: #63
RE: HP 48G Linear Regression Best Fit Line
Edit: Have a look at the next post.

If we look at the data set:

Pt.--- Northing(y)--Easting(x)

248 1529945.480 521921.773
249 1530002.951 521922.245
251 1530058.926 521921.687
252 1530114.903 521923.001
254 1530221.977 521924.059
600 1529945.482 521921.526
601 1530221.979 521923.827

Points 600 and 601 are the endpoints of the BFL. Point 600 is near to point 248, and point 601 is near to point 254.

Assume that the the data set with its more digits are typed into ΣDAT (but not points 600 and 601) letting Northing be X and Easting be Y, LR is executed to fill in the summary statistics. Now if we execute ORTH we get:

[[ .008321172 ]
[ 509190.586948 ]]

In order to get point 600, they took the Northing value of point 248 and added .oo2 to it and formed a 1x2 matrix on the stack from it like this:

[[ 1529945.482 1 ]]

Then execute ORTH and the stack looks like this:

2: [[ .008321172 ]
[ 509190.586948 ]]

1: [[ 1529945.482 1 ]]

Then press multiply and get:

1: [[ 521921.526454 ]]

Drop the last two digits and that's the value they got for the Easting, which I'm treating as the Y value.

Or do it this way: type in as the X matrix and store in the X variable (the Northing of points 600 and 601 are included):

[ 1529945.480 1 ]
[ 1530002.951 1 ]
[ 1530058.926 1 ]
[ 1530114.903 1 ]
[ 1530221.977 1 ]
[ 1529945.482 1 ]
[ 1530221.979 1 ]

The last two entries are points 600 and 601, which are points 248 and 254 with .002 added to each.

Now execute X (recall the X matrix), ORTH, * and see:

[[ 521921.526438 ]
[ 521922.004664 ]
[ 521922.470441 ]
[ 521922.936236 ]
[ 521923.827217 ]
[ 521921.526454 ]
[ 521923.827233 ]]

The last two values are the Easting of points 600 and 601 after you round to only 3 digits after the decimal point. They are identical to what the Office software got.

Now type in the Eastings and store as the Y matrix. Execute OFIT and get:

[[ .24655 ]
[ .24033 ]
[ -.78341 ]
[ .06476 ]
[ .23177 ]
[ -.00045 ]
[ -.00023 ]]

The last two values are the orthogonal offsets of points 600 and 601. Since points 600 and 601 are the endpoints of the BFL, they are necessarily ON the BFL and their orthogonal offsets from the BFL should be zero, which they essentially are! :-)
Find all posts by this user
Quote this message in a reply
12-24-2021, 02:07 PM (This post was last modified: 12-24-2021 02:18 PM by Rodger Rosenbaum.)
Post: #64
RE: HP 48G Linear Regression Best Fit Line
Because these data are being used with an orthogonal fit, the slope if you exchange X and Y is just reciprocated; you can type in the Eastings as X and the Northings as Y, and remove the NEG from the end of OFIT and it all works OK. :-)

It's easier than I thought it would be; I just hadn't thought it through. :-)

After typing in everything like that, to check that you typed it all in correctly, execute ORTH; you should get:

[[ 120.175378956 ]
[ -61192171.745 ]]

Now type OFIT (after having removed the NEG at the end) and see:

[[ .24655 ]
[ .24033 ]
[ -.78341 ]
[ .06476 ]
[ .23177 ]
[ -.00045 ]
[ -.00023 ]]
Find all posts by this user
Quote this message in a reply
12-25-2021, 12:49 AM (This post was last modified: 12-25-2021 12:51 AM by MNH.)
Post: #65
RE: HP 48G Linear Regression Best Fit Line
(12-24-2021 01:42 PM)Rodger Rosenbaum Wrote:  In order to get point 600, they took the Northing value of point 248 and added .oo2 to it and formed a 1x2 matrix on the stack from it like this:

[[ 1529945.482 1 ]]

I concur. Looks like the same for point 601.

248 (S. OFFSET BFL) to 600 (S. END BFL):

Dist.: 0.247 Az: 270°27'50"
Δy(N): 0.002 Δx(E): -0.247

254 (N. OFFSET BFL) to 601 (N. END BFL):

Dist.: 0.232 Az: 270°29'38"
Δy(N): 0.002 Δx(E): -0.232
Find all posts by this user
Quote this message in a reply
12-25-2021, 02:26 AM
Post: #66
RE: HP 48G Linear Regression Best Fit Line
(12-19-2021 01:08 AM)Rodger Rosenbaum Wrote:  After you enter the data into ΣDAT you need to get into the statistics menu and execute the "Fit data" function (it's the 3rd function in the list). Doing this will fill in all the summary statistics such as ΣX, ΣY, ΣXY, etc. Without doing this the LR function, and the ORTH program won't work.

How can I store my own data into the summary statistics variables?
Find all posts by this user
Quote this message in a reply
12-25-2021, 02:41 AM
Post: #67
RE: HP 48G Linear Regression Best Fit Line
(12-25-2021 02:26 AM)MNH Wrote:  
(12-19-2021 01:08 AM)Rodger Rosenbaum Wrote:  After you enter the data into ΣDAT you need to get into the statistics menu and execute the "Fit data" function (it's the 3rd function in the list). Doing this will fill in all the summary statistics such as ΣX, ΣY, ΣXY, etc. Without doing this the LR function, and the ORTH program won't work.

How can I store my own data into the summary statistics variables?

As I mentioned earlier, executing LR does the job. Why would you want to do it yourself?

There is a substantial advantage to letting the HP48 do it. When the HP48 does it, the calculations are done using the internal 15 digit arithmetic. If you do it yourself, you will be doing it with 12 digit arithmetic (if you do the calculations on the HP48) and lose substantial accuracy.
Find all posts by this user
Quote this message in a reply
12-25-2021, 03:46 PM
Post: #68
RE: HP 48G Linear Regression Best Fit Line
(12-25-2021 02:41 AM)Rodger Rosenbaum Wrote:  
(12-25-2021 02:26 AM)MNH Wrote:  How can I store my own data into the summary statistics variables?

As I mentioned earlier, executing LR does the job. Why would you want to do it yourself?

There is a substantial advantage to letting the HP48 do it. When the HP48 does it, the calculations are done using the internal 15 digit arithmetic. If you do it yourself, you will be doing it with 12 digit arithmetic (if you do the calculations on the HP48) and lose substantial accuracy.

When I execute LR, I get the y-intercept and slope values on the stack. Don't you mean Fit data..., Linear Fit, [OK]? What if I could write a program that would do that automatically? I'm simply thinking about writing a more user-friendly program. Nothing wrong with that, right? I am curious about the summary statistics variables. Where do they reside in calculator memory?
Find all posts by this user
Quote this message in a reply
12-25-2021, 04:39 PM (This post was last modified: 12-25-2021 04:40 PM by Rodger Rosenbaum.)
Post: #69
RE: HP 48G Linear Regression Best Fit Line
(12-25-2021 03:46 PM)MNH Wrote:  
(12-25-2021 02:41 AM)Rodger Rosenbaum Wrote:  As I mentioned earlier, executing LR does the job. Why would you want to do it yourself?

There is a substantial advantage to letting the HP48 do it. When the HP48 does it, the calculations are done using the internal 15 digit arithmetic. If you do it yourself, you will be doing it with 12 digit arithmetic (if you do the calculations on the HP48) and lose substantial accuracy.

When I execute LR, I get the y-intercept and slope values on the stack. Don't you mean Fit data..., Linear Fit, [OK]? What if I could write a program that would do that automatically? I'm simply thinking about writing a more user-friendly program. Nothing wrong with that, right? I am curious about the summary statistics variables. Where do they reside in calculator memory?

Re-read post #49. Executing LR returns intercept and slope for a least squares fit where the errors are in the Y direction, not in the orthogonal direction. It must calculate the summary statistics to use for the fit.

The summary statistics are stored in built-in variables named ΣDAT, ΣPAR, ΣX, ΣY, ΣX2, ΣY2, ΣXY, NΣ. You can see them all if you bring up the statistics menu and select the 4th item (right after the 3rd item which is "Fit data...") "Summary stats". In that menu item you can check the ones you want to see and press "OK".

I'll work on a program that will do everything after typing in the nx2 matrix of the X and Y values; that much typing can't be avoided.

Merry Christmas. The snow is just starting here in Seattle, a very rare event in the lowlands on Christmas.
Find all posts by this user
Quote this message in a reply
12-25-2021, 04:59 PM
Post: #70
RE: HP 48G Linear Regression Best Fit Line
(12-25-2021 04:39 PM)Rodger Rosenbaum Wrote:  Re-read post #49. Executing LR returns intercept and slope for a least squares fit where the errors are in the Y direction, not in the orthogonal direction. It must calculate the summary statistics to use for the fit.

Thank you for the constant reminders! Merry Christmas to you too! Not the slightest chance of snow here in Orlando!
Find all posts by this user
Quote this message in a reply
12-26-2021, 10:42 AM (This post was last modified: 12-26-2021 11:03 AM by Rodger Rosenbaum.)
Post: #71
RE: HP 48G Linear Regression Best Fit Line
Type in a couple of programs.

Daug, which stands for de-augment. It takes the n x 2 matrix of X and Y data (which will be stored in ΣDAT) as input and splits it into the X matrix and Y matrix, with the Y matrix in stack level 2 and the X matrix in level 1.

Daug:
<< DUP SIZE 2 GET COL- DUP SIZE { 1 } + RDM SWAP >>

Setup, which expects the n x 2 matrix of X and Y data on stack level 1. It stores that matrix in ΣDAT, executes LR, separates it into X and Y matrices, adds a column of 1s to the X matrix and stores them into the X and Y variables. Everything is ready for OFIT to do its job.

Setup:
<< DUP 'ΣDAT' STO LR DROP DROP Daug →COL SWAP DUP
ROT CON 2 COL→ 'X' STO 'Y' STO >>

So, type in the X and Y data as a single n x 2 matrix, but don't store it in ΣDAT--Setup will take care of that. Execute Setup and you're done, ready to do OFIT.
Find all posts by this user
Quote this message in a reply
12-26-2021, 01:16 PM
Post: #72
RE: HP 48G Linear Regression Best Fit Line
(12-26-2021 10:42 AM)Rodger Rosenbaum Wrote:  Type in a couple of programs.

Daug, which stands for de-augment. It takes the n x 2 matrix of X and Y data (which will be stored in ΣDAT) as input and splits it into the X matrix and Y matrix, with the Y matrix in stack level 2 and the X matrix in level 1.

Daug:
<< DUP SIZE 2 GET COL- DUP SIZE { 1 } + RDM SWAP >>

Setup, which expects the n x 2 matrix of X and Y data on stack level 1. It stores that matrix in ΣDAT, executes LR, separates it into X and Y matrices, adds a column of 1s to the X matrix and stores them into the X and Y variables. Everything is ready for OFIT to do its job.

Setup:
<< DUP 'ΣDAT' STO LR DROP DROP Daug →COL SWAP DUP
ROT CON 2 COL→ 'X' STO 'Y' STO >>

So, type in the X and Y data as a single n x 2 matrix, but don't store it in ΣDAT--Setup will take care of that. Execute Setup and you're done, ready to do OFIT.

Thank you! Will try later today.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)