A poker hand consists of 5 cards dealt at random without replacement from a standard deck of 52 cards of which 26 are red and the rest black. A poker hand is dealt. Find the chance that the hand contains three red cards and two black cards.
To achieve it, we use the hypergeometric probability mass function. We want 3 cards from the set of 26 red cards and 2 from the set of 26. So the parameters for the hypergeometric function are:
M = 52 # Total number of cards n = 26 # Number of Type I cards (e.g. red cards) N = 5 # Number of draws (5 cards dealt in one poker hand) k = 3 # Number of Type I cards we want in one hand
In SciPy we can get the probability
import scipy.stats as ss hpd = ss.hypergeom(M, n, N) p = hpd.pmf(k)