Skip to content

Commit

Permalink
rough fix for very very bad chi2
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorStoneAstro committed May 31, 2024
1 parent 30f33a1 commit a8471e6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/pqm/pqm.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ def pqm_chi2(
chi2_stat, _, dof, _ = _pqm_test(x_samples, y_samples, num_refs, whiten)
if dof != num_refs - 1:
# Rescale chi2 to new value which has the same cumulative probability
cp = chi2.sf(chi2_stat, dof)
chi2_stat = chi2.isf(cp, num_refs - 1)
if chi2_stat / dof < 10:
cp = chi2.sf(chi2_stat, dof)
chi2_stat = chi2.isf(cp, num_refs - 1)
else:
chi2_stat = chi2_stat * (num_refs - 1) / dof
dof = num_refs - 1
return chi2_stat, dof

0 comments on commit a8471e6

Please sign in to comment.