Metadata-Version: 2.1
Name: odrpack
Version: 0.5.0
Summary: Package for weighted orthogonal distance regression (ODR).
Keywords: regression,statistics,mathematics
Author-Email: Hugo Vale <57530119+HugoMVale@users.noreply.github.com>
License: MIT License
         
         Copyright (c) 2025 HugoMVale
         
         Permission is hereby granted, free of charge, to any person obtaining a copy
         of this software and associated documentation files (the "Software"), to deal
         in the Software without restriction, including without limitation the rights
         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the Software is
         furnished to do so, subject to the following conditions:
         
         The above copyright notice and this permission notice shall be included in all
         copies or substantial portions of the Software.
         
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         SOFTWARE.
         
Classifier: Development Status :: 1 - Planning
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering
Project-URL: Repository, https://github.com/HugoMVale/odrpack-python
Project-URL: Documentation, https://hugomvale.github.io/odrpack-python/
Requires-Python: >=3.10
Requires-Dist: numpy>=1.24
Description-Content-Type: text/markdown

# odrpack (-python)

[![Test-Linux](https://github.com/HugoMVale/odrpack-python/actions/workflows/test-linux.yml/badge.svg)](https://github.com/HugoMVale/odrpack-python/actions)
[![codecov](https://codecov.io/gh/HugoMVale/odrpack-python/graph/badge.svg?token=B9sFyJiweC)](https://codecov.io/gh/HugoMVale/odrpack-python)
[![Latest Commit](https://img.shields.io/github/last-commit/HugoMVale/odrpack-python)](https://img.shields.io/github/last-commit/HugoMVale/odrpack-python)
![PyPI - Downloads](https://img.shields.io/pypi/dm/odrpack?label=PyPI%20downloads)
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](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.

<p align="center">
  <img src="https://github.com/HugoMVale/odrpack-python/blob/main/docs/odr.png" width="250" alt="Deming regression; special case of ODR." style="margin-right: 10px;">
</p>

[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 = [0.982, 1.998, 4.978, 6.01]
ydata = [2.7, 7.4, 148.0, 403.0]

beta0 = [2.0, 0.5]
bounds = ([0.0, 0.0], [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]
```
