Commit graph

1 commit

Author SHA1 Message Date
Lukas Brübach
a438be8bda [Analytics] Return zero instead of NaN for impossible draw probabilities
The draw-probability widget computes a hypergeometric probability as a sum of
qLn terms. Two argument combinations reach a non-positive term and return NaN,
which the results table prints as "nan":

- k > K, asking for more copies than the deck holds. A deck with one Forest,
  draw 7, "exactly 3" gives K=1, k=3.
- n - k > N - K, where drawing k targets would need more non-target cards than
  exist. An 8-card deck with 6 targets, draw 5, "exactly 0" gives N-K=2, n-k=5.

Both are reachable: the quantity and drawn spinboxes allow 1-60, and the
"at least" branch caps k at copies while the "exactly" branch passes the spinbox
value straight through.

Extract the function so it can be tested on its own, and guard both cases.
Restoring the old guard fails 3 of the 7 new tests.
2026-10-10 19:57:18 +02:00