To calculate \( P(D) \), the probability of generating document \( D \), we can use the law of total probability:
\[ P(D) = P(D | y=+) P(y=+) + P(D | y=-) P(y=-) \]
We are given the following values:
- \( P(y=+) = 0.3 \)
- \( P(y=-) = 1 - P(y=+) = 1 - 0.3 = 0.7 \)
- \( P(D | y=+) = 0.3 \)
- \( P(D | y=-) = 0.6 \)
Now substitute these values into the equation for \( P(D) \):
\[ P(D) = P(D | y=+) P(y=+) + P(D | y=-) P(y=-) \]
\[ P(D) = (0.3)(0.3) + (0.6)(0.7) \]
Calculating each term:
\[ P(D) = 0.09 + 0.42 \]
\[ P(D) = 0.51 \]
Now, to find the posterior probability \( P(y=+ | D) \) using Bayes' theorem:
\[ P(y=+ | D) = \frac{P(D | y=+) P(y=+)}{P(D)} \]
Substituting the values:
\[ P(y=+ | D) = \frac{(0.3)(0.3)}{0.51} \]
Calculating the numerator:
\[ P(y=+ | D) = \frac{0.09}{0.51} \]
Calculating:
\[ P(y=+ | D) \approx 0.1765 \]
Rounding to two decimal places:
\[ P(y=+ | D) \approx 0.18 \]
In summary:
- \( P(D) \approx 0.51 \)
- \( P(y=+ | D) \approx 0.18 \)