Question 1164034
```python?code_reference&code_event_index=1
from itertools import combinations

# Box contents: 1 Yellow (Y), 2 Red (R1, R2), 3 Green (G1, G2, G3)
balls = ['Y', 'R1', 'R2', 'G1', 'G2', 'G3']

# Sample space: Choosing 2 balls without replacement
S = list(combinations(balls, 2))
n_S = len(S)

def is_yellow(combo):
    return any('Y' in b for b in combo)

def is_red(combo):
    return any('R' in b for b in combo)

def is_green(combo):
    return all('G' in b for b in combo)

def same_color(combo):
    b1, b2 = combo[0][0], combo[1][0]
    return b1 == b2

# Events
A = [c for c in S if is_yellow(c)]
B = [c for c in S if is_red(c)]
C = [c for c in S if is_green(c)]
D = [c for c in S if same_color(c)]

# (a) P(A|B) = P(A and B) / P(B)
A_and_B = [c for c in A if c in B]
p_a_given_b = len(A_and_B) / len(B)

# (b) P(B^c | D) = P(B^c and D) / P(D)
not_B = [c for c in S if c not in B]
not_B_and_D = [c for c in not_B if c in D]
p_not_b_given_d = len(not_B_and_D) / len(D)

# (c) P(D | C^c) = P(D and C^c) / P(C^c)
not_C = [c for c in S if c not in C]
D_and_not_C = [c for c in D if c in not_C]
p_d_given_not_c = len(D_and_not_C) / len(not_C)

print(f"n(S): {n_S}")
print(f"n(A): {len(A)}, n(B): {len(B)}, n(C): {len(C)}, n(D): {len(D)}")
print(f"n(A and B): {len(A_and_B)}")
print(f"P(A|B): {len(A_and_B)}/{len(B)}")
print(f"P(B^c|D): {len(not_B_and_D)}/{len(D)}")
print(f"P(D|C^c): {len(D_and_not_C)}/{len(not_C)}")


```
```text?code_stdout&code_event_index=1
n(S): 15
n(A): 5, n(B): 9, n(C): 3, n(D): 4
n(A and B): 2
P(A|B): 2/9
P(B^c|D): 3/4
P(D|C^c): 1/12

```
To solve these conditional probabilities, we first determine the total number of outcomes in the sample space and the number of outcomes for each event.

The box contains **6 balls**: 1 Yellow ($Y$), 2 Red ($R$), and 3 Green ($G$).
The total number of ways to choose 2 balls without replacement is:
$$n(S) = \binom{6}{2} = 15$$

---

### **Step 1: Define the Event Counts**
* **Event A (One ball is Yellow):** This means choosing the 1 Yellow ball and 1 from the other 5 balls.
  $n(A) = \binom{1}{1} \times \binom{5}{1} = 5$
* **Event B (At least one Red):** Total outcomes minus outcomes with no Red.
  $n(B) = 15 - \binom{4}{2} = 15 - 6 = 9$
* **Event C (Both Green):** Choosing 2 from the 3 Green balls.
  $n(C) = \binom{3}{2} = 3$
* **Event D (Same Color):** Both Red or Both Green. (Yellow only has one ball, so "Both Yellow" is impossible).
  $n(D) = \binom{2}{2} (\text{Red}) + \binom{3}{2} (\text{Green}) = 1 + 3 = 4$

---

### **Step 2: Calculate the Conditional Probabilities**

**(a) $P(A \mid B)$**
We need $n(A \cap B)$, which is the number of ways to have 1 Yellow ball **and** at least one Red ball. Since we only pick 2 balls, this must be exactly 1 Yellow and 1 Red.
$n(A \cap B) = \binom{1}{1} \times \binom{2}{1} = 2$
$$P(A \mid B) = \frac{n(A \cap B)}{n(B)} = \frac{2}{9}$$

**(b) $P(B^c \mid D)$**
$B^c$ is the event "No Red balls." We need $n(B^c \cap D)$, which is the number of ways the balls are the same color **and** neither is Red. This leaves only the "Both Green" option.
$n(B^c \cap D) = \binom{3}{2} = 3$
$$P(B^c \mid D) = \frac{n(B^c \cap D)}{n(D)} = \frac{3}{4}$$

**(c) $P(D \mid C^c)$**
$C^c$ is the event "Not both Green." 
$n(C^c) = n(S) - n(C) = 15 - 3 = 12$
$n(D \cap C^c)$ is the number of same-color pairs that are **not** Green. This leaves only the "Both Red" option.
$n(D \cap C^c) = \binom{2}{2} = 1$
$$P(D \mid C^c) = \frac{n(D \cap C^c)}{n(C^c)} = \frac{1}{12}$$

---

### **Final Results:**
* (a) $P(A \mid B) = \mathbf{2/9}$
* (b) $P(B^c \mid D) = \mathbf{3/4}$
* (c) $P(D \mid C^c) = \mathbf{1/12}$