Example for fitting data to a straight line
The minimum, or least, square method is a reliable numerical method for fitting data to empirical equations. In this case, the simple straight line with familiar equation is,
$y=mx+b$ Eq. (01)
is the one to be used with the slope $m$ and intercept $b$ as the free parameters. In other words, $m$ and $b$ should be estimated from the given data so that the straight line adjust itself, as much as possible, to the data points.
Important note: If you are new to fitting data any given equation you should be aware that the set of data points, if plotted, should beave linearly. This is, the plotted data points should look as if these wer along a straight line.
The sample data
Let us consider the following set of (x,y) data points as shown in the table below,
Table 1. Sample data for fitting to a straight line |
Basic equations for the minimum (or leasts) square method for fitting to a straight line
If experimental data, as thos shown in Table 1, were to be represented by a straight line given in general form by Eq. (01), then the slope $m$ and intercept $b$ can be estimated by the following formulas,
$m=\dfrac{N\sum (xy)-\sum (x) \sum (y)}{N\sum(x^2) - \left(\sum x\right)^2}$ Eq. (02)
$b=\dfrac{\sum (y) - m\sum (x)}{N}$ Eq. (03)
In Eqs. (02,03) the symbol $\sum$ means summatory. It is expected to have several lines of data so that these have to be summed up as indicated by the formulas.
As may notice, the main difficulty comes from the amount of data. If you were to handle hundreds of points the calculations bay hand and calculator could take very long so that the use of a worksheet is necessary.
Example minimum (or leasts) square method calculations
Table 2. Calculations of products row by row |
Fig. 1 Plot of data points in Table 1. Notice that the data looks very close to what you could call a straight line. |
And from the above calculations we can easily evaluate the summations as,
Any question? Write in the comments and I shall try to help.
No comments:
Post a Comment