lmfit-py icon indicating copy to clipboard operation
lmfit-py copied to clipboard

[ENH] Confidence Interval improvements

Open Tillsten opened this issue 2 years ago • 3 comments

The CI calculation now uses the root_scalar interface for root finding and changes the default method to toms748. Additonally, caching of probabilties is now used to speed up the calculation.

Description

Improves the CI calculation by using some caching and using another root finding method.

Type of Changes
  • [ ] Bug fix
  • [ ] New feature
  • [x] Refactoring / maintenance
  • [ ] Documentation / examples
Tested on

Python: 3.9.12 (main, Apr 4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)]

lmfit: latest master, scipy: 1.7.1, numpy: 1.20.3, asteval: 0.9.23, uncertainties: 3.1.6

Verification

Have you

  • [ ] included docstrings that follow PEP 257?
  • [ ] referenced existing Issue and/or provided relevant link to mailing list?
  • [x] verified that existing tests pass locally?
  • [x] verified that the documentation builds locally?
  • [x] squashed/minimized your commits and written descriptive commit messages?
  • [x] added or updated existing tests to cover the changes?
  • [ ] updated the documentation and/or added an entry to the release notes (doc/whatsnew.rst)?
  • [ ] added an example?

Tillsten avatar Aug 02 '22 09:08 Tillsten

@Tillsten Thanks very much for this -- I think it looks good. If @reneeotten has no objection, I propose that we merge this.

newville avatar Aug 02 '22 18:08 newville

Sorry, busy days... I'll take a look tonight!

reneeotten avatar Aug 03 '22 12:08 reneeotten

@reneeotten Thanks! And yes, I believe the idea that root_scaler is both the "more recent, supported" root-finding method, and that toms748 is almost always faster (# of function calls) than the brent method.

And I think that break at the test for "has solution converged" is within a for loop, expressing "if a solution is not converged don't bother trying to bracket the uncertainties for the other probabilities".

newville avatar Aug 04 '22 16:08 newville

@reneeotten any objections to merging this?

newville avatar Sep 04 '22 16:09 newville

@Tillsten OK, merging this, thanks!

newville avatar Sep 05 '22 23:09 newville

@reneeotten any objections to merging this?

not really, other than the comments that I left earlier: to squash the commits to remove the flurry of commits including a "merge-commit" and adding an entry to whatsnew.rst indicating this change.

reneeotten avatar Sep 07 '22 02:09 reneeotten