Include equal distances in permutation-test upper tails - #1094
Closed
dnncha wants to merge 1 commit into
Closed
Conversation
Member
|
AI generated slop. If you didn't review as a human, why should I? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1094 +/- ##
==========================================
- Coverage 79.95% 79.94% -0.02%
==========================================
Files 55 55
Lines 7533 7533
==========================================
- Hits 6023 6022 -1
- Misses 1510 1511 +1
🚀 New features to boost your workflow:
|
Author
|
Pertpy can raise a false alarm. All 70 possible groupings give exactly the same result—nothing makes the original special. Yet it reports statistical significance: p=0.001 instead of p=1. Counting ties correctly fixes these examples. Who found the bug does not change the arithmetic. If the example is wrong, show why. Otherwise, please track and fix it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When all label permutations tie the observed distance,
DistanceTestcurrently reports p=1/n_perms instead of 1. This patch counts equal distances in the upper tail and updates the helper's docstring. It preserves the existing group-label alignment fix and minimum-count convention.For eight observations split 4/4, both identical nonzero embeddings and an embedding with seven rows (1,1,1) plus one row (9,1,1) have the same statistic for all 70 balanced assignments. The latter has Euclidean distance 2 and E-distance 1 for every assignment. Released Pertpy 1.3.0 gives raw p=0.001 with 1,000 permutations; the inclusive-tail correction gives 1. The same strict comparison remains in current upstream base 3001be8.
Minimal public-API reproduction:
Seven new checks cover four public-API fixture/metric combinations, a mixed equal/lower tail, and strictly greater/lower controls. Including the existing group-label alignment regression: before, five fail and three pass; after, all eight pass. The other 18 distance tests use a downloaded dataset and were deselected; the full suite was not run. Changed source/tests pass Ruff lint and formatting checks.
The change addresses exact ties. It does not introduce a floating-point near-tie tolerance, randomized tie-breaking, or revise the general Monte Carlo numerator/denominator convention. No affected published conclusion is established. The inclusive upper-tail convention is also documented by https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.permutation_test.html .
Published reproduction, full enumeration, released-wheel before/after outputs and evidence archive: https://cheerfulduck.com/research/audits/pertpy-permutation-ties . Prepared with AI assistance; independent human scientific review and a released fix are not claimed.