Why is this integral over probability equal to identity function of event? I'm trying to derive the expression for the Gini coefficient of a lognormal variable and have been directed to this answer, but I realize that I'm very rusty when it comes to these sort of derivation and would appreciate a helping hand. In particular, I'm having trouble with these two steps
$$\int_0^\infty \Pr\left(e^{\sigma X + \mu} \leq x < e^{\sigma Y + \mu}\right) \mathop{d x} = \operatorname{E}\left[\int_0^\infty \mathbf{1}_{\{e^{\sigma X + \mu} \leq x < e^{\sigma Y + \mu}\}}\right] = \operatorname{E}\left[e^{\sigma Y + \mu} - e^{\sigma X + \mu} ; X \leq Y\right],$$
where for $X, Y$ i.i.d. $\mathcal{N}(0, 1)$. Could you please explain?
 A: First equality boils down to two facts.

*

*Fubini's theorem


*$\mathbb P(A) = \mathbb E[1_A] $ for measurable $A$. (which is just the very definition, indeed $\mathbb E[X] = \int_{\Omega}X(\omega)d\mathbb P(\omega)$ and $\mathbb P(A) = \int_{A}1d\mathbb P(\omega) $, so with $X=1_A$ we get the result)
Indeed, if we knew that, then taking $A_x = \{ e^{\sigma X + \mu} \le x < e^{\sigma Y + \mu}\}$, by 2) and Fubinii (interchange of $\int_0^\infty$ sign with $\mathbb E$, due to non-negativeness of indicator function) we would get. $$ \int_0^\infty \mathbb P(A_x)dx = \int_0^\infty \mathbb E[1_{A_x}]dx = \mathbb E\left[ \int_0^\infty 1_{A_x}dx\right]$$
The last equality is just the computation of this integral inside. Indeed, note that due to monotonicity of $\exp$ function, this integral is zero when $Y > X$, so $$ \int_0^\infty 1_{A_x}dx = 1_{\{X \le Y \}} \int_{e^{\sigma X + \mu}}^{e^{\sigma Y + \mu}} dx  = 1_{\{X \le Y\}}\cdot \big( e^{\sigma Y + \mu} - e^{\sigma X + \mu}\big)$$
Hence $$ \int_0^\infty \mathbb P(A_x)dx = \mathbb E\left[1_{\{X \le Y\}}\big(e^{\sigma Y + \mu} - e^{\sigma X + \mu}\big)\right] $$
Which is by definition $\mathbb E[e^{\sigma Y + \mu} - e^{\sigma X + \mu} ; X \le Y]$
