If we have two discrete random variables $X$ and $Y$, $$p_X(x) = \sum_y p_{XY}(x,y) = \sum_y p_{X|Y}(x|y)p_Y(y) = \sum_y \mathbb{P}(X = x|Y=y) \mathbb P(Y=y)$$
Similarly, if we have two continuous random variables $X$ and $Y$, $$p_X(x) = \int_y p_{XY}(x,y) dy = \int_y p_{X|Y}(x|y)p_Y(y) dy $$
However, I am slightly confused about what happens when one is continuous and one is discrete. For example, if $X$ is continuous and $Y$ is discrete, I want to say: $$p_X(x) = \sum_yp_X(x,Y=y) = \sum_y p_X(x|Y=y)p_Y(y) = \sum_y p_X(x|Y=y)\mathbb P(Y=y) $$ This looks intuitively right, but I am also a bit stuck on the notation.
I'm not sure if a joint distribution exists for $X$ and $Y$ in the case that one is continuous and one is discrete, so I'm not sure it would be correct in the above to say: $$p_X(x) = \sum_yp_{XY}(x,Y=y)$$
However, $p_X(x) = \sum_yp_X(x,Y=y)$ doesn't look quite right to me either.
I am similarly unsure about what happens if we want to obtain $p_Y(y)$ (if $X$ is continuous and $Y$ is discrete as above). I know we would have to integrate over $x$, but I am struggling to come up with an expression for the marginalisation with notation that makes sense.
I would appreciate some clarity on this.
If $X$ is a real-valued continuous random variable and $Y$ is discrete with values in some countable set $E$, then there exists a map $p_{XY}:\mathbb R\times E\to\mathbb R$ such that $$ \forall A\textrm{ measurable }\subset\mathbb R,\quad\forall y\in E,\quad\mathbb P(X\in A,Y=y)=\int_Ap_{XY}(x,y)\,dx. $$
In that case, the marginal distribution of $X$ has density $p_X$ defined by $$ \forall x\in\mathbb R,\quad p_X(x)=\sum_{y\in E}p_{XY}(x,y), $$ and the marginal distribution of $Y$ is given by $$ \forall y\in E,\quad\mathbb P(Y=y)=\int_{\mathbb R}p_{XY}(x,y)\,dx. $$