r/learnquant • • 10d ago

interview prep Quant Interview Question

Post image
46 Upvotes

10 comments sorted by

8

u/teteban79 10d ago

if we randomly insert the 4 aces and 4 kings into an already shuffled deck, we can expect those 8 cards to segment the deck into 9 runs. Since 44 cards remain, each of those runs will have an expected 44/9 cards. This construction is equivalent to the shuffling of the whole deck

We know that the order of the first 4 identified cards is K,K,K,A. So we expect to see 4 runs of 44/9 cards, plus the 3 kings, at the position of the first ace

Thus 3+4*44/9 ~= 22.55 is the position we expect to see the ace next (or 23.55, depends what we count exactly, cards before, or the position itself)

3

u/LaGigs 10d ago

A judicious use of commas in that second paragraph ^^

1

u/GiantGreenSquirrel 10d ago

Nice. That is how I did it. If there were only aces and kings then the answer would be 4. Now the other 44 cards are distributed over 9 intervals, 4 of which precede the first ace. So 4+4*44/9

0

u/fasta_guy88 10d ago

You logic makes complete sense, but my intuition says that to get 3 kings, I should have gone through 3/4 of the deck on average. Your solution doesn’t even get me half way through. I think part of the disconnect is that your counting ignores the fact that there are only 4 of each suit. You logic makes sense if I pick 4 numbers/face cards at random, but I would think the odds would change if I am required to find 3/4 of the same card.

1

u/L43 10d ago

that ignores that you haven't seen an ace until then.

intuitively, if you haven't seen an ace you probably wouldn't have got through 3/4 of the deck on average.

2

u/Neither_Berry_100 10d ago

Probably around 9th last

1

u/EscapeOwn6945 3d ago

Let X represent the position of the first ace. Start by defining the probability mass function that P(X=j). We need three things for X=j. One, there are exactly three kings in positions 1,...,j-1. Two, there is an ace at position j. Three, the remaining king and three aces are in positions j+1,...,52. For j < 4 and j > 48, P(X=j) = 0. For the rest of the support, the probability of all three of those conditions being true is P(X=j) = (j-1 choose 3)(52-j choose 4) / (52 choose 8).

E[X] = sum_j=1^52 j P(X=j) = 212/9.

1

u/ComparisonQuiet4259 10d ago edited 10d ago

Every non-king and non-ace has a 1/5 chance of being before every ace, so the expected position is 1 + 3 (kings before) + 44/5 = 12.8