Skip to content

Commit 5995adb

Browse files
committed
update example to odr_fit
1 parent 577143b commit 5995adb

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,26 @@ pip install odrpack
3535
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.
3636

3737
```py
38-
from odrpack import odr
38+
from odrpack import odr_fit
3939
import numpy as np
4040

41-
x = np.array([0.982, 1.998, 4.978, 6.01])
42-
y = np.array([2.7, 7.4, 148.0, 403.0])
41+
xdata = np.array([0.982, 1.998, 4.978, 6.01])
42+
ydata = np.array([2.7, 7.4, 148.0, 403.0])
4343

4444
beta0 = np.array([2.0, 0.5])
45-
lower = np.array([0.0, 0.0])
46-
upper = np.array([10.0, 0.9])
45+
bounds = (np.array([0.0, 0.0]), np.array([10.0, 0.9]))
4746

4847
def f(beta: np.ndarray, x: np.ndarray) -> np.ndarray:
4948
"Model function."
5049
return beta[0] * np.exp(beta[1]*x)
5150

52-
sol = odr(f, beta0, y, x, lower=lower, upper=upper, iprint=1001)
51+
sol = odr_fit(f, xdata, ydata, beta0, bounds=bounds)
5352

5453
print("beta:", sol.beta)
5554
print("delta:", sol.delta)
5655
```
5756

5857
```sh
59-
beta: [1.63337057 0.9 ]
60-
delta: [-0.36885787 -0.31272733 0.02928942 0.11031791]
58+
beta: [1.63336897 0.9 ]
59+
delta: [-0.36885696 -0.31272648 0.02929022 0.11031872]
6160
```

0 commit comments

Comments
 (0)