https://github.com/hugomvale/odrpack-python
Python bindings for the modernized version of odrpack95.
https://github.com/hugomvale/odrpack-python
mathematics regression statistics
Last synced: 5 months ago
JSON representation
Python bindings for the modernized version of odrpack95.
- Host: GitHub
- URL: https://github.com/hugomvale/odrpack-python
- Owner: HugoMVale
- License: mit
- Created: 2025-01-03T14:36:40.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-09-05T21:15:16.000Z (10 months ago)
- Last Synced: 2025-09-25T08:34:38.957Z (9 months ago)
- Topics: mathematics, regression, statistics
- Language: Python
- Homepage: https://hugomvale.github.io/odrpack-python/
- Size: 459 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# odrpack (-python)
[](https://github.com/HugoMVale/odrpack-python/actions)
[](https://codecov.io/gh/HugoMVale/odrpack-python)
[](https://img.shields.io/github/last-commit/HugoMVale/odrpack-python)

[](https://deepwiki.com/HugoMVale/odrpack-python)
## Description
This Python package provides bindings for the well-known weighted orthogonal distance regression
(ODR) solver [odrpack95]. This design ensures that users benefit from the performance and reliability
of the original Fortran implementation, while working within the modern Python ecosystem.
ODR, also known as [errors-in-variables regression], is designed primarily for instances when both
the explanatory and response variables have significant errors.
[errors-in-variables regression]: https://en.wikipedia.org/wiki/Errors-in-variables_models
[odrpack95]: https://github.com/HugoMVale/odrpack95
## Installation
You can install the package via pip:
```sh
pip install odrpack
```
## Documentation and Usage
The following example demonstrates a simple use of the package. For more comprehensive examples and explanations, please refer to the [documentation](https://hugomvale.github.io/odrpack-python/) pages.
```py
from odrpack import odr_fit
import numpy as np
xdata = np.array([0.982, 1.998, 4.978, 6.01])
ydata = np.array([2.7, 7.4, 148.0, 403.0])
beta0 = np.array([2.0, 0.5])
bounds = (np.array([0.0, 0.0]), np.array([10.0, 0.9]))
def f(x: np.ndarray, beta: np.ndarray) -> np.ndarray:
"Model function."
return beta[0] * np.exp(beta[1]*x)
sol = odr_fit(f, xdata, ydata, beta0, bounds=bounds)
print("beta:", sol.beta)
print("delta:", sol.delta)
```
```sh
beta: [1.63336897 0.9 ]
delta: [-0.36885696 -0.31272648 0.02929022 0.11031872]
```