From a well shuffled deck of $52$ cards, four cards are selected at random. Let the random variable $X$ denote the number of queens drawn, and let the random variable $Y$ denote the number of kings drawn. Find $f_{X|Y =1}(2)$.
How to solve this problem?
Here is the lecture notes I'm following: The conditional distribution of one random variable given another: Suppose $X$ and $Y$ are jointly distributed discrete random variables with joint PMF $f_{XY}$. The conditional PMF of $Y$ given $X=t$ is defined as the PMF $f_{Y|X=x}(y)$:
$ f_{Y|X=x}(y) = \frac{{P(X=x, Y=y)}}{{P(X=x)}} = \frac{{f_{XY}(x, y)}}{{f_X(x)}} $
We denote the conditional random variable by $Y|(X=x)$. Note that $Y|(X=x)$ is a valid random variable with PMF $f_{Y|(X=x)}$.
Properties:
- The range of $Y|(X=t)$ can be different from the range of $Y$ and will depend on $t$.
- $f_{XY}(x, y) = f_{Y|X=x}(x, y) \cdot f_X(x) = f_{X|Y=y}(x, y) \cdot f_Y(y)$
- $\sum_{y \in \text{range}(Y)} f_{Y|X=x}(y) = 1$
Here is how I'm tying to solve it: To find $f_{X|Y=1}(2)$, we need to calculate the conditional probability of $X$ being equal to $2$ given that $Y$ is equal to $1$.
We know that the joint PMF of $X$ and $Y$ is given by $f_{XY}(x, y)$, and the conditional PMF of $X$ given $Y=1$ is denoted as $f_{X|Y=1}(x)$.
Using the formula for conditional probability: $ f_{X|Y=1}(x) = \frac{{f_{XY}(x, 1)}}{{f_Y(1)}} $
In our case, we have to find $f_{X|Y=1}(2)$, which means we need to calculate the probability of $X$ being equal to $2$ when $Y$ is equal to $1$.
Now let's substitute the values into the formula: $ f_{X|Y=1}(2) = \frac{{f_{XY}(2, 1)}}{{f_Y(1)}} $
To find the values of $f_{XY}(2, 1)$ and $f_Y(1)$, we need to determine the number of favorable outcomes in the deck of cards that satisfy $X=2$ and $Y=1$, respectively.
In this case, to have $X=2$, we need exactly $2$ queens out of the $4$ cards drawn. There are ${4 \choose 2}$ ways to choose $2$ queens from the $4$ available.
To have $Y=1$, we need exactly $1$ king out of the $4$ cards drawn. There are ${4 \choose 1}$ ways to choose $1$ king from the $4$ available.
Therefore, we have:
$ f_{XY}(2, 1) = \frac{{\binom{4}{2} \cdot \binom{4}{1}}}{{\binom{52}{4}}} $
$ f_Y(1) = \frac{{\binom{4}{1}}}{{\binom{52}{4}}} $
Substituting these values into the formula, we can find $f_{X|Y=1}(2)$:
$ f_{X|Y=1}(2) = \frac{{\frac{{\binom{4}{2} \cdot \binom{4}{1}}}{{\binom{52}{4}}}}}{{\frac{{\binom{4}{1}}}{{\binom{52}{4}}}}} $
Simplifying this expression will give us the value of $f_{X|Y=1}(2) = 6.0$.
And the answer is absolutely wrong. How to even learn this subject?
Update Another attempt to solve the problem: Given:
- X: Number of queens drawn
- Y: Number of kings drawn
- We need to find $f_{X|Y=1}(2)$, which represents the conditional probability of X being 2 given that Y is 1.
Probability of getting a queen is $\frac{4}{52} = \frac{1}{13}$
Probability of getting a king is $\frac{4}{52} = \frac{1}{13}$
The Uniform random variable x,y $\in \{{0,1,2,3,4}\}$
To get the binomial distribution: The binomial distribution describes the probability distribution of the number of successes in a fixed number of independent Bernoulli trials, each with the same probability of success. It is characterized by two parameters: the number of trials, denoted by $n$, and the probability of success in each trial, denoted by $p$.
The probability mass function (PMF) of the binomial distribution is given by the equation:
$ P(X = k) = \binom{n}{k} \cdot p^k \cdot (1 - p)^{n - k} $
where:
- $P(X = k)$ represents the probability of having exactly $k$ successes in $n$ trials.
- $\binom{n}{k}$ is the binomial coefficient, which counts the number of ways to choose $k$ successes out of $n$ trials.
- $p^k$ represents the probability of having $k$ successes.
- $(1 - p)^{n - k}$ represents the probability of having $n - k$ failures.
In this equation, the sum of the probabilities for all possible values of $k$ from 0 to $n$ will equal 1, as it covers all possible outcomes of the binomial experiment.
# Lets get the binomial distribution
from scipy.stats import binom
p = 1/13
n = 4
X = []
for i in range(0,5):
X.append(binom.pmf(i, n, p))
print(X)
Y = X
# Calculate joint pmf
joint_pmf = []
for x in range(5): # Values of X (number of queens)
row = []
for y in range(5): # Values of Y (number of kings)
# Calculate the joint PMF for X = x and Y = y
prob = X[x] * Y[y]
row.append(prob)
joint_pmf.append(row)
Print the joint PMF table
print("Joint PMF:")
for x in range(5):
for y in range(5):
print(f"P(X={x}, Y={y}) = {joint_pmf[x][y]:.6f}")
print()
Calculate the conditional probability f_{X|Y=1}(2)
conditional_prob = joint_pmf[2][1] / sum(joint_pmf[x][1] for x in range(5))
from IPython.display import display, Markdown
display(Markdown(f"$f_{{X|Y=1}}(2) = {conditional_prob:.6f}$"))
And yet another time got wrong answer as $f_{X|Y=1}(2)=0.030251$