mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 19:43:41 +02:00
Fixed bugs for combined fits with multiple independent variables (#211)
This commit is contained in:
parent
0ef8649031
commit
dc63142f8e
2 changed files with 49 additions and 2 deletions
|
@ -365,7 +365,7 @@ def least_squares(x, y, func, priors=None, silent=False, **kwargs):
|
|||
raise Exception('The minimization procedure did not converge.')
|
||||
|
||||
output.chisquare = chisquare
|
||||
output.dof = x_all.shape[-1] - n_parms + len(loc_priors)
|
||||
output.dof = y_all.shape[-1] - n_parms + len(loc_priors)
|
||||
output.p_value = 1 - scipy.stats.chi2.cdf(output.chisquare, output.dof)
|
||||
if output.dof > 0:
|
||||
output.chisquare_by_dof = output.chisquare / output.dof
|
||||
|
@ -393,7 +393,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(x_all.shape[-1]) - P_phi) @ W @ cov @ W)
|
||||
expected_chisquare = np.trace((np.identity(y_all.shape[-1]) - P_phi) @ W @ cov @ W)
|
||||
output.chisquare_by_expected_chisquare = output.chisquare / expected_chisquare
|
||||
if not silent:
|
||||
print('chisquare/expected_chisquare:', output.chisquare_by_expected_chisquare)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue