Using external minimizers
We show how to use an external minimizer to find the minimum of a function and then use iminuit to compute the parameter uncertainties.
We will demonstrate this with a maximum-likelihood fit of a normal distribution, which is carried out with scipy.optimize.minimize. iminuit is then used to compute the parameter uncertainties.
fun: 1405.1044194490182
hess_inv: array([[ 9.11426039e-04, -4.57424334e-05],
[-4.57424334e-05, 4.68208132e-04]])
jac: array([0., 0.])
message: 'Optimization terminated successfully.'
nfev: 45
nit: 12
njev: 15
status: 0
success: True
x: array([-0.05425323, 0.98626113])
|
Name |
Value |
Hesse Error |
Minos Error- |
Minos Error+ |
Limit- |
Limit+ |
Fixed |
0 |
x0 |
-0.054 |
0.031 |
|
|
|
|
|
1 |
x1 |
0.986 |
0.022 |
|
|
|
|
|
|
x0 |
x1 |
x0 |
0.000973 |
6.92e-08 |
x1 |
6.92e-08 |
0.000486 |
We can also compute the “Hesse errors” at any other point than the minimum. These cannot be interpreted as parameter uncertainties, they are just some numbers related to the second derivative of the cost function at that point.
|
Name |
Value |
Hesse Error |
Minos Error- |
Minos Error+ |
Limit- |
Limit+ |
Fixed |
0 |
x0 |
1.000 |
0.031 |
|
|
|
|
|
1 |
x1 |
0.500 |
0.006 |
|
|
|
|
|
|
x0 |
x1 |
x0 |
0.000963 |
0.000169 (0.861) |
x1 |
0.000169 (0.861) |
4.01e-05 |
Likewise, it one can also run MINOS to get MINOS estimates. Note that MINOS can fail if the starting point is not actually a minimum. So here we reset the values to the solution found by scipy.optimize.
|
Name |
Value |
Hesse Error |
Minos Error- |
Minos Error+ |
Limit- |
Limit+ |
Fixed |
0 |
x0 |
-0.054 |
0.031 |
-0.031 |
0.031 |
|
|
|
1 |
x1 |
0.986 |
0.022 |
-0.022 |
0.022 |
|
|
|
|
x0 |
x1 |
Error |
-0.031 |
0.031 |
-0.022 |
0.022 |
Valid |
True |
True |
True |
True |
At Limit |
False |
False |
False |
False |
Max FCN |
False |
False |
False |
False |
New Min |
False |
False |
False |
False |
|
x0 |
x1 |
x0 |
0.000973 |
0 |
x1 |
0 |
0.000486 |
We can see that MINOS ran successfully. The Hesse Errors were also updated, because MINOS needs HESSE to run first. HESSE is called automatically in this case.