[SciPy-dev] Module Submission: Orthogonal Distance Regression
Robert Kern
kern at caltech.edu
Tue Nov 19 00:28:55 CST 2002
Some time ago, I wrote an extension module to use ODRPACK, a FORTRAN
library that performs Orthogonal Distance Regression (ODR) as well as
non-linear Ordinary Least-Squares (OLS) and implicit regression (fitting
to, say, an ellipse).
ODRPACK is very flexible. It can handle multi-dimensional input
and output variables, weighted observations (with correlations between
dimensions). It solves the ODR problem, i.e. finding "parameter
estimates that minimize the sum of the squares of the weighted
orthogonal distances between each observed data point and the curve
described by a nonlinear equation" [1] as well as the nonlinear OLS
problem, where uncertainties on the input variables are assumed to be
negligible. Further, the model equation can be implicit, e.g.
x0^2+x1^2-r^2 = 0 will fit the data to a circle and estimate the radius.
ODRPACK will estimate the uncertainties and covariances of the estimated
parameters. ODRPACK has a flexible reporting system to generate reports
on all stages of the computation.
SciPy issues:
I have wrapped the base extension module in a set of classes to
facilitate the handling of all the options. These classes model my use
of the module: fitting experimental data and fiddling on the interactive
interpreter to get it right. Perhaps this is leads to a cumbersome API,
or another needs to be exposed in addition.
I believe I have followed the SciPy style guide except for the classes,
which are MixedCase.
I think the docstrings are pretty thorough, but I might need to write a
tutorial to get people jump-started.
Tests: I have tests based on ODRPACK's FORTRAN examples and some of my
own data. They are not in unittest form yet, nor do they completely
cover all features. ODRPACK comes with a comprehensive FORTRAN testsuite
which could be converted to Python, but it will be a fair bit of work.
I use Numeric's LinearAlgebra to do a matrix inversion. If adopted into
SciPy, that would change to scipy.inv .
Availability:
http://starship.python.net/crew/kernr/source/odr-0.6.tar.gz
License:
Public Domain
References:
[1] http://www.boulder.nist.gov/mcsd/Staff/JRogers/odrpack.html
ODRPACK comes from http://www.netlib.org/odrpack/index.html and is
public domain.
--
Robert Kern
Ruddock House President
kern at caltech.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
More information about the Scipy-dev
mailing list