Ellipse Fitting
At the July 21, 1999 meeting of the Celestial Mechanics Study Group,
Gerry Sussman gave
the problem of fitting an ellipse to a set of data points as an example of an
application of the method of least squares.
More specifically, the problem is to fit an ellipse centered at the
origin with axes coincident with the Cartesian axes to a set of
points {(xi ,
yi)}, i = 1, 2,
. . . , n.
Such an ellipse can be described by an equation of the form
where a and b are the lengths of the semiaxes of
the ellipse in the x and y directions, respectively.
If we define
|
|
fa,b(x , y)
= 1 - |
x2
a2 |
- |
y2
b2 |
|
|
we want to find the values of a and b which
minimize
By setting the partial derivatives of χ2 with respect to
a and b to zero, it can be shown that the a
and b which minimize χ2 solve the system of two
simultaneous equations
|
|
(Σ
xi2)a2b2
- (Σ
xi2yi2)a2
- (Σ
xi4)b2
= 0 |
|
|
and
|
|
(Σ
yi2)a2b2
- (Σ
yi4)a2
- (Σ
xi2yi2)b2
= 0 |
|
|
The solution to the above system of equations is
|
|
a2 = |
(Σ
xi2yi2)2
- (Σ xi4)(Σ
yi4)
(Σ
xi2yi2)(Σ
yi2) - (Σ
xi2)(Σ
yi4) |
|
|
|
|
b2 = |
(Σ
xi2yi2)2
- (Σ xi4)(Σ
yi4)
(Σ
xi2)(Σ
xi2yi2)
- (Σ
xi4)(Σ
yi2) |
|
|