Open maxnoe opened 3 years ago
My main argument is that we should teach people tools that are simple to use for simple things, but which also scale to complex scenarios when the need arises later.
curve_fit
is great but limited to non-linear least-squares. It does not generalize like iminuit
, which can be used with least-squares cost functions and maximum likelihood, further with robust least-squares, etc. By learning iminuit
, even if you we do not teach the advanced functionality, we already point people to a tool they will likely use again later and that is able to grow with their needs. curve_fit
cannot do that.
iminuit.utils.propagate
vs. uncertainties
: The popular uncertainties
package is similarly a dead end. It works for simple stuff, but it does not scale to complex situations. uncertainties
is invasive, it requires you to replace ordinary numpy arrays with its own special arrays. You cannot pass these arrays to code that expects numpy arrays, for example, a C++ function that you wrapped to Python with pybind11. uncertainties
behind the scenes introduces couplings between arrays that appear to be separate. This goes against a fundamental design principle that objects in object oriented programming should behave independently from each other. Violating this principle makes the code difficult to reason about. All these problems do not exist for iminuit.utils.propagate
. It works with any function that accepts and returns numpy arrays (whether plain Python, numba-jitted, or implemented in C++ and wrapped to Python) and it keeps the values (a vector) and their covariance matrix (a matrix) as two separate objects. It is not invasive since it does not require you to change your code at all. It is also quite natural to use the parameter vector and the covariance matrix as separate objects, since that is what you get from fitting tools, be it curve_fit
or iminuit
.
Brought up by @hdembinski in the E5 chat, we should evaluate if we want to switch from teaching the curve_fit / uncertainties combination to using
iminuit
(iminuit.utils.propagate
for uncertainty propagation).