Recommend
1 
 Thumb up
 Hide
9 Posts

BoardGameGeek» Forums » Board Game Design » Board Game Design

Subject: Please help with general probability equations rss

Your Tags: Add tags
Popular Tags: [View All]
Brad Johnson
United States
Crystal Lake
Illinois
flag msg tools
designer
badge
Avatar
mbmbmbmbmb
I'm looking for help deriving the general equation for the following:

Given a deck of cards composed of X suits numbered 1 to Y each, what is the probability of a randomly-dealt hand of size M containing a flush of size N?

For example, say I have a deck of 6 suits numbered 1 to 10 each. (So a deck of 60 cards.) If I deal a hand of 8 random cards, what is the chance it will contain exactly 4 cards of the same suit (any suit)?

Unless I'm wrong, the same equation should be usable to get the probabilities of sets (cards of the same rank), because it's just "slicing" the deck the other way.

But I'd also like to get the general equation as above for straights (cards in sequential rank, regardless of suit) of size N, which I think is probably even more complicated.

I can't get my head around this. Any probability experts who can help out there?
 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Jeremy Lennert
United States
California
flag msg tools
designer
Avatar
mbmbmbmbmb
There are X*Y cards in the deck, so C(X*Y, M) possible hands of size M.

To have exactly N cards of a specific color, you need to deal N cards of that color and M-N cards of other colors; there are C(Y, N) * C(Y*(X-1), M-N) ways to do that.

So the odds of getting an N-long flush of a specific suit (say, clubs) is C(Y, N) * C(Y*(X-1), M-N) / C(X*Y, M).

However, that's going to include some hands that also have partial flushes in another color. For instance, if you look for 8-card hands with 3-flushes in clubs, you're including hands that have a 3-flush of clubs and a 5-flush of diamonds in the same hand. If you want to exclude those because you only want to count the "best" set in the hand, things get more complicated.

Also, you might think you could count up the 3-flushes in ALL suits by muliplying by the number of suits--but there are some hands with 3-flushes in multiple suits, so you'd be counting those twice.

To handle both of the preceding points, you'd probably need to calculate the number of hands with overlap and then apply the Inclusion-Exclusion Principle.


Unless you are dealing with really big numbers, I suspect you would be better served by writing a computer program to count the hands by brute force, instead of trying to derive a closed-form equation. Less chance of an error, and easier to modify to handle other cases.
6 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Brad Johnson
United States
Crystal Lake
Illinois
flag msg tools
designer
badge
Avatar
mbmbmbmbmb
Thanks - that overlap between multiple flushes in the same hand (the "more complicated" part) is what's messing me up. I do want to just count the "best" flush, regardless of suit. I debated doing a program to empirically count all the possible hands, but the case I'm really most interested in is C(5*12,9) = 14.8 billion hands, and that's really just too many to do on my little laptop.

I think I'm going to have to try to come up with all the possible overlapping sub-cases and calculate them separately.....
 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Jeremy Lennert
United States
California
flag msg tools
designer
Avatar
mbmbmbmbmb
tempus42 wrote:
the case I'm really most interested in is C(5*12,9) = 14.8 billion hands, and that's really just too many to do on my little laptop.

You could use random sampling (Monte Carlo) to get an approximate answer much more quickly.
 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Pelle Nilsson
Sweden
Linköping
flag msg tools
designer
badge
Avatar
mbmbmbmbmb
tempus42 wrote:
the case I'm really most interested in is C(5*12,9) = 14.8 billion hands, and that's really just too many to do on my little laptop......


Even your laptop probably does several billion instructions per second so iterating over 14.8 billion hands to count how many match some criteria should not take very long.

Otherwise Monte Carlo as was already suggested.
2 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Larry L
United States
Stockton
California
flag msg tools
Roll for it
badge
I + I = 0
Avatar
mbmbmbmbmb
Inclusion/Exclusion isn't too awful for flushes as you have defined them (exactly N cards, no more, no less) since you can't have too many in your hand at once. (I think you will run into more trouble with straights, but I haven't thought it through)

If you are okay counting hands with one or more flushes in them you want:

# of hands with 1 flush (and maybe more) - # of hands with 2 flushes + # of hands with 3 flushes and so on (alternating minus/plus). Luckily that 'and so on' wont run very long, since you will run out of space in your hands really quickly.

If you want hands with exactly one flush and not two (or more) you want:

# of hands with 1 flush (and maybe more) - 2 * # of hands with 2 flushes + 3 * # of hands with 3 flushes and so on.

(After you count, divide by the number of possible hands to get the probability)

 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Brad Johnson
United States
Crystal Lake
Illinois
flag msg tools
designer
badge
Avatar
mbmbmbmbmb
Thanks, everyone. I was actually able to do some semi-manual piece-meal calculations to come up with the percentages I wanted for one specific case, for flushes and sets at least. Much harder for straights. So I did also go ahead and wrote a little program to do some Monte Carlo estimation for some particular means I wanted. Seemed to work out ok. General equations just aren't going to be practical the way I had hoped, but I got what I needed anyway.
 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Peter Strait
United States
Sacramento
California
flag msg tools
badge
Avatar
Also, and this is a little out there, if you consider each suit a directional axis you can exclude based on rotational symmetry. (You'll need a modern graphics card and a post-grad CS degree to pull it off, though.)
 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Peter Strait
United States
Sacramento
California
flag msg tools
badge
Avatar
Also and more seriously (since my brain has decided it enjoys chewing on this question), you can create a "built up" probability for a given hand almost trivially*, by recursively asking, "What is the chance that the next card drawn will contribute to a straight/flush/set?" paired with treating each non-matching card as opening a new opportunity for a separate set. (Basically "Odds of Continuing Flush N" with "Odds of starting new flush" for each successive card, branching once with each new card up to as many times as there are suits, which can then be summed; you should be able to go up to a hand size of 8 without swamping a modern PC.)

(*can be done with an BS or AS in CS. )
 
 Thumb up
 tip
 Hide
  • [+] Dice rolls
Front Page | Welcome | Contact | Privacy Policy | Terms of Service | Advertise | Support BGG | Feeds RSS
Geekdo, BoardGameGeek, the Geekdo logo, and the BoardGameGeek logo are trademarks of BoardGameGeek, LLC.