(45) Straight-Line Fitting
|
03-10-2024, 02:26 PM
Post: #2
|
|||
|
|||
RE: (45) Straight-Line Fitting
(01-31-2020 12:34 PM)SlideRule Wrote: If the standard deviations are not required, the sum ∑y² can be omitted, with a saving of six keyboard steps (steps 5, 9, 10, 11, 12, 13 in the previous list). This leaves us with:
But we can do slightly better with:
Registers These registers are used: \( \begin{array}{|c|c|} \hline \text{Register} & \text{Value} \\ \hline 1 & a \\ 2 & b \\ 3 & \sum{y} \\ 5 & n \\ 6 & \sum{x^2} \\ 7 & \sum{x} \\ 8 & \sum{xy} \\ \hline \end{array} \) Formula (01-31-2020 12:34 PM)SlideRule Wrote: It is then a simple task to calculate the slope, intercept, and standard deviations using the well-known least-squares formulas. The following formulas are used to calculate slope \(a\) and intercept \(b\): \( \begin{align} a &= \frac{\sum{xy} - \frac{\sum{x} \sum{y}}{n}}{\sum{x^2} - \frac{\sum{x}^2}{n}} \\ \\ b &= \frac{\sum{y} - a \cdot \sum{x}}{n} \\ \end{align} \) Program These steps calculate both \(a\) and \(b\): Code: # calculate a Example \( \begin{array}{|c|c|c|c|c|c|c|} \hline n & 1 & 2 & 3 & 4 & 5 & 6 \\ \hline C & 40.5 & 38.6 & 37.9 & 36.2 & 35.1 & 34.6 \\ \hline F & 104.5 & 102 & 100 & 97.5 & 95.5 & 94 \\ \hline \end{array} \) Initialise the Registers CLEAR STO 3 Enter the Data 104.5 STO + 3 40.5 × LASTx Σ+ 102 STO + 3 38.6 × LASTx Σ+ 100 STO + 3 37.9 × LASTx Σ+ 97.5 STO + 3 36.2 × LASTx Σ+ 95.5 STO + 3 35.1 × LASTx Σ+ 94 STO + 3 34.6 × LASTx Σ+ Result RCL 1 1.76 RCL 2 33.53 HP-25 The statistics functions also store \(\sum{xy}\). In addition to that it is programmable. Both makes entry of the data and calculating the best fit much easier. Initialise the Registers CLEAR REG Enter the Data 104.5 ENTER 40.5 Σ+ 102 ENTER 38.6 Σ+ 100 ENTER 37.9 Σ+ 97.5 ENTER 36.2 Σ+ 95.5 ENTER 35.1 Σ+ 94 ENTER 34.6 Σ+ Program Code: 01: 24 04 : RCL 4 Data Code: DATA Python Just in case you want to compare the results: Code: C = [40.5, 38.6, 37.9, 36.2, 35.1, 34.6] (1.7601490488333176, 33.52712950250892, 222.9, 593.5, 8306.23, 22093.4, 6) References
|
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(45) Straight-Line Fitting - SlideRule - 01-31-2020, 12:34 PM
RE: (45) Straight-Line Fitting - Thomas Klemm - 03-10-2024 02:26 PM
RE: (45) Straight-Line Fitting - Namir - 03-11-2024, 11:28 AM
|
User(s) browsing this thread: 1 Guest(s)