470,643 Members | 1,371 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,643 developers. It's quick & easy.

Ellipse fitting in python?

Is there a python package out there that supports fitting a set of 2D
points to an ellipse? I haven't been able to find one.

Thanks!

Ron
Jul 18 '05 #1
6 6402
on********@hotmail.com (Ron Kneusel) writes:
Is there a python package out there that supports fitting a set of 2D
points to an ellipse? I haven't been able to find one.


This is a set of points with some noise (scatter), right?

A not-very-thoughtful answer: a sledgehammer method is to throw an
implementation of a standard nonlinear least-squares algorithm at the
problem. For example, SciPy contains a wrapper of MINPACK's nonlinear
LS solver . There are several implementations of the same
(Levenburg-Marquardt) algorithm in pure Python floating around, too.

If there's no scatter, it's time to dig out your old algebra textbooks
:-)
John
Jul 18 '05 #2
John J. Lee wrote:
on********@obvious.com (Ron Kneusel) writes:
Is there a python package out there that supports fitting a set of 2D
points to an ellipse? I haven't been able to find one.


This is a set of points with some noise (scatter), right?

A not-very-thoughtful answer: a sledgehammer method is to throw an
implementation of a standard nonlinear least-squares algorithm at the
problem. For example, SciPy contains a wrapper of MINPACK's nonlinear
LS solver . There are several implementations of the same
(Levenburg-Marquardt) algorithm in pure Python floating around, too.


A quick comment in case it's not obvious: an ellipse is not a function in
Cartesian coordinates, and most standard LS solvers expect a function. So
it's probably best to convert things over to polar before feeding the data to
the LS solver.

f
Jul 18 '05 #3
Ron Kneusel wrote:
Is there a python package out there that supports fitting a set of 2D
points to an ellipse? I haven't been able to find one.


It's not so easy; it's a nonlinear orthogonal distance regression problem.
I know of a FORTRAN package and I myself have a (more general) package written
in Scilab ( a Matlab "clone" )

If you have just a few datasets, I'll compute a fit for you.
But implementing it in Python would be much work.
--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
Jul 18 '05 #4
Aloha,

Ron Kneusel wrote:
Is there a python package out there that supports fitting a set of 2D
points to an ellipse? I haven't been able to find one.


See http://www.magic-software.com/Approximation.html
Here are C++ Sources, you will need a interface like SWIG for using this
in python.

Wishing a happy day
LOBI
Jul 18 '05 #5
On Wed, 14 Jul 2004, Fernando Perez wrote:
A quick comment in case it's not obvious: an ellipse is not a function in
Cartesian coordinates, and most standard LS solvers expect a function. So
it's probably best to convert things over to polar before feeding the data to
the LS solver.


You could break both the ellipse and the data into two pieces (say, y>=K
and y<K). Polar coordinates might get you more uniform results, though.

Jul 18 '05 #6
Helmut Jarausch wrote:
Ron Kneusel wrote:
Is there a python package out there that supports fitting a set of 2D
points to an ellipse? I haven't been able to find one.

It's not so easy; it's a nonlinear orthogonal distance regression problem.
I know of a FORTRAN package and I myself have a (more general) package
written
in Scilab ( a Matlab "clone" )


I wrote a wrapper to the FORTRAN ODRPACK.

http://starship.python.net/crew/kern...odr-0.6.tar.gz
If you have just a few datasets, I'll compute a fit for you.
But implementing it in Python would be much work.

Jul 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Grant Edwards | last post: by
5 posts views Thread by lgeastwood | last post: by
11 posts views Thread by Christopher Ireland | last post: by
2 posts views Thread by weird0 | last post: by
3 posts views Thread by illusion.admins | last post: by
8 posts views Thread by =?Utf-8?B?RGFu?= | last post: by
reply views Thread by =?Utf-8?B?UGFua2FqR2F1cg==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.