Commit graph

122 commits

Author SHA1 Message Date
s-kuberski
68e4633ae0
[Feat] Number of fit parameters can be explicitly passed to the fit functions (#269) 2025-10-09 13:14:17 +02:00
s-kuberski
5f5438b563
[Feat] Introduce checks of the provided inverse matrix for correlated fits (#259)
Co-authored-by: Simon Kuberski <simon.kuberski@cern.ch>
2025-02-19 18:15:55 +01:00
s-kuberski
6ed6ce6113
[fix] Corrected an error message (#257)
Co-authored-by: Simon Kuberski <simon.kuberski@cern.ch>
2025-02-13 19:43:56 +01:00
s-kuberski
4b1bb0872a
fix: corrected bug that prevented combined fits with multiple x-obs in some cases (#241)
* fix: corrected bug that prevented combined fits with multiple x-obs in some cases

* made test more complex

* [Fix] Slightly increase tolerance for matrix function test.

* Adapt test_merge_idx to compare lists

---------

Co-authored-by: Simon Kuberski <simon.kuberski@cern.ch>
Co-authored-by: Fabian Joswig <fjosw@users.noreply.github.com>
2024-09-13 19:15:59 +02:00
Pia Leonie Jones Petrak
1d6f7f65c0
Feature/corr matrix and inverse cov matrix as input in least squares function for correlated fits (#223)
* feat: corr_matrix kwargs as input for least squares fit

* feat/tests: inverse covariance matrix and correlation matrix kwargs as input for least squares function

* feat/tests/example: reduced new kwargs to 'inv_chol_cov_matrix' and outsourced the inversion & cholesky decomposition of the covariance matrix (function 'invert_corr_cov_cholesky(corr, covdiag)')

* tests: added tests for inv_chol_cov_matrix kwarg for the case of combined fits

* fix: renamed covdiag to inverrdiag needed for the cholesky decomposition and corrected its documentation

* examples: added an example of a correlated combined fit to the least_squares documentation

* feat/tests/fix(of typos): added function 'sort_corr()' (and a test of it) to sort correlation matrix according to a list of alphabetically sorted keys

* docs: added more elaborate documentation/example of sort_corr(), fixed typos in documentation of invert_corr_cov_cholesky()
2024-09-13 08:35:10 +02:00
s-kuberski
dc63142f8e
Fixed bugs for combined fits with multiple independent variables (#211) 2023-10-24 19:30:52 +02:00
Fabian Joswig
957030cba0 fix: explicit type check replaced by isinstance in fits.least_squares. 2023-09-17 18:11:26 +02:00
Fabian Joswig
5c2a6de56f
fix: explicit Exception for combined fit constant edge case. (#202) 2023-07-14 14:26:54 +01:00
Fabian Joswig
90c9ce9c73
refactor: unnecessary line in fit parameter detection removed.
Iterator variable renamed.
2023-03-14 09:50:35 +00:00
Fabian Joswig
a7a098b861
fix: chisquare, dof and p-value also calculated when dof is 0. Test for
dof and chisquare_over_dof added.
2023-03-09 15:32:27 +00:00
Fabian Joswig
99a1033703
refactor: refactored construction of prior Obs in least_squares. 2023-03-09 14:25:37 +00:00
Fabian Joswig
507fa7dbdc
chore: Duplicate check of y-errors removed and Exception made more
explicit in least_squares.
2023-03-08 16:52:21 +00:00
Fabian Joswig
80f4eef912
chore: Exception in least_squares specified. 2023-03-08 16:45:29 +00:00
Fabian Joswig
e6051d7ba0
docs: docstring of least_squares updated. 2023-03-07 16:39:37 +00:00
Fabian Joswig
839d9214ed
Improved prior fit (#161)
* refactor: merged combined fit and prior fit without breaking the
routine. Fitting with priors does not work yet.

* refactor: correlated fits without priors work now.

* refactor: prior error propagation and dof fixed.

* refactor: old prior fit implementation moved to tests.

* refactor: moved _extract_val_and_dval out of least_squares.

* refactor: comment removed.

* tests: additional tests and exceptions added.

* tests: test for constrained prior fit added.

* docs: least_squares docstring extended.

* fix: linting errors fixed.

* feat: additional if cause for fits without priors added to achieve
original speed.

* tests: test_constrained_and_prior_fit fixed.

* fix: fix array cast of least_squares dict mode.

* tests: test for lists in dict fit added.

* fix: additional asarray added in resplot.

Co-authored-by: Simon Kuberski <simon.kuberski@uni-muenster.de>
2023-03-07 16:15:16 +00:00
Fabian Joswig
82cd2f11ea
fix: multi dim fits fixed in least squares. Test added. (#160)
Co-authored-by: Simon Kuberski <simon.kuberski@uni-muenster.de>
2023-03-03 16:35:26 +00:00
Fabian Joswig
2ac38515b6
refactor: logic in least square fits simplified.
Co-authored-by: Simon Kuberski <simon.kuberski@uni-muenster.de>
2023-03-02 18:42:55 +00:00
Fabian Joswig
a140b2ab39
refactor: removed redundant formulations of the chisquare function in
least_squares.
2023-03-01 16:29:59 +00:00
Fabian Joswig
ee2944d5b0
refactor: chisqfunc rewritten as sum over residuals. 2023-03-01 16:12:31 +00:00
Fabian Joswig
dc7033e51f
refactor: _standard_fit method made redundant. (#154)
* refactor: _standard_fit method made redundant.

* fix: xs and yz in Corr.fit promoted to arrays.

* fix: x promoted to array in _combined_fit if input is just a list.

* feat: residual_plot and qqplot now work with combined fits with
dictionary inputs.

* tests: test for combined fit resplot and qqplot added.

* docs: docstring of fits.residual_plot extended.
2023-03-01 10:00:35 +00:00
Fabian Joswig
3ca79581f3
Merge pull request #148 from PiaLJP/feature/correlated_combined_fit
Feature/correlated combined fit
2023-02-03 17:05:36 +00:00
ppetrak
b0b5d88dc3 Merge branch 'develop' of https://github.com/PiaLJP/piapyerrors into develop 2023-02-03 15:04:06 +01:00
ppetrak
ba54545b4e feat/tests: Correlated fits now also work for combined fits. 2023-02-03 14:54:54 +01:00
Fabian Joswig
3236ba54e7
Merge pull request #134 from PiaLJP/develop
sample implementation of a (uncorrelated) combined fit
2023-02-02 15:09:11 +00:00
Fabian Joswig
088f4d1239
feat: additional check for invalid input to least_squares added.
Co-authored-by: Simon Kuberski <simon.kuberski@uni-muenster.de>
2023-02-02 14:58:35 +00:00
ppetrak
59d22fceee fix: reduced the migrad solver tolerance + removed unnecessary check 2023-01-30 15:16:41 +01:00
ppetrak
80371a0898 fix/tests: Combined fit now also works when the keys of the x,y & func input dictionaries are not in the same order, build: improvements in performance 2023-01-30 14:26:47 +01:00
Justus Kuhlmann
26447d658c
better docstrings (#144)
* first example of returns statement in docstring

* added a some return statements for pandas API

* last return statements in pandas input

* added returns to bdio docstrings

* few returns statements added to docstring

* finished docstrings for hadrons submodule

* also finished docstrings for json submodule

* finished misc submodule

* added returns in docstrings in openqQCD

* made some cosmetic chanes to dostrings

* added return nad return statement in docstring

* linting

* Improved docstrings of mpm, fits, roots, misc to have return statements

returns added for misc.py

returns added for mpm.py

reutrns added for fits.py

* linting...

* Some polishing of docstrings
2023-01-16 14:57:22 +00:00
Fabian Joswig
b9cdebd442
feat: gm alias for gamma_method also added to other classes. 2023-01-13 17:26:52 +00:00
ppetrak
80c8a0f979 feat: added (default) method Levenberg-Marquardt, test added 2022-12-20 15:26:13 +01:00
Fabian Joswig
33ff2219ba
fix: Combined fit can now handle list and array inputs for y-values, test added. 2022-12-19 16:06:12 +01:00
Fabian Joswig
140b626aae
fix: Combined fit can now handle list and array inputs for x-values,
test added.
2022-12-19 15:15:24 +01:00
ppetrak
3d6ec7b397 fix: flak8 & pytest 2022-12-19 14:03:45 +01:00
ppetrak
500c5234cf clean-up 2022-12-16 18:55:43 +01:00
ppetrak
9a05fc916a incorparated (uncorrelated) combined fits in fits.least_squares 2022-12-16 18:47:25 +01:00
Fabian Joswig
19bf558c78
feat: Hotelling t-squared p-value for correlated fits added. 2022-12-06 17:17:03 +00:00
Fabian Joswig
89125c91e2
fix: another bug in num_grad version of prior fit fixed. 2022-10-07 18:02:14 +01:00
Fabian Joswig
ca4f83f5d1
fix: bug in num_grad version of prior fit fixed. 2022-10-07 17:57:02 +01:00
Fabian Joswig
58b8383c1a
feat: hessian added to prior fit and odr fit routines. 2022-10-06 18:07:19 +01:00
Fabian Joswig
b84ea1cc3b
feat: double jacobian in standard fit replaced by hessian
This greatly improves performance for numerical derivatives and helps
with readability.
2022-10-06 10:44:06 +01:00
Fabian Joswig
99e130d33c
fix: index of num diff jacobian in least squares fit corrected. 2022-10-05 17:54:25 +01:00
Fabian Joswig
ee4149e498
feat: least_squares fit error propagation can now also be performed via
numerical derivatives.
2022-10-05 17:44:38 +01:00
Fabian Joswig
6c6a0f367e feat: warning for ill conditioned correlation matrix in correlated fit
only triggered for condition number > 1e13.
2022-07-18 16:25:33 +01:00
Fabian Joswig
86a45eb47b refactor: Unused variable in fit function detection removed. 2022-06-24 13:12:53 +01:00
Fabian Joswig
fe9696841f fix: Exception types for fit function detection specified. 2022-06-24 13:10:06 +01:00
Fabian Joswig
3e29cf9ca8 fix: detection of invalid fit functions extended. 2022-06-24 12:50:26 +01:00
Fabian Joswig
0150ef4c0b refactor: imports of scipy.stats in fits simplified. 2022-06-15 14:14:01 +01:00
Fabian Joswig
155c329921 fix: bug in error propagation for correlated fits fixed. 2022-06-06 15:47:41 +01:00
Fabian Joswig
6bd724715f fix: Fit_result.gamma_method can now be called with kwargs 2022-06-06 15:04:16 +01:00
Fabian Joswig
4aae55d1d6 docs: Docstring for fits.least_square extended. 2022-05-31 11:51:59 +01:00