Sunday 19 February 2017

probability - Expected Size of largest Flush (Cards)



I have been trying the following question from TopCoder but am having trouble understanding how to calculate the probability.



You are playing a card game in which large flushes, or sets of cards of the same suit,
are beneficial. Your next move is to draw number cards: the larger the flush you get,

the better. You wish to know the expected size of the largest flush in the cards you
draw. The deck will consist of some number of cards of four suits, given as suits. The
ith element of suits is the number of cards of that suit in the deck. Return a double,
the expected size of the largest flush your hand will make.


The expected size of the largest flush is calculated as follows: For each possible
hand, multiply the size of the largest flush in that hand by the probability of
getting that hand. Then add all of these values together to get the expected size of
the largest flush. For example, if half of the possible hands give you a flush of

size 3, and the rest give you one of size 2, the expected value is (0.5 * 3) + (0.5 *
2) = 2.5. Also, recall that there are n Choose k = n!/k!/(n-k)! ways to select k
cards of one suit out of a total of n cards in that suit, where ! denotes the
factorial operation. Thus, if suits = {3,3,3,3}, then there are (3 Choose 3) * (3
Choose 2) * (3 Choose 1) * (3 Choose 0) = 1 * 3 * 3 * 1 = 9 ways to get 3 cards of
the first suit, 2 of the second, 1 of the third, and none of the fourth.


More info: http://topcoder.bgcoder.com/print.php?id=885




I've been trying to understand the problem by first trying to tackle a simpler example.



suits = [2,2,2,2]
Cards to pick = 3


When picking the 2nd card, you can either:



1) Pick a card from the same suit as the first card (EV = 1/7 * 2)




2) Pick a card from a different suit to the first card (EV = 6/7 * 1)



This is where I get confused. When picking the 3rd card, do I calculate a probability as if 1) occurred, as if 2) occurred and then sum the result?



If someone could shed some light as to what would happen at this step, I would greatly appreciate it!


Answer



Yes, you have to cover all the possibilities. This is sometimes done with a probability tree in simple situations like this one. The probabilities of each step are beside each branch. With "FS" meaning "flush size":



enter image description here




You multiply the probabilities at each level and this gives,



\begin{eqnarray*}
P(FS=1) &=& \dfrac{6}{7}\times\dfrac{4}{6} &=& \dfrac{4}{7} \\
P(FS=2) &=& \dfrac{1}{7}\times 1 + \dfrac{6}{7}\times\dfrac{2}{6} &=& \dfrac{3}{7} \\
P(FS=3) &=& \dfrac{1}{7}\times0 &=& 0.
\end{eqnarray*}



To generalise this idea for any program input you could consider a different style of tree where at each step you consider what happens if a heart, diamond, spade, or club is drawn. Its recursive/repetitive nature could make it more program-friendly than the above tree.




enter image description here


No comments:

Post a Comment

real analysis - How to find $lim_{hrightarrow 0}frac{sin(ha)}{h}$

How to find $\lim_{h\rightarrow 0}\frac{\sin(ha)}{h}$ without lhopital rule? I know when I use lhopital I easy get $$ \lim_{h\rightarrow 0}...