# Cards in box - probability a given type is picked last

I came out with a probability question which I find difficult to solve. I hope some kind souls can provide me with some ideas.

There is a box with four different types of cards, namely A, B, C, D. There are 7 A, 4 B, 3 C and 2 D. One starts to pick cards from the box. The card picked out is not put back into the box. I would like to calculate the probability for certain type the cards that is to be picked last.

For example, if the sequence of cards picked goes like AABABC, then D is identified instantly as the card to be picked last.

Can anyone provide a non-exhaustive method of calculating the probability of certain type of a cards to be picked last? Thank you!

Furthermore, it would be very nice of you to provide a generalized formula of evaluation.

-
are we picking out every card from box or just n amount? – Kamster Aug 27 '14 at 5:31
One will continue picking until you pick out three types of cards, for example, in the case of sequence:AABBBAAC, once C is picked out, D is deemed to be picked out last. – user122049 Aug 27 '14 at 5:44
Could you give a proof? Thank you! – user122049 Aug 27 '14 at 5:47
Are you asking whether probability that D is actually picked last (like literally the last card picked) or probability that you picked all the other types of cards before you even got one D card – Kamster Aug 27 '14 at 6:37
One observation that may help anyone who wants to solve this is that the probability is unchanged if one adds the cards back to the deck. After A is drawn once, it really doesn't matter whether it's drawn again or not, as long as all the other types of cards have the same (relative) probabilities of being drawn. This observation might conceivably simplify the analysis. – Will Nelson Aug 27 '14 at 7:07

The cards in the box are: 7 of type A, 4 of B, 3 of C and 2 of D.

Let, for example, $A=1,B=2,C=3$ represent the event of encountering the type A first, type B second, type C third, and type D last. (We don't have to write the last, it's implicit.) One such example is to draw cards in order $\mathbf A,A,\mathbf B, A, \mathbf C,B,A,C,\mathbf D, A...$

Clearly the probability of encountering A first is : $\mathsf P(A=1) =a/(a+b+c+d) =7/16$

Given that, the probability of encountering B second is: $\mathsf P(B=2 \mid A=1)=b/(b+c+d)= 4/9$

And likewise, $\mathsf P(C=3\mid A=1,B=2) = c/(c+d) = 3/5$

So \begin{align} \mathsf P(A\!=\!1,B\!=\!2,C\!=\!3) &= \frac{abc}{(a+b+c+d)(b+c+d)(c+d)} &= \frac{7\times 4\times 3}{(7+4+3+2)(4+3+2)(3+2)} \\ \mathsf P(A\!=\!1,B\!=\!3,C\!=\!2) &= \frac{abc}{(a+b+c+d)(b+c+d)(b+d)} &=\frac{7\times 4\times 3}{(7+4+3+2)(4+3+2)(4+2)} \\ \mathsf P(A\!=\!2,B\!=\!1,C\!=\!3) &= \frac{abc}{(a+b+c+d)(a+c+d)(c+d)} &= \frac{7\times 4\times 3}{(7+4+3+2)(7+3+2)(3+2)} \\ \mathsf P(A\!=\!2,B\!=\!3,C\!=\!1) &= \frac{abc}{(a+b+c+d)(a+b+d)(b+d)} &=\frac{7\times 4\times 3}{(7+4+3+2)(7+4+2)(4+2)} \\ \mathsf P(A\!=\!3,B\!=\!1,C\!=\!2) &= \frac{abc}{(a+b+c+d)(a+c+d)(a+d)} &= \frac{7\times 4\times 3}{(7+4+3+2)(7+3+2)(7+2)} \\ \mathsf P(A\!=\!3,B\!=\!2,C\!=\!1) &= \frac{abc}{(a+b+c+d)(a+b+d)(a+d)} &= \frac{7\times 4\times 3}{(7+4+3+2)(7+4+2)(7+2)} \end{align}

Then $\mathsf P(D=4)$ is the sum of these six.

\begin{align}\mathsf P(D=4) & = \frac{7\times 4\times 3}{16}\times(\frac 1 {9\times 5}+\frac 1{ 12\times 5}+\frac 1{9 \times 6}+\frac 1{12 \times 9}+\frac 1{13\times 6}+\frac 1{13\times 9}) \\ & =\frac{721}{1560}\end{align}

And so forth.

-
Nicely explained! Do you think the general formula can be written using cyclic addition? – user122049 Aug 27 '14 at 7:41

Suppose I take a video of you picking the cards from a shuffled deck. You reach the last card; and shake it in the air. Then you shuffle and I video you doing it again, and then again.

Now play those same videos in reverse - we see you shake a card from a shuffled deck in the air, then watch you proceed to go through the rest of the deck.

Thinking about this, we see that the odds that the last card is $X \in \{A,B,C,D\}$ is the same as the odds that the first card is $X$. In fact with consistent re-editing of our videos, we could see that it's the same as the odds that $X$ is the second card, etc.

So if $n_X$ is the number of cards of type $X$, and there are a total of $N$ cards in the deck, the odds that $X$ is the last card = the odds that $X$ is the first card = $\frac{n_X}{N}$.

EDIT: I think I misunderstood the original question; which wants "$X$ is the last" to mean not the type of the last card turned over, but instead that the first card of type $X$ to be turned over has been preceded by every other type of card.

-
Buts isn't she not replacing so the odds are different as depending how many cards are in deck and which cards? – Kamster Aug 27 '14 at 5:59
It's precisely because she's NOT replacing that this works. That's why 'playing the videos in reverse' doesn't change the outcome. If she were replacing, then we couldn't perform this transform and claim that it doesn't change the distribution. Of course, if the number of cards in the deck / number of cards of each type changed depending on the video's playback order mattered, it would be different; but that's not the case here. – Chas Brown Aug 27 '14 at 6:21
Oh, isn't the OP was asking, whether a certain card is picked last (in terms) that all other cards had been picked before got to that card, not literally picked last, since in example OP gave there was AABABC which doesn't have every card picked and doesn't imply that D is actually the last card picked – Kamster Aug 27 '14 at 6:34
Essentially what I thought OP meant by picked last is if you have 2 A, 2 B, and 1 C, that ABBCA and ABBAC and ABCAB would all be considered having C picked last. – Kamster Aug 27 '14 at 6:41
User159823 is correct. That is exactly what I mean. – user122049 Aug 27 '14 at 7:01
Sequence Probability
-------- -----------
ABCD     7/16 x 4/9 x 3/5
BACD     4/16 x 7/12 x 3/5
ACBD     7/16 x 3/9 x 4/6
BCAD     4/16 x 3/12 x 7/9
CABD     3/16 x 7/13 x 4/6
CBAD     3/16 x 4/13 x 7/9


These probabilities sum to $\dfrac{721}{1560} \approx 0.462179$. I don't know how to turn this method into a general formula, though.

-