# Simple Monte Carlo simulation/approximation of 2 pair in a 5 card poker hand

I am very curious about simulation of an event where an estimating/sampling technique is used.

In this example, the goal is to simulate a subset of all the roughly $2.6$ million $5$ card poker hands from a standard $52$ card deck and determine how many are $2$ pair hands.

We already know that the correct count is about $123,552 / 2,598,960$ which is about $4.75$% but I am using this example because it has a reasonable # of outcomes to be simulated in any proportion from $0$ to $100$% and because we can use it to check the accuracy of the partial simulation easily.

I would like if someone could simulate a subset of these hands using some simulation software and perhaps build a small table with 5 columns, namely:

1. Number of hands evaluated
2. % of total possible hands
3. Number of winners found
4. Extrapolated winners expected
5. Actual error

So for example, a good starting point would be to simulate $1$% of the roughly $2.6$ million possible outcomes so that would be about $26,000$. So for our table we would fill in the following:

1. $26,000$
2. $1$%
3. ? (we would expect around $1236$)
4. $100$ * whatever we actually get in # $3$.
5. how far off are we from the expected $1236$ in %?

I'd also be curious of what type of sampling method you used such as random or something else. For example, would you just choose $5$ random cards $26,000$ times and check for a 2 pair? Would that be the best method in this case or would something other than random be more appropriate?

I would like to see the results of some other sample sizes too like $0.01$% ($260$ hands), $0.1$% ($2600$ hands) and $2$% ($52,000$ hands).

Can Mathematica and/or other simulation software handle this problem easily? If so, does it automatically check that the same random hand is not generated multiple times for the same simulation or does that require separate programming or is it not a concern since it would be rare if the number of samples is small (such as $1$% or less of the total # of possible $5$ card hands)?

Assuming your random simulation is indeed random, generating the same hand more than once is not a problem: you do not have to remove duplicates or even have to check whether it has happened. Generating duplicate cards in the same hand would be a problem.

If the probability of an event is $p$ and you sample $n$ times then, using the binomial distribution, you would expect $np$ cases to occur, with a standard deviation of $\sqrt{np(1-p)}$. The ratio of these is $\sqrt{\frac{1-p}{np}}$. Thanks to the central limit theorem, you would expect $95\%$ to within about two standard deviations of the expected value.

For your example this give a mean of about $1236.0$ as you have said and a standard deviation of about $34.3$. The ratio in your example about $0.0278$ suggesting that about $95\%$ of simulations should be within $5.55\%$ of $1236$.

Change the sample size and you change $n$ in the calculations above. If it is small, you should use the binomial distribution directly rather than a Gaussian approximation, especially given the discreteness of the results.

• Can I get some "concrete" data please like someone run a random simulation of some number of trials of a $5$ card poker hand such as $2600$ and report back? I am anxious to see how close to the expected value of $124$ we actually get. Thanks. – David Sep 26 '14 at 10:28
• Here concrete data will tell you less than theory. But if you insist, $260$ attempts gave me $16$ two-pairs (but not full houses or fours-of-a-kind), $2600$ attempts gave me $114$ two-pairs, $26000$ attempts gave me $1263$ two-pairs, and $260000$ attempts gave me $12425$ two-pairs. Consistent with my answer but less informative. – Henry Sep 26 '14 at 12:13
• That is informative thanks. It seems like the Monte Carlo method works when you don't need an exact count/probability but rather just an approximation. However if there were trillions (or more) of possible outcomes to consider, then the % we could actually simulate in a reasonable amount of time would go way down and the possible error would likely go way up. Notice that the $16$ you got here out of $260$ has the greatest % error since it should be a theoretical $12.4$ count so that is about $29$% too high an estimate but I would say it is "ballpark" (although in the "nosebleed" section). – David Sep 26 '14 at 12:49
• The sample error does not really depend on the population size (at least not until they are the same order of magnitude and you are sampling without replacement). My expression $\sqrt{\frac{1-p}{np}}$ indicates how the likely magnitude of the relative error changes with the sample size, and is unaffected by whether there are millions, or billions, or trillions of possibilities in the original population. – Henry Sep 26 '14 at 13:18
• Also your formulas are informative but sometimes we don't know p, that is why we are simulating it. For example, in my original problem of drawing $27$ cards from $54$. I don't even have a feel for what a "ballpark" answer would be on that and because it has about $2$ quadrillion card combinations, even a simulation would likely be considerably off. – David Sep 26 '14 at 13:35