Skip to content

Commit

Permalink
switch to more stable survival function
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorStoneAstro committed May 31, 2024
1 parent 8f29f83 commit 30f33a1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/pqm/pqm.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ 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.cdf(chi2_stat, dof, scale=chi2_stat)
chi2_stat = chi2.ppf(cp, num_refs - 1, scale=chi2_stat)
cp = chi2.sf(chi2_stat, dof)
chi2_stat = chi2.isf(cp, num_refs - 1)
dof = num_refs - 1
return chi2_stat, dof
2 changes: 1 addition & 1 deletion tests/test_gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ def test_fail_chi2():

new.append(pqm_chi2(x_samples, y_samples, num_refs=100))
new = np.array(new)
assert np.mean(new[:, 0]) / 99 > 10
assert np.mean(new[:, 0]) / 99 > 2

0 comments on commit 30f33a1

Please sign in to comment.