HP 48G Linear Regression Best Fit Line

12212021, 08:42 AM
(This post was last modified: 12212021 11:11 PM by Rodger Rosenbaum.)
Post: #41




RE: HP 48G Linear Regression Best Fit Line
Troubleshooting:
Edit: When I ask you what you see, if the X or Y data matrix is on the stack don't bother typing out the whole thing as what you see, just type "X matrix", or "Y matrix". You will be able to tell if it's ok. But for things like the result from executing ORTHO the result should be small enough to type out the whole thing. After you do the "Fit data" in the statistics menu, there are 3 items on the stackjust drop them. Execute LR; what do you see on the stack? It should be error freedrop anything on the stack. Execute ORTH (press the softkey for ORTH); what do you see on the stack? it should be error freeclear the stack. You can run OFIT manually a step at a time. Recall X to the stack by pressing the softkey for the X variable; what do you see? Press the softkey for ORTH; what do you see? Type "DUP" and press enter; what do you see? Type "1." and press enter; what do you see? Type "GET" and press enter; what do you see? Apparently the error will occur when we try to execute "GET", so the contents of the stack here, and just before the "GET", should tell us what the problem is. 

12222021, 02:09 AM
(This post was last modified: 12222021 02:11 AM by MNH.)
Post: #42




RE: HP 48G Linear Regression Best Fit Line
After you do the "Fit data" in the statistics menu, there are 3 items on the stackjust drop them.
Done Execute LR; what do you see on the stack? It should be error freedrop anything on the stack. Intercept: 672.349 Slope: 0.008 Execute ORTH (press the softkey for ORTH); what do you see on the stack? it should be error freeclear the stack. 0.008 672.345 You can run OFIT manually a step at a time. Recall X to the stack by pressing the softkey for the X variable; what do you see? x matrix Press the softkey for ORTH; what do you see? x matrix 0.008 672.345 Type "DUP" and press enter; what do you see? x matrix 0.008 672.345 672.345 Type "1." and press enter; what do you see? x matrix 0.008 672.345 672.345 1.000 Type "GET" and press enter; what do you see? GET Error: Bad Argument Type 0.008 672.345 672.345 1.000 Apparently the error will occur when we try to execute "GET", so the contents of the stack here, and just before the "GET", should tell us what the problem is. 

12222021, 02:19 AM
(This post was last modified: 12222021 06:34 AM by Rodger Rosenbaum.)
Post: #43




RE: HP 48G Linear Regression Best Fit Line
(12222021 02:09 AM)MNH Wrote: After you do the "Fit data" in the statistics menu, there are 3 items on the stackjust drop them. Edit: See the post right after this one. I see a possible problem here. The result from running ORTH should not be two separate values on the stack as you apparently show like this: Level 2: 0.008 Level 1: 672.345 The result should be a 2 row, 1 column matrix like this: [[ 0.008 ] [ 672.345 ]] So, which is the ORTH result, two values or a matrix? (12222021 02:09 AM)MNH Wrote: You can run OFIT manually a step at a time. Recall X to the stack by pressing the softkey for the X variable; what do you see? 

12222021, 02:26 AM
(This post was last modified: 12222021 02:26 AM by Rodger Rosenbaum.)
Post: #44




RE: HP 48G Linear Regression Best Fit Line
I see a problem. I was looking at an earlier version of ORTH when I posted it a while ago.
The ORTH program needs a couple more items at the end: << LR SWAP DROP DUP CORR DUP SIGN 4 ROLLD SQ / SWAP INV  2 / DUP SQ 1 + √ ROT * + DUP ΣX * NEG ΣY + NΣ / { 2. 1. } →ARRY >> Make this change shown in red to ORTH and see if it all works. 

12222021, 09:16 PM
(This post was last modified: 12222021 09:17 PM by MNH.)
Post: #45




RE: HP 48G Linear Regression Best Fit Line
(12212021 12:59 AM)Rodger Rosenbaum Wrote: But it's easy to adjust the offsets to be orthogonal offsets with a few additions to OFIT. Here's the new OFIT: (1) UNROT is not an HP 48G series command (2) The subtraction function generates a  Error: Bad Argument Type 

12222021, 09:25 PM
Post: #46




RE: HP 48G Linear Regression Best Fit Line  
12222021, 09:28 PM
Post: #47




RE: HP 48G Linear Regression Best Fit Line  
12222021, 09:30 PM
Post: #48




RE: HP 48G Linear Regression Best Fit Line
(12222021 09:16 PM)MNH Wrote:(12212021 12:59 AM)Rodger Rosenbaum Wrote: But it's easy to adjust the offsets to be orthogonal offsets with a few additions to OFIT. Here's the new OFIT: Instead of unrot, use ROT ROT. 

12222021, 09:32 PM
(This post was last modified: 12222021 09:46 PM by Rodger Rosenbaum.)
Post: #49




RE: HP 48G Linear Regression Best Fit Line
(12222021 09:28 PM)MNH Wrote:(12212021 08:42 AM)Rodger Rosenbaum Wrote: After you do the "Fit data" in the statistics menu, there are 3 items on the stackjust drop them. As I explained in post #27: "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. " Actually, I checked and just executing LR will fill in the summary statistics, and you will only have 2 things to delete. :) But it's still true that ORTH needs the summary statistics filled in order to work properly. 

12222021, 09:34 PM
(This post was last modified: 12222021 09:53 PM by Rodger Rosenbaum.)
Post: #50




RE: HP 48G Linear Regression Best Fit Line
(12222021 09:25 PM)MNH Wrote:(12222021 02:26 AM)Rodger Rosenbaum Wrote: << LR SWAP DROP DUP CORR DUP SIGN 4 ROLLD SQ / SWAP INV  The subsequent ORTH program as it stands now needs them to be a 2x1 matrix, but rather than doing it in ORTH, you could add "{ 2. 1. } →ARRY" right after the call to ORTH in OFIT. 

12222021, 09:58 PM
(This post was last modified: 12222021 10:06 PM by MNH.)
Post: #51




RE: HP 48G Linear Regression Best Fit Line  
12222021, 10:02 PM
Post: #52




RE: HP 48G Linear Regression Best Fit Line  
12222021, 10:08 PM
Post: #53




RE: HP 48G Linear Regression Best Fit Line
I'm eagerly awaiting your report that it's all working as it should!


12232021, 03:35 AM
Post: #54




RE: HP 48G Linear Regression Best Fit Line
(12222021 10:08 PM)Rodger Rosenbaum Wrote: I'm eagerly awaiting your report that it's all working as it should! OFIT << X ORTH DUP 1 GET ROT ROT * Y  SWAP ATAN COS * 5 RND NEG >> ORTH << LR SWAP DROP DUP CORR DUP SIGN 4 ROLLD SQ / SWAP INV  2 / DUP SQ 1 + √ ROT * + DUP ΣX * NEG ΣY + NΣ / { 2 1 } →ARRY >> All working as it should! Thank you, Rodger! 

12232021, 04:13 AM
Post: #55




RE: HP 48G Linear Regression Best Fit Line
(12232021 03:35 AM)MNH Wrote:(12222021 10:08 PM)Rodger Rosenbaum Wrote: I'm eagerly awaiting your report that it's all working as it should! The HP48 and descendants come through again! I'm glad it all worked outyou'll be the envy of the other guys you work with. :) 

12232021, 12:41 PM
(This post was last modified: 12232021 12:51 PM by MNH.)
Post: #56




RE: HP 48G Linear Regression Best Fit Line
(12232021 04:13 AM)Rodger Rosenbaum Wrote: The HP48 and descendants come through again! I'm glad it all worked outyou'll be the envy of the other guys you work with. :) My next step is to get a direction on the best fit line. I've been scanning the Internet for this. It looks like I'll need to know where the x and yintercepts are in order to get a delta x and a delta y. I can then use tan^1(delta x / delta y) to calculate the azimuth of the line. I have a question unrelated to the above. What does the data on stack level 3 mean? The data is placed on the stack after selecting rightshift, STAT, Fit data..., Linear Fit. 3: '672.34932+0.00832... 2: Correlation: 0.893... 1: Covariance: 94.09017 What's the purpose of the single quotation mark to the left of the first digit on stack level 3? If you view (rightshift, STACK) the data appears as 672.34932+0.00832X. 

12232021, 01:07 PM
Post: #57




RE: HP 48G Linear Regression Best Fit Line
(12232021 12:41 PM)MNH Wrote:(12232021 04:13 AM)Rodger Rosenbaum Wrote: The HP48 and descendants come through again! I'm glad it all worked outyou'll be the envy of the other guys you work with. :) When you execute ORTH the first number (.008321172 for the data we've been testing with) is the slope. The angle the line makes with the x axis is just the atan of the slope. Is your "azimuth" the angle with the y axis? In that case simply calculate atan(1/slope). (12232021 12:41 PM)MNH Wrote: I have a question unrelated to the above. What does the data on stack level 3 mean? The data is placed on the stack after selecting rightshift, STAT, Fit data..., Linear Fit.It's because that thing on the stack is an algebraic object (its type = 9). 

12232021, 04:01 PM
Post: #58




RE: HP 48G Linear Regression Best Fit Line
(12232021 01:07 PM)Rodger Rosenbaum Wrote: When you execute ORTH the first number (.008321172 for the data we've been testing with) is the slope. The angle the line makes with the x axis is just the atan of the slope. Perfect! I get 0.476757033 decimal degrees, which equals 0°28'36". That would be in the first (northeast) quadrant turning clockwise from 0° north. I have to test the slope angle in all 4 quadrants because the angle might be restricted to 0° through 90°. I'm wondering if the slope angle for quadrants 3 (southwest) and 4 (northwest) would be a negative number because the xvalues in those quadrants are negative. Another thing I have to do is get coordinates for both ends of the BFL. Depending on which direction I'm coming from along the line, I need to be able to define the line by entering a coordinate and a direction. In this case our line runs on an azimuth of 0°28'36" (N 0°28'36" E) along the west side of a road. I will need to check the perpendicular offsets from our line to points on the other side of the road. Coordinates will be necessary to do this. 

12232021, 04:32 PM
(This post was last modified: 12232021 04:41 PM by Rodger Rosenbaum.)
Post: #59




RE: HP 48G Linear Regression Best Fit Line
(12232021 04:01 PM)MNH Wrote:(12232021 01:07 PM)Rodger Rosenbaum Wrote: When you execute ORTH the first number (.008321172 for the data we've been testing with) is the slope. The angle the line makes with the x axis is just the atan of the slope. Have a look at this: https://www.chilimath.com/lessons/interm...ceptform/ and also look at this article: https://en.wikipedia.org/wiki/Azimuth In the Wikipedia article a little over halfway down the page under the heading "in Cartography" see: "Remark that the reference axes are swapped relative to the (counterclockwise) mathematical polar coordinate system and that the azimuth is clockwise relative to the north. This is the reason why the X and Y axis in the above formula are swapped. If the azimuth becomes negative, one can always add 360°. " The result from ORTH and OFIT are in the mathematical polar coordinate system. The angle of the line ORTH got for your test data is measured counterclockwise from the positive X axis, so the azimuth you want is atan(1/.008321172) = 89.5232429674 decimal degrees clockwise from north. For coordinates of the end of the BFL, you can pick an arbitrary X1 value near one end of the line and plug it into the formula Y1 = m*X1 + b, where m=.008321172 and b = 672.344948942 Then pick another arbitrary X2 near the other end of the line and plug it in the formula Y2 = m*X2 +b. This will give a couple of coordinates (X1,Y1) and (X2,Y2) in the mathematical rectangular coordinate system. You may need to convert these to the system surveyors use if it's different. It occurs to me that I assumed the data you gave: The actual survey data is PT # Northing Easting Elevation Description 248 29945.480 921.773 0.000 PROP_COR 249 30002.951 922.245 0.000 PROP_COR 250 30006.678 982.237 0.000 PROP_COR 251 30058.926 921.687 0.000 PROP_COR 252 30114.903 923.001 0.000 PROP_COR 253 30119.876 983.350 0.000 PROP_COR 254 30221.977 924.059 0.000 PROP_COR' is in standard mathematical rectangular coordinates, and the results from ORTH and OFIT being in the same system will apply to the system being used by the survey data as far as coordinates go. Plainly, the azimuth will have be derived from the polar coordinate system assumed by ORTH and OFIT. 

12232021, 08:17 PM
(This post was last modified: 12232021 08:23 PM by MNH.)
Post: #60




RE: HP 48G Linear Regression Best Fit Line
Before I study the information in the articles that you gave me the links to, I want to post an edited version of some data output from the office software that I use. Please note that the coordinate data that I previously posted here was watereddown for easier entry. 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. Pt.: 600  Pt.: 601 Dir: N 00°28'36" E Pt.: 601  Pt.: 600 Dir: S 00°28'36" W Pt.: 248 Offset: 0.24655 RT Pt.: 249 Offset: 0.24033 RT Pt.: 251 Offset: 0.78342 LT Pt.: 252 Offset: 0.06476 RT Pt.: 254 Offset: 0.23177 RT 

« Next Oldest  Next Newest »

User(s) browsing this thread: