# Expectation of a stopping time

I have a question about something my professor used in the lecture. We have the markov process generated by the Brownian motion $(B_t, F_t, P_x)$. Let $G \subset \mathbb{R}^d$ and consider the stopping time $\tau_G := inf \{t >0: B_t \notin G\}.$ Then we want to compute the expectation of the stopping time. He wrote

$E_x [\tau_G] = \int_0^{\infty} P_x(\tau_G > t) dt$.

I don't really understand how this is possible since for me the expectation of a random variable is $E[X] = \int XdP$.

Thank you for your help!

This has nothing to do with Brownian motion or the definition of $\tau_G$. For any non0negative random variable $Y$, $EY=\int_0^{\infty } P\{Y>y\}\, dy$. This follows by Fubini's Theorem and has been discussed many times on MSE so I will let you search the site instead of reproducing the proof again.