# In a card game, how to check if hand patterns are fair?

I'm playing contract bridge and the boards are dealt by a machine. Last time, one of the player suggested the boards are not dealt at random and I want to check that.

At contract bridge, each player receive 13 cards from a deck of 52 cards. It's possible to categorize the hand of a player by its pattern. For instance, a 5-4-3-1 hand is a hand with 5 cards in one suit, 4 cards in another, 3 cards in the third one and just 1 card in the last one. The probabilities to have a specific hand pattern if the distribution is fair are known. For a 5-4-3-1 hand, we have a probability of 12.931%.

Now, I want to design a protocol to check if the distribution is fair or not. My null hypothesis is "the distribution is fair" and my alternative hypothesis is "the distribution is unfair". My question is: is the following protocol sufficient to accept or reject my alternative hypothesis?

I want to use a Z-test for each hand pattern (39 different hand patterns). The idea is to count the frequency of each hand pattern over a sample of n different boards. Bonus question: what minimum value of n should I choose to have a 95% confidence interval?

The problem of the Z-test is I will have 39 different tests. What if some of them accept the alternative hypothesis and some others reject it? How can I sum the results to get a unique result? I would like to be able to say: "I'm sure the board distribution is fair at x percent."

Last point, this protocol just check the hand patterns but I want to do the same verification on the high cards points of each hand. Can I follow the same protocol? What if there are different results?

If you know the expected probability of each hand pattern under the null of 'fair distribution', you can use Pearson's chi-squared test to test if your sample is from that distribution.

You can even create a Monte Carlo test when the observed frequencies are too small and the chi-squared approximation of the null distribution may not be correct.

• You're right, I guess Pearson's chi-squared test is a better test in my case. But, I'm not sure to understand what you mean by using a Monte Carlo for small frequencies. Commented Dec 27, 2018 at 12:43
• Instead of relying on the asymptotic (chi-squared) distribution of the test statistic, you can generate draws from the data generating process under the null (i.e. the fair distribution) and use these draws to approximate the null distribution. This gives a much better approximation when your dataset is small and you have low expected counts for certain hand patterns. Commented Dec 27, 2018 at 15:16

The challenge here is that your friend's hypothesis is too broad. Actually, any sample could be derived "randomly" or "deterministically". As you say, any particular deal has low likelihood on a "random" hypothesis, and can be "explained" by a sufficiently complicated deterministic hypothesis.

Is s/he suggesting e.g. that it is an advantage to sit on the left of the mechanical dealer? Then I suggest that you swap hands after every other deal, and keep track of the results.

Fairness isn't quite the same as randomness, but a simple test of fairness is: how often does hand 1 have more points than hand 2? Other similar ones are: does hand 1 have a void more often that hand 2? The statistics for these are fairly simple.

• I mean by fair the frequencies of the hand patterns we get respect the probabilities when the deck of cards is shuffle totally randomly. The hypothesis of my friend doen't suggest there is an advantage to be sit in a place rather another one but the suit distribution are not totally random. In other words, he suggests the mechanical dealer dealt more irregular hands than if a human deal with a random deck of cards. Commented Dec 26, 2018 at 12:37
• That ( the mechanical dealer deals more irregular hands than if a human dealt them) is - providing we sufficiently define 'irregular' - a specific hypothesis which could be tested, though there's no reason whatever to suppose that humans produce random deals; the question then is whether you want to compare the mechanical device to actual randomness or to human deals. Commented Dec 27, 2018 at 2:26

I'd suggest that you have a look at the cusum test. You know the pdf $$p(h,\theta)$$ where $$h$$ is any given hand and $$\theta$$ is the parameters of your pdf $$p$$. What cusum will help you do is ask the question "given the last $$k$$ draws, is it more likely that the hands were drawn from some other distribution $$p(h,\theta_a)$$?".

The cusum test comes from quality control and detection of structural change, and it'll even in the case where your process is mostly fair but sometimes not (rather than unfair all the time).

You say "The problem of the Z-test is I will have 39 different tests. What if some of them accept the alternative hypothesis and some others reject it? How can I sum the results to get a unique result?".

If you are neutral about which distributions are more common then they should be, then this is the "false discovery rate" problem. See the paper by Benjamini and Hochberg.

But it seems like your friend believes that "interesting" hands are too common. I suggest that you make an exact definition of "interesting". Then you can compare the observed frequency with the predicted frequency. I suggest also that you do the analysis for only one hand, e.g. the one on the left of the dealer, because otherwise the conditional probabilities get complicated.