Least squares fit to a circle

Mike Page Mike at Page-One.Waitrose.com
Tue Mar 23 10:19:01 CET 2010


Hello,

Does anybody have a good suggestion for fitting a circle to a set of
experimental (x,y) data?  The data are measured electrically as a set of
complex numbers and I want to find the centre and radius ([x0, y0, r]) of
the circle that fits the data best in a least squared error sense.
Typically the data spans somewhere between 0.2 and 1.0 radians of arc and is
not very noisy (say 1%).

I have tried using the nonlinear solver fsolve, by defining a loss function:

L = (r^2 - (x-x0)^2 - (y-y0)^2)^2

and finding the vector [r, x0, y0] for which dL/d[r, x0, y0] is zero.  I
have tried both with and without a Jacobian, but find that often the method
fails to converge to a solution (maybe works 8 out of 10 times).

Next I tried the Box method of the Nelder Mead toolbox (I have constraints
since physically, the centre has to be in the ++ quadrant of the complex
plane).  This is better and always converges to a solution.  However, the
solution is not always very good.  I can often fit a better circle by eye.

It may be that the algorithms are converging to a local minimum rather than
the global one, but I don't know a good way to change this behaviour.  I
seem to remember that simulated annealing was a way to solve this problem -
does anybody know anything about that?

So, what I would like to know:

- Is there a better way than fsolve or Nelder Mead for fitting a circle to
the data?
- Is there a way to tune the performance that might give me a better fit?

I can post some code if it helps.

Thanks for any help.

Regards,
Mike.




More information about the users mailing list