Interpolation is the process to obtain values
from an established graph or table that contain given points.
these values to find or located between these given points.
Extrapolation is the same process, but used to extend
the graph, or find values beyond the given points.
Here is the method for an interpolation:
For any functionf :
x -> f(x)
If we know the values of a and b and their results
f(a) and f(b), we can get the value of any X between
a and b:
F(X) = {[f(a) – f(b)] X + [a f(b) – b f(a)]}/(a - b)
2. The Method of Least Squares
The Method of Least Squares cames from Statistics. It’s the most used method
to find the best fit line which is :
y = m xi + b.
The purpose
of this method, is to minimize the difference between the observed (yi)
and predicted values y and to determine the coefficients : m and b.
The squared quantity: (y-yi)2 may be the "least", that
is the minimum. We express this by:
dSi[(y-yi)2] /dm=0 (1) and
dSi[(y-yi)2] /db=0 (2)
(i runs from 1 to n; where n is a chosen number)
We have:
and
Example:
Here is a prgram in PHP and AJAX that calculates the
slope and the y-intercept for given data.
Enter the values
of xi and their corresponding values yi: