Transformation of Random variable Suppose I have $N$ random variables $\{X_i\}_{i=1}^N$, and I want to calculate the expectation of a function of these random variables:
$$\mathbb{E}[g(X_1,\cdots,X_N)h(X_1,\cdots,X_J)]=\int g(X_{1},\cdots,X_N) h(X_1,\cdots,X_J) f(X_1,\cdots , X_N)\, dX_1 \cdots X_N, $$
where $g(\cdot)$ and $h(\cdot)$ are functions of random varialbes, $J<N$, and $f(\cdot)$ is the joint density of $\{X_i\}_{i=1}^N$.
I wonder if there exists some density $\tilde{f}(\cdot)$ of $\{X_i\}_{i=1}^J$ and $Y$, where $Y = g(X_{1},\cdots,X_N)$ so that
$$\mathbb{E}[g(X_1,\cdots,X_N)h(X_1,\cdots,X_J)] = \int Yh(X_1,\cdots,X_J)\tilde{f}(X_1,\cdots,X_J,Y)\,dX_1\cdots X_J Y $$

By using conditional expectation (double projection),
\begin{align*}\mathbb E[g(X_1,\cdots,X_N)&h(X_1,\cdots,X_J)]\\
&=\mathbb E[\mathbb E[g(X_1,\cdots,X_N)h(X_1,\cdots,X_J)|(X_{1},\cdots,X_J)]]\\
&=\mathbb E[\mathbb E[g(X_1,\cdots,X_N)|(X_{1},\cdots,X_J)]h(X_1,\cdots,X_J)]\\
&=\mathbb E[\mathbb E[Y|(X_{1},\cdots,X_J)]h(X_1,\cdots,X_J)]\\
&=\int y h(x_1,\cdots,x_J)~p(y|x_1,\cdots,x_J)q(x_1,\cdots,x_J) ~\text dx_1\ldots\text dy
\end{align*}
assuming the conditional distribution of $Y$ given $(X_{1},\cdots,X_J)$ enjoys a density wrt the measure $\text dy$.
