How do I numerically integrate $f(x) = \int x y p(y\mid x) dy$?

49 Views Asked by At

Suppose $X,Y$ follows a joint distribution $p(x,y)$ and we know that $X$ and $Y$ are not independent. Define

$$f(x) = \int x y p(y\mid x) dy$$

Suppose I can sample from $p(x,y)$. How can I numerically compute the integral?

I can get a sample of $\{x^{i},y^{i}\}_{i=1}^N$, compute $x^i y^i$, and compute the average, but that gives me $\int \int xy p(x,y) dx dy$, which is not what I want. Can I get a hint?