DATA FITTING
Engineers occasionally need to fit an equation to discrete data. Since the discrete data points do not exactly fit on any one equation, then the data must be fit to the equation. Each data point can be expressed as the equation (fn) plus an error, ϵn, such that f(xn) = fn + ϵn where n = 1, N. These data should be fit to an equation so that the trend is accurately captured, but the errors are minimized. One starts by picking a function
F(x) = f(x;c1, ..., ck) k≪N
where c1, ..., ck have a linear dependency, so that
F(x) = c1φ1(x) + ... + ckφk(x)
What is a "good" approximation? Let the error associated with the approximation is determined as dn = fn − F(xn;c1, ..., ck) for n = 1, N. The error over the entire range of numbers can be found using norms:
∞ − norm
||d||∞ = max|dn|1 ≤ n ≤ N
1 − norm
||d||1 = N⎲⎳n = 1|dn|
2 − norm
||d||2 = (N⎲⎳n = 1|dn|2)(1)/(2)
The second norm (2-norm) is also known as the least-squares approximation.
The errors should be minimized so then E(ĉ) = ||d||22 = ∑Nn = 1[fn − F(xn;c)]2. Using the dependency and setting the error to zero results in the equation:
− 2N⎲⎳n = 1[Fn − F(xn;c)]φi(xn) = 0 i = 1...k
Using the concept of orthogonality results in the following process for the least squares analysis. Let f(x) valid over the range (a, b) be approximated by a polynomial, p with a degree less than K. Then the discrete orthogonal solution of the error will become:
< f(x) − p(x)1, f(x) − p(x) > = N⎲⎳n = 1[f(xn) − p(xn)]2w(xn)
If the least-squares is weighted (each term multiplied by a different constant), then the equation is:
p(x) = d0P0(x) + ... + dkPk(k)
ant one must minimize E(d) = < f(x) − d0P0(x) − ...dkPk(x), f(x) − d0P0(x) − ... − dkPk(x) > . If Si = < Pi, Pi > for all i = 0, ..., k, then the error will be di = ( < f, Pi > )/(Si) for every i = 0, ..., k.
In practical application, the least-squares can be determined by
- Set P0(x) = 1.
- Compute S0 = < P0, P0 > = ∑Nn = 1w(xn)
- Multiply one term by x to compute a new set of orthogonal coefficients, B0 = ( < xP0(x), P0(x) > )/(S0) = ∑Nn = 1(w(xn)xn)/(S0).
- Using these new coefficients, p1(x) = (x − B0)P0(x) = x − B0
-
For the remainder of the coefficients (j), compute: Sj = < Pj, Pj > = N⎲⎳n = 1[Pj(xn)]2w(xn)Bj = N⎲⎳n = 1xn[Pj(xn)]2(w(xn))/(Sj) *1cmCj = (Sj)/(Sj − 1)
- Construct the function Pj + 1(x) = (x − Bj)Pj(x) − CJPj − 1(x)