Why Orthogonal Distance Regression (ODR)? Sometimes one has
measurement errors in the explanatory (a.k.a., “independent”)
variable(s), not just the response (a.k.a., “dependent”) variable(s).
Ordinary Least Squares (OLS) fitting procedures treat the data for
explanatory variables as fixed, i.e., not subject to error of any kind.
Furthermore, OLS procedures require that the response variables be an
explicit function of the explanatory variables; sometimes making the
equation explicit is impractical and/or introduces errors. ODR can
handle both of these cases with ease, and can even reduce to the OLS
case if that is sufficient for the problem.

ODRPACK is a FORTRAN-77 library for performing ODR with possibly
non-linear fitting functions. It uses a modified trust-region
Levenberg-Marquardt-type algorithm [R335] to estimate the function
parameters. The fitting functions are provided by Python functions
operating on NumPy arrays. The required derivatives may be provided
by Python functions as well, or may be estimated numerically. ODRPACK
can do explicit or implicit ODR fits, or it can do OLS. Input and
output variables may be multi-dimensional. Weights can be provided to
account for different variances of the observations, and even
covariances between dimensions of the variables.

The scipy.odr package offers an object-oriented interface to
ODRPACK, in addition to the low-level odr function.

Additional background information about ODRPACK can be found in the
ODRPACK User’s Guide, reading
which is recommended.

deff(B,x):'''Linear function y = m*x + b'''# B is a vector of the parameters.# x is an array of the current x values.# x is in the same format as the x passed to Data or RealData.## Return an array in the same format as y passed to Data or RealData.returnB[0]*x+B[1]