oneelkruns@hotm ail.com (Ron Kneusel) writes:
[color=blue]
> 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.[/color]
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 J. Lee wrote:
[color=blue]
> oneelkruns@obvi ous.com (Ron Kneusel) writes:
>[color=green]
>> 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.[/color]
>
> 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.[/color]
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.
Ron Kneusel wrote:[color=blue]
> 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.
>[/color]
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
Ron Kneusel wrote:[color=blue]
> 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.[/color]
On Wed, 14 Jul 2004, Fernando Perez wrote:
[color=blue]
> 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.[/color]
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.
Helmut Jarausch wrote:[color=blue]
> Ron Kneusel wrote:
>[color=green]
>> 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.
>>[/color]
>
> 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" )[/color]
Comment