View Full Version : [SLEEPER:] probability of getting a pair in poker in excel
k3j4h5g6
07-03-2024, 08:01 AM
I'm working on a probability problem related to poker, and I could really use some help with figuring out how to calculate it in Excel. Here’s the scenario:
In a game of poker, you're dealt 5 cards from a standard deck of 52 cards. I want to determine the probability of getting at least one pair (i.e., two cards of the same rank) in my hand.
I understand that this involves some combinatorial calculations, but I'm not sure how to set it up properly in Excel. I've been playing poker online and this question came up because I'm interested in evaluating my chances of winning. Could someone help me verify if this approach is correct and guide me on how to properly set up these calculations in Excel?
Paul_Hossler
07-03-2024, 10:51 AM
31692
Aussiebear
04-18-2025, 04:03 AM
Kind of bored tonight so.... is this a different version?
' Function to calculate combinations (nCr)
Function Combinations(n As Integer, r As Integer) As Double
' Handle cases where r is invalid
If r < 0 Or r > n Then
Combinations = 0
' Handle base cases for combinations
ElseIf
r = 0 Or r = n Then
Combinations = 1
' Optimize calculation by choosing the smaller 'r'
ElseIf
r > n / 2 Then
Combinations = Combinations(n, n - r)
' Calculate the combination iteratively
Else
Dim result As Double
result = 1
For i = 1 To r
result = result * (n - i + 1) / i
Next i
Combinations = result
End If
End Function
Sub CalculatePairProbability()
' Declare variables to store the calculated values
Dim totalPossibleHands As Double
Dim handsWithNoPair As Double
Dim probabilityOfNoPair As Double
Dim probabilityOfAtLeastOnePair As Double
' 1. Calculate the total number of possible 5-card hands
totalPossibleHands = Combinations(52, 5)
' 2. Calculate the number of 5-card hands with NO pairs
' a) Choose 5 distinct ranks from 13 available ranks
Dim numberOfRankCombinations As Double
numberOfRankCombinations = Combinations(13, 5)
' b) For each of these 5 ranks, choose 1 of the 4 suits
Dim numberOfSuitCombinations As Double
numberOfSuitCombinations = 4 ^ 5 ' 4 choices for each of the 5 cards
' c) Total number of "no pair" hands
handsWithNoPair = numberOfRankCombinations * numberOfSuitCombinations
' 3. Calculate the probability of getting NO pairs
probabilityOfNoPair = handsWithNoPair / totalPossibleHands
' 4. Calculate the probability of getting AT LEAST ONE pair
' This is 1 minus the probability of getting no pairs
probabilityOfAtLeastOnePair = 1 - probabilityOfNoPair
' Display the result to the user
MsgBox "The probability of getting at least one pair in a 5-card hand is approximately: " & Format(probabilityOfAtLeastOnePair, "0.00%")
End Sub'
' --- End of Module Level Code ---
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.