Skip to content

Conversation

@shntnu
Copy link
Member

@shntnu shntnu commented Dec 8, 2025

Summary

  • When C(total, num_pos) <= null_size, compute exact null distribution by enumerating all possible rankings instead of random sampling
  • Added exact_ap() function to enumerate all combinations
  • Modified null_dist_cached() to use exact computation when feasible
  • Results are tiled to null_size for consistent interface

Closes #105

Example

For a small configuration with num_pos=3 positives and total=10 items:
C(10, 3) = 120

If null_size=10,000, all 120 exact AP scores are computed and tiled to fill 10,000 slots, giving exact p-values.

Test plan

  • uv run pytest passes (65 tests)
  • uv run ruff check src/ tests/ passes
  • Added tests for exact_ap, exact/random switching logic

🤖 Generated with Claude Code

shntnu and others added 2 commits December 7, 2025 21:00
When the number of possible rankings C(total, num_pos) is less than or
equal to null_size, compute exact null distribution by enumerating all
combinations instead of random sampling.

This provides exact p-values for small configurations like (5 replicates,
20 negcon) where C(20, 5) = 15,504 < 10,000.

Closes #105

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@shntnu shntnu requested a review from johnarevalo December 8, 2025 02:03
@johnarevalo
Copy link
Member

Thanks for the PR!

For (5 replicates, 20 negcon): C(20, 5) = 15,504

Shouldn't this be C(25, 5)? 😄

@shntnu
Copy link
Member Author

shntnu commented Dec 8, 2025

Shouldn't this be C(25, 5)? 😄

Ah yes :) I've updated the example (and with a smaller one fwiw)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compute exact p-value for small null configs

3 participants