# Joint and Posterior Distributions of Continuous and Discrete R.V.s

Consider random variables $$P$$ and $$X$$ where $$P \sim Uniform(0,1)$$ and $$X|P \sim Binomial (1, P)$$. For any $$s \in [0,1]$$, calculate both $$\mathbb{P}(P \leq s, X = 0)$$ and $$\mathbb{P}(P \leq s, X = 1)$$.

I have an intuition on what to do, but I am having trouble justifying it rigorously and would like some assistance. This is what I have:

For $$s \in [0,1]$$,

$$\mathbb{P}(P \leq s, X=0) = \int_0^s \mathbb{P}(X=0|P=p)f_P(p)dp$$ $$=\int_0 ^s \frac{1}{1-0}(1-p)dp = s - \frac{s^2}{2}$$

The first part is from the PDF of a uniform distribution, the second part of the integral comes from drawing a "tail" for $$X$$. Yet since $$X$$ is discrete, I am not sure if I am allowed to move it inside the integral. I understand that there may be many flaws to my approach, so please enlighten me.

Calculate the conditional distribution of $$P$$ given $$X=1$$.

My attempt: $$\mathbb{P}(P \leq s | X = k) = \frac{\mathbb{P}(P \leq s, X = k)}{\mathbb{P}(X=k)}$$

From previous problem, we know that $$\mathbb{P}(P \leq s, X = k) = \frac{s^2}{2}$$ when $$k=1$$. Then $$\mathbb{P}(X = 1) = \int_0 ^1 \mathbb{P}(X=1 | P = p) f_P(p)dp=\int_0^1 p \frac{1}{1-0}dp=\frac{1}{2}$$

Thus $$\mathbb{P}(P\leq s|X=1) = \frac{s^2}{2} \cdot \frac{1}{\frac{1}{2}}=s^2$$ and finally, $$f_{P|X=1}(s)=\frac{d}{ds} \mathbb{P}(P \leq s |X=1)=\frac{d}{ds}s^2=2s$$

We should take the joint distribution $$f_{X,P}(x,p)=\mathbb P(X=x|p)\cdot f_P(p)$$ and integrate/sum it along the region defined by $$X=0$$ and $$P: $$\mathbb P(P
Your final result is correct, but the step $$\mathbb{P}(P \leq s, X=0) = \mathbb{P}_P (P\leq s) \cdot \mathbb{P}_{X | P=p}(X=0)$$ is not correct. The actual result from the product rule is $$\mathbb{P}(P \leq s, X=0) = \mathbb{P}_P (P\leq s) \cdot \mathbb{P}_{X | P\leq s}(X=0)$$, which not really useful here. The integral you wrote after it is right though, since it is the integral of the joint probability distribution over the region of interest.