File Exchange

image thumbnail

Texas Holdem Win Probabilities

version (5.3 KB) by Oliver Rice
Calculates the probability of each player winning a round of Texas Holdem


Updated 07 May 2012

View License

The CardAnalyze function estimates the probability of each player at a table of Texas Holdem winning the round.

Variable inputs are accepted for number of players, player's cards, cards on the table, and number of Monte Carlo iterations to use in estimating probabilities.

The function is able to operate at 3 levels of information

Only one player's cards are known

All players' cards are known

Some of the players' cards are known, some are not.

A 1.7ghz dual core processor is able to calculate 10,000 iterations for 6 players in under 1 second.

Starting a matlab pool will yield a notable speed increase
'matlabpool local'

If speed is still a concern, over half the computational time is spent on the loop call of 'randpermut'. This would be an area to improve.

The original purpose of the function was to develop strategies for identifying player collusion via machine learning.

Cite As

Oliver Rice (2020). Texas Holdem Win Probabilities (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (9)


Great tool!


i found out that the actual probabilities are shown when all cards,flop turn river are in the table.
is it normal? shouldnt it be better to show the actual probabilities an any stage of the program?


Hello Oliver!
i find this a very very nice job, however i i have an issue here:


that means i have a flush royal on the flop,however the probalities i take are these:
ans =


but of my course my probality should be 1
any idea why this happens?


Hi Oliver,

I have the same problem as described below. When running the process the following error appears:
??? Error: File: CardAnalyze.m Line: 130 Column: 11
Expression or statement is incorrect--possibly unbalanced (, {, or [.

I think it is because of the expression [~,Loc] which is not allowed.

Thanks in advance



Oliver Rice

Okay, lets try this. The simplest inputs you can give are


This is random cards for every player. It will return a list of 6 win probabilities (1 per player) that should all be equal to within half a percent.

It sounds like you will be running using 'standard' information. So lets now try adding 2 cards in your hand and estimating the probability of winning.


The above will return the probability of you winning with pocket 2s pre-flop.

And now finally, when the flop, turn and river go on the board you can add them into the 'table' parameter like so.


So now it is estimating again with a 4 of suit 2, a jack of suit 1 and a 12 of suit 3 on the table. The choice of which suit equals which decimal is up to you, just keep it consistant. Also, as people fold, you can adjust the 6 to represent the number of players remaining in the hand.

Let me know if you have any trouble.

saurabh korgaonkar

thanks actually am also new to matlab file-exchange.
I wanted to try out your program against texas hold'em in Facebook.
currently i just played your demo program and had the following error
Can you give me some set of sample values just so i know the working of the program if i am doing it wrong

Oliver Rice


I am not able to recreate your error. Please list the inputs you are using and I'll do my best to troubleshoot for you.


saurabh korgaonkar

??? Error: File: CardAnalyze.m Line: 130 Column: 11
Expression or statement is incorrect--possibly unbalanced (, {, or [.

Error in ==> DemoCardAnalyze at 31
WinProb = CardAnalyze(Hand,Table,nPlayers,nIter);

MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux