For two random variables $x$ and $y$, if I can sample from the joint distribution $p(x, y)$, I can obtain samples from the marginal $p(x)$ by sampling from the joint distribution and ignoring the values of $y$. I want to make a formal argument for this. Something like:
$$ \begin{align} \mathbb{E}_{x \sim p(x)} [f(x)] &= \int_{x \in \mathcal{X}} f(x)\,p(x)\,dx \\ &= \int_{x \in \mathcal{X}} f(x)\,\int_{y \in \mathcal{Y}} p(x, y)\,dy\,dx \\ &= \int_{x \in \mathcal{X}} \int_{y \in \mathcal{Y}} f(x)\,p(x, y)\,dy\,dx \\ &= \mathbb{E}_{x, y \sim p(x, y)} [f(x)] \end{align} $$
Is this a reasonable argument?