# Are random variables equal almost surely if their expectation are interchangable?

Suppose you have $$X$$ and $$Y$$ on a common probability space Let $$h,g$$ be arbitrary bounded Borel-measurable functions. If you have:

$$\mathbb{E}(h(X)g(Y)) = \mathbb{E}(h(X)g(X))$$

Do you also have X=Y a.s.?

My intuition is yes, using $$h=1,g(\cdot)=|\cdot-X|$$ (is this allowed?), and then LHS=RHS=0 meaning $$|X-Y|=0$$ a.s.

• To see if something is allowed, just track their related sets. Like, $X:\Omega\to\mathbb{R}$, $g:\mathbb{R}\to\mathbb{R}$. Commented Apr 28, 2021 at 5:53

For $$A,B\in \mathcal B(\mathbb R)$$, using the hypothesis with $$h=1_A$$ and $$g=1_B$$, $$P\big((X\in A) \cap (Y\in B)\big) = P\big(X\in (A\cap B)\big).$$

Taking $$A=\mathbb R$$ yields $$\forall B\in \mathcal B(\mathbb R)$$, $$P(Y\in B) = P(X\in B)$$, hence $$X\stackrel{d}= Y$$.

Consequently, for any bounded measurable $$h,g$$ we have $$E\big(h(X)g(Y) \big) = E\big(h(X)g(X) \big) = E\big(h(Y)g(Y) \big)$$ and exchanging $$h$$ and $$g$$ we have additionally $$E\big(g(X)h(Y) \big) = E\big(g(X)h(X) \big)$$ thus $$E\big(h(X)g(Y) \big) = E\big(g(X)h(Y) \big) = E\big(h(X)g(X) \big) = E\big(h(Y)g(Y) \big)$$

so that $$E\big([g(X)-g(Y)][h(X)-h(Y)] \big) = 0.$$

Taking $$g=h=\arctan$$ yields $$E\big([\arctan(X)-\arctan(Y)]^2 \big) = 0,$$ hence $$\arctan(X)=\arctan(Y)$$ a.s. and $$X=Y$$ a.s.

You cannot make that choice of $$g$$ but the result is true:

You get $$P(X \in A, Y\in A)=P(X \in A)$$ by taking $$g=h=I_A$$. But $$(X \in A, Y\in A) \subseteq (X \in A)$$. From this it follows that $$X\in A$$ implies $$Y \in A$$ a.s. [in the sense $$P(X \in A, Y \notin A)=0$$. Thus $$\frac {i-1}n \leq X \leq \frac i n$$ implies $$\frac {i-1}n \leq Y \leq \frac i n$$ so $$|X-Y| \leq \frac 1 n$$ a.s. Can you take it from here?

• I can follow your first argument but in your last step, are you using $g$ to squeeze $X,Y$ to an interval? Wouldn't that fail if you let $Y=X (\%) \frac{i-1}{n}$ (the remainder)? Commented Apr 28, 2021 at 5:43
• $X$ always lies between $\frac {i-1} n$ and $\frac i n$ for some $i$. For that $i$ it follows that $Y$ also lies between these limits so $|X-Y| \leq \frac 1 n$. [The only techical point here is to find one null which works for each $n$ but that is certainly possible]. @Isomorphism Commented Apr 28, 2021 at 5:47