prob_at_least_one_new_card drops probability mass for rarities with no cards in the pack and never clamps #2

Closed
opened 2026-10-08 21:43:00 +02:00 by freydis · 0 comments
Owner

In `apps/tracker/utils.py`, the inner loop does `if total == 0: continue` when a rarity in the generation table has no cards in the pack. That rarity's slot probability is simply removed from `slot_prob_no_new`, so the per-slot distribution no longer sums to 1 and P(no new) is underestimated, i.e. the displayed chance is inflated. In the extreme (all rarities of a slot missing, e.g. slot 6 of a G4 shiny pack applied to a pack without shiny cards) the slot contributes 0 and the chance becomes 100% regardless of collection.

Today this is triggered by A4b (shiny_rare row, no shiny_rare cards) and by any pack whose `rarity_version` points at the wrong generation (see the import_data issue).

Suggested fix: renormalise over the rarities actually present in the pack (divide by the sum of their slot probs), or treat the missing-rarity mass as "no new card", and clamp the final result to [0, 1]. Also run `validate_probabilities` in CI or at the end of `import_data` so bad tables fail loudly instead of producing wrong numbers.

In \`apps/tracker/utils.py\`, the inner loop does \`if total == 0: continue\` when a rarity in the generation table has no cards in the pack. That rarity's slot probability is simply removed from \`slot_prob_no_new\`, so the per-slot distribution no longer sums to 1 and P(no new) is underestimated, i.e. the displayed chance is inflated. In the extreme (all rarities of a slot missing, e.g. slot 6 of a G4 shiny pack applied to a pack without shiny cards) the slot contributes 0 and the chance becomes 100% regardless of collection. Today this is triggered by A4b (shiny_rare row, no shiny_rare cards) and by any pack whose \`rarity_version\` points at the wrong generation (see the import_data issue). Suggested fix: renormalise over the rarities actually present in the pack (divide by the sum of their slot probs), or treat the missing-rarity mass as "no new card", and clamp the final result to [0, 1]. Also run \`validate_probabilities\` in CI or at the end of \`import_data\` so bad tables fail loudly instead of producing wrong numbers.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
freydis/tcgp-tracker#2
No description provided.