Fitting Functions To Data: Appendix N
Fitting Functions To Data: Appendix N
Fitting Functions To Data: Appendix N
Frequently, you would like to estimate the best values of the coefficients in
an equation from experimental data. The equation might be a theoretical law
or just a polynomial, but the procedure is the same. Let y be the dependent
variable in the equation, bi be the coefficients in the equation, and xi be the
independent variables in the equation so that the model is of the form
Let represent the error between the observation of y, Y, and the predicted
value of y using the values of xi and the estimated values of the coefficients bi:
Y=y+ (N.2)
The classical way to get the best estimates of the coefficients is by least
squares, that is, by minimizing the sum of the squares of the errors (of the
deviations) between Y and y for all the j sets of experimental data, j = 1 to p:
p p
Minimize F = a (Pj)2 = a (Yj - fj)2 (N.3)
j=1 j=1
Let us use a model linear in the coefficients with one independent variable x
y = b0 + b1x (N.4)
924
Appendix N Fitting Functions to Data 925
There are two unknown coefficients, b0 and b1, and p known pairs of experi-
mental values of Yj and xj. We want to minimize F with respect to b0 and b1.
Recall from calculus that you take the first partial derivatives of F and
equate them to zero to get the necessary conditions for a minimum.
p
0F
= 0 = 2 a (Yj - b0 - b1xj)(-1) (N.6a)
0 b0 j=1
p
0F
= 0 = 2 a (Yj - b0 - b1xj)(-xj) (N.6b)
0 b1 j=1
p p p
b0 a xj + b1 a xj2 = a xjYj (N.7b)
j=1 j=1 j=1
The two linear equations above in two unknowns, b0 and b1, can be solved
quite easily for b0 the intercept and b1 the slope.
x Y
0 0
1 2
2 4
3 6
4 8
5 10
(Continues)
AppN.qxd 3/10/12 9:26 PM Page 926
a xj = 15 a xjYj = 110
2
a Yj = 30 a xj = 55
Then
6b0 + 15b1 = 30
15b0 + 55b1 = 110
b0 = 0 b1 = 2
and the model becomes Ŷ = 2x, where Ŷ is the predicted value for a given x.
y = b0 + b1x1 + b2x2
y = b0eb1x + b2x2
1G. E. P. Box, W. G. Hunter, and J. S. Hunter. Statistics for Experimenters. New York: Wiley-
Interscience (1978).
2G. E. P. Box and N. R. Draper. Empirical Model Building and Response Surfaces. New York:
Wiley (1987).