[Fix] corrected expected_chisquare by adding the number of priors (#274)

* [Fix] corrected expected_chisquare by adding the number of priors

* test/fits_test.py: dof and expected chisquare the same in uncorrelated fit w. prior to uncorrelated data
This commit is contained in:
Pia Leonie Jones Petrak 2025-10-22 09:36:01 -04:00 committed by GitHub
commit e0076ccea9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 79 additions and 1 deletions

View file

@ -472,7 +472,7 @@ def least_squares(x, y, func, priors=None, silent=False, **kwargs):
hat_vector = prepare_hat_matrix()
A = W @ hat_vector
P_phi = A @ np.linalg.pinv(A.T @ A) @ A.T
expected_chisquare = np.trace((np.identity(y_all.shape[-1]) - P_phi) @ W @ cov @ W)
expected_chisquare = np.trace((np.identity(y_all.shape[-1]) - P_phi) @ W @ cov @ W) + len(loc_priors)
output.chisquare_by_expected_chisquare = output.chisquare / expected_chisquare
if not silent:
print('chisquare/expected_chisquare:', output.chisquare_by_expected_chisquare)