The Statistics of Ngau-ngau, a Chinese Gambling Card Game

Tyson Wu
10 min readAug 29, 2020

--

“Ngau-ngau”, a Chinese gambling card game. Is it risky to play?

Ngau-ngau, translated to Cow-cow in Cantonese. Photo by Luca Basili on Unsplash

Introduction and Motivation

Hi there! My name is Tyson Wu. Today we will be looking at a gambling card game popularised in Hong Kong called “Ngau-ngau”. Ngau, meaning cow in Cantonese, is a card game involving a banker and multiple players ranging from 2 to 9, with a setting similar to Blackjack. However, this card game do not require any slightest human decision.

As a card game purely win or lose by luck, it is not possible to make any strategy and profit from it. The game itself is quite exciting, but I do not always play with this gambling game due to the above reason. However, many of my friends do enjoy playing the game during gathering and in most of the time, the profit deviations among players are pretty large, usually resulting in greater spread than other similar by-luck gambling games such as Sic-bo. Hence, I am motivated to exploit the underlying statistical outlook of Ngau-ngau: How does the profit distribution looks like, and how risky it is to play the game as a banker or a player?

In this article, I will firstly introduce the game rules of Ngau-ngau, followed by an exhaustion of hand probabilities, and try to simulate the playing of Ngau-ngau with Monte Carlo techniques in Python. No need to worry if you are not familiar of any of these statistical jargons or programming language. I will explain them one-by-one.

Also, the source code of generating games and statistical analysis are provided as a Jupyter notebook. Feel free to consult the notebook and run your own simulation from it. Let’s begin!

Basic Game Rules

Me and my friends played a slightly modified version of Ngau-ngau, deviated from the rules introduced on Wikipedia. All the discussions in this article are based on the following rules:

Using the standard deck

The standard 52-card deck will be notated in the format of “suit-numeral”. The four suits are namely Club, Diamond, Heart, and Spade. The notation of 52 cards in the deck is exhausted as follows:

C1 C2 C3 ... C10 CJ CQ CKD1 D2 D3 ... D10 DJ DQ DKH1 H2 H3 ... H10 HJ HQ HKS1 S2 S3 ... S10 SJ SQ SK

In Ngau-ngau, suits are neglected and cards are assigned with numerical values according to their face value, where A=1, 2=2, … 10=10, Jacks=10, Queens=10, and Kings=10.

At the start of game

In a group of n people, one person will be the banker and the others will be players.

In the beginning of each round, the banker deals 5 cards randomly to everyone including the banker himself. Everyone then reveal the cards they have, and try to arrange their cards so that the last digit of numerical sum of exactly 3 out of 5 cards is 0. For example, 3+2+5=10, or 7+7+6=20, or Jack+Jack+King=0. If the player could form their card in such arrangement, then the player is said to be “game-enabled” (in Cantonese, 開局).

On top of that, if the banker or players can form a set (a triplet) with their cards (such as 7,7,7), the set can also be used for “enabling the game”.

Situation 1: The player has game-enabling arrangement

The 3 cards used for “enabling the game” is put aside, and the remaining 2 cards will be used to “form the ngau” according to the last digit of the numerical sum of the 2 cards.

For example, if the 2 cards are 8 and 6 which forms the digit 4 (8+6=14), then the player is said to have the hand “ngau-4”.

Here are the possible “ngau-hands”:

ngau-1 (also called ngau-nail)
ngau-2
... up to
ngau-9
ngau-ngau (when the last digit is 0)
ngau-pair (when the two cards form a pair)

Situation 2: The player has no game-enabling arrangement

In such situation, the player is said to have “no-game”. The player can only find if he has one pair or two pairs in their hand, or else a high card.

Special situations

On top of the above arrangements, if the 5 cards are exclusively formed by {A,2,3,4}, the player is said to have the hand “all-small”. Similarly if the 5 cards are exclusively formed by {10,J,Q,K}, then the player is said to have the hand “all-big”.

Hand rankings

The “strength” of the hands is ordered as follows, in descending order:

all-big > all-small > ngau-pair > ngau-ngau
ngau-ngau > ngau-9 > ngau-8 > ... > ngau-1 > no-game

Determining the payoff

After everyone revealing their hands, the banker competes with the players one-by-one using the strength of their hands, with payoff as follows:

all-big    5x
all-small 5x
ngau-pair 5x
ngau-ngau 4x
ngau-9 3x
ngau-8 2x
ngau-7 2x
others 1x

For example on the basis of $1 per bet, the banker has “ngau-7” while player 1 has “ngau-3”. Player 1 has to pay $2 to the banker.

In the same round, player 2 has “all-small”. The banker has to pay $5 to player 2 . Note that the payoff is solely determined by the strength of the winning hand and the strength of the losing hand is irrelevant no matter how strong it is.

In case of a tie

For simplicity, if two hands have the same strength, then they result in a tie and the payoff will be zero. However, if both hands are “no-game” hands, they still compete in the manner of poker, where two-pairs > one-pair > high card.

Hand Probabilities

So, what are the chances of forming each hand? To answer this question, we can directly exhaust all possible combinations of cards.

Mathematically, in a standard deck of 52 cards, there are 52C5 = 2598960 ways to draw 5 cards from 52 cards. Not too small but not too big of a number that a computer cannot handle. I tried to calculate the strength of all possible combinations:

Probabilities of hands

Insight

We can see that on average, there are 32.4% chance resulting in “no-game”, and around 5–7% chance for each of the ngau-hands, and a very little chance of 0.168% of getting “all-small” or “all-big”. It is quite unbalanced that “all-big” and “all-small” hands only worth 5x return, and “ngau-7/8/9” worth more than other “ngaus” by rule.

The Simulation

For one session

So far, we have built a script that teaches the computer to arrange ngau-ngau hands. Now, we also want to construct virtual players and track their PnL (profit and loss) history and see what would happen. Let’s assume that there are 1 banker + 3 players (n=4) and they play ngau-ngau for 30 times (r=30) in one session (s=1):

Now, all the historical payoffs are stored in a PnL dictionary. Let’s visualise the payoffs using the plotly package in Python:

Payoff in one random session

It is obvious and reasonable to see the banker has a greater risk, or greater profit variance compare to all other players. In one session, the banker has a probability to win or lose more money than any other players.

Monte Carlo simulation

In the above example we have simulated the outcome of one single session. Indeed, we can conclude nothing from it. The banker has a great bankroll this time, but he can still lose more next time, or maybe not. Hence, we should run the session for a lot more times, and see the outcome of PnL of the banker in these sessions.

This is what we called Monte Carlo simulation — a technique of iterating the event for thousands, or even millions of times (if it is computationally not heavy), and extract the distribution or statistical figures.

What happens when we iterate the session for 2000 times (s=2000)?

If we plot the players’ PnL for every session using a histogram, we arrive to the following graph:

PnL Distribution

From the graph, we see that most PnLs are near the centralised around zero, and in very rare occasion, the banker could lose more than $100 or even win $200 for every $1 bet in 30 plays! The graph also clearly tells us that the risk (or variance) that the banker bears is significantly larger than the other players. For a player, it is very rare to win or lose over $40 in a session with 30 rounds of games.

So, what is the actual PnL distribution of the game?

If you are familiar with statistical distributions, you will quickly notice that this distribution resembles some traits of a standard normal distribution — something in bell shape and centred at zero. How can we verify, or describe the actual distribution?

To do so, we have to look at the statistical moments of the PnL data. Statistical distributions can be briefly described by the statistical moments. In simpler words, statistical moments are the parameters that describes “how does the distributional curve look like” and “the way the curve curves”. The four statistical moments are namely mean, variance, skewness, and kurtosis.

Statistical moments

Mean describes value where the curve is centred at. The mean of a standard normal distribution (commonly notated as Z), the mean is 0.

Variance describes how “broad” the curve is. A standard normal distribution has variance of 1.

Skewness describes whether the curve “leans” towards a certain direction. A standard normal distribution has skewness of 0. Positive skewness means that the curve “leans” towards the left side, and vice versa.

Kurtosis describes how “fat” the curve is in the two extremes. A standard normal distribution has kurtosis of around 0 (using Fischer’s definition if you ask), and a positive kurtosis implies that the “tails” of the curve is fatter than the one in a standard normal distribution.

Monte Carlo again with different number of players and rounds

If we are only concerned about the PnL distribution, it is clumsy and unnecessary to record every single PnL in every sessions. So instead of looking into every single record, we can only record the extracted statistical moments. In the following, we carry out Monte Carlo simulation again, but with 20000 iterations.

As we only extract the statistical moments of every session, we are now capable of doing a more generalized simulation: what if we iterate over the number of players and number of rounds in each session? Will it show a certain trend?

In the following simulation, we iterate over the number of players (n) and number of rounds (r). For example, we run 20000 sessions with n=3 and r=30, then extract the statistical moments for the result; then with n=3 and r=40,…,200, as we are curious about the effect of number of players and rounds towards the statistical moments of the distribution.

As we iterate over different possible combinations of n and r, the process is metaphorical to crawling over a grid of variables, and therefore called a grid search.

Also notice that I have implemented parallel computation in the above code, as this is a very resource-intensive process for a laptop computer.

After getting all the statistical moments with different values of (n,r) pairs, we shall visualise the results using heatmap and see if there is any trends behind. The following are the graphs of banker’s statistical moments from PnL data:

Results

Unsurprisingly, the mean is very close to zero, which means the banker does not have a positive value in this game. The kurtosis is also approximately zero implying a similar tail thickness as compared to a standard normal distribution. The standard deviation (a same metric as variance) is correlated to n and r — greater value of n and r causes a significantly greater PnL deviation. Now we have verified that the result can be fairly described as normal.

The verification is nowhere robust, but it is consistent with the law of large numbers, where the statistics always tends to a normal distribution.

So… what are the takeaways?

To all the ngau-ngau lovers, you may wonder what are the things that can be learned in this article. You have noticed that neither bankers or players possess a positive expected value from the game, and the PnL is nowhere controllable. However, with the variance heatmap from the above, you can now have a brief idea on how risky the game is.

For example, if you are the banker and you are planning to play ngau-ngau with 7 friends with 200 rounds, you should expect that the profit or loss can be extremely volatile. According to the heatmap, one standard deviation of PnL in this situation is around $200 for $1 bet in each round — implying that there are approximately 37% chance that your final PnL is positive and below $200 and in 95% of the time, your final PnL is within the range of 2 deviations, meaning that your final PnL can range from -$400 to $400, which is 400x of the betting amount.

With this estimation, you shall prepare your stack accordingly, and prepare for the worst outcome when the luck is not with you.

Codes in this Article

If you are interested in the algorithm behind the codes in this article, a separate Jupyter notebook is also available for viewing. A complete guide on the construction of hands arrangement and the simulation is given in the notebook.

There is also a GitHub repo available, which contains the script for Monte Carlo simulation in this article. Don’t hesitate to check it out!

References

--

--

Tyson Wu

Crypto quant. Passion in software engineering and quantitative trading. Sharing my learning through writing.