# scipy.odr.odrpack¶

Python wrappers for Orthogonal Distance Regression (ODRPACK).

## Classes¶

Data – stores the data and weights to fit against

RealData – stores data with standard deviations and covariance matrices

Model – stores the model and its related information

Output – stores all of the output from an ODR run

ODR – collects all data and runs the fitting routine

## Exceptions¶

odr_error – error sometimes raised inside odr() and can be raised in the
fitting functions to tell ODRPACK to halt the procedure
odr_stop – error to raise in fitting functions to tell ODRPACK that the data or
parameters given are invalid

## Use¶

Basic use:

1) Define the function you want to fit against.

```def f(B, x):
''' Linear function y = m*x + b '''
return B*x + B

# B is a vector of the parameters.
# x is an array of the current x values.
# x is same format as the x passed to Data or RealData.

# Return an array in the same format as y passed to Data or RealData.
```

2) Create a Model.

```linear = Model(f)
```

3) Create a Data or RealData instance.

```mydata = Data(x, y, wd=1./power(sx,2), we=1./power(sy,2))
```

or

```mydata = RealData(x, y, sx=sx, sy=sy)
```

4) Instantiate ODR with your data, model and initial parameter estimate.

```myodr = ODR(mydata, linear, beta0=[1., 2.])
```

5) Run the fit.

```myoutput = myodr.run()
```

6) Examine output.

```myoutput.pprint()
```

Read the docstrings and the accompanying tests for more advanced usage.

## Credits¶

• Thanks to Arnold Moene and Gerard Vermeulen for fixing some killer bugs.

Robert Kern robert.kern@gmail.com

Functions

 odr(fcn, beta0, y, x[, we, wd, fjacb, ...]) report_error(info) Interprets the return code of the odr routine.

Classes

 Data(x[, y, we, wd, fix, meta]) The Data class stores the data to fit. Model(fcn[, fjacb, fjacd, extra_args, ...]) The Model class stores information about the function you wish to fit. ODR(data, model[, beta0, delta0, ifixb, ...]) The ODR class gathers all information and coordinates the running of the Output(output) The Output class stores the output of an ODR run. RealData(x[, y, sx, sy, covx, covy, fix, meta]) The RealData class stores the weightings as actual standard deviations

Exceptions

 odr_error odr_stop