Basically, I’d like to know for a card game this particular question. I have 13 “basic” cards in the deck, one of which must be in my starting hand - a hand of 7 cards drawn from a randomly shuffled deck. If I don’t get a “basic” in this hand of cards I then reshuffle the deck with that hand going back into it and draw a new 7 card. There’s 6 different types of “basic” card - 5 having a two count with one having three. (resulting in the previously mentioned 13 “basic” cards.)
After drawing a hand of 7 cards with at least one basic from my shuffled deck, I place 6 cards face down from the top of the deck - without shuffling again or looking at them to the side of my board. What are the odds that all copies of the same “basic” as well as one other specific card from the deck (let’s call it “X”) are placed in this 6 cadd pile. For reference, the decklist would look like:
”Basic” cards. (13)
3 A, 2 B, 2 C, 2 D, 2 E, 2 F
Other (47)
46 cards not relevant, 1 X
Script
Here's a solution using my Icepool Python package:
(API subject to change. This script is based on Icepool v0.25.6.)
Try this script in your browser.
Result
Die with denominator 7422507311299080
Explanation
all_basicreturns 1 if that card is a basic card and all copies of that card were drawn, and 0 otherwise.multiset_functionallows us to define a function using some simple multiset operations. In this case, we jointly determine three things:&operator represents multiset intersection, and.any()determines whether that intersection is non-empty..any()such card.final_evaluationdescribes restarting if the first condition is not met, and otherwise determines whether the other two conditions are met.Algorithm
The algorithm uses dynamic programming and the decomposition of the hypergeometric distribution into binomials to find the distribution efficiently. If you are curious to learn more, you can read my paper here.