Conditional distribution of one random variable given another, find $f_{X|Y =1}(2)$

89 Views Asked by At

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$

1

There are 1 best solutions below

0
On BEST ANSWER

You want $f_{X|Y=1}(2)$, which is the probability that $X=2$, given that $Y=1$. That's equal to the probability $$ \frac{P(X=2,Y=1)}{P(Y=1)}. $$ To calculate $P(Y=1)$, you want the probability that you pick exactly one king in a draw of four, and the other three should not be kings. You choose one king out of $4$ which will appear in your draw, so that's $\binom{4}{1}$. In your first attempt, you forgot to account for the fact that the other cards must not be kings. That's why that attempt was wrong.

In any case, that's three "not kings" which must be picked out of a total of $48$ cards which are not kings. This leads to $\binom{48}{3}$. The number of picking $4$ cards out of $52$ is $\binom{52}{4}$, hence $P(Y=1) = \frac{\binom{4}{1}\binom{48}{3}}{\binom{52}{4}}$.

What about the numerator? Well, you need exactly one king, so that's a $\binom{4}{1}$ like last time. Next, you need two queens out of four, so that's $\binom{4}{2}$. What about the last card? It must not be a queen or a king, and there are $44$ such cards. The $\binom{52}{4}$ still stays as the denominator of this particular term, and we are led to $\binom{\binom{4}{1}\binom{4}{2}\binom{44}{1}}{\binom{52}{4}}$. Thus, the answer is (after the $\binom{52}{4}$s cancel out) $$ \frac{\binom{4}{1}\binom{4}{2}\binom{44}{1}}{\binom{4}{1}\binom{48}{3}} = \frac{\binom{4}{2}\binom{44}{1}}{\binom{48}{3}} = \frac{33}{2162}. $$


What is the mistake in your code, though? The mistake is the following : you write

  # Calculate the joint PMF for X = x and Y = y
  prob = X[x] * Y[y]

The mistake is here. The joint PMF for $X=x$ and $Y=y$ is not the product of the probabilities of $X=x$ and $Y=y$ (although , I commend you for one very important correct thing you've done : the individual distributions of $X$ and $Y$ are indeed binomial random variables with the correctly identified parameters. Well done!)

Remember that the joint distribution is the product of the individual probabilities precisely when the random variables in question are independent. However, $X$ and $Y$ are clearly not independent. For example, if $X=4$, then necessarily $Y=0$, because if you drew $4$ queens, then you have obviously not drawn any kings. So obviously, $P(X=4,Y=1) = 0 \neq P(X=4) \times P(Y=1)$.


What I glean from your attempt is that you should perhaps look to argue more from first principles. While the identification of the binomial random variables is honestly an excellent spot, the "textbook" method here would be to use first principles to calculate the number of favorable outcomes in which $X=2,Y=1$, and in which only $Y=1$ respectively. You need to ensure that each card which is chosen in the favorable set is counted for : if $X=3$, then that's three queens and a non-queen, for example.