# Integral of the OU (Ornstein Uhlenbeck) process conditioned on hitting a threshold value for the first time

Let say I have a zero-mean OU process as follows:

$dX_t = -\alpha X_t + dW_t$

The process starts at $x_0 = 0%$ and I'm interested in the event in which the process hits the value $x_{\tau} = a$ for the first time. The distribution of the "first passage time", $\tau$ has been well studied in the literature. I am interested in the expected value of integral of $X_t$ before the first passage time happens, i.e.

$E\left[\int_{0}^{\tau}X_t dt\right | X(\tau) = a]$

Has this problem been solved?

I am curious about the target of your question. It is rarely put as $$\mathbb{E}\left[\int_0^{\tau}X_t{\rm d}t\Bigg|X_{\tau}=a\right],$$ because, as per your statement, $\tau$ is defined as $$\tau=\inf\left\{t>0:X_t=a\right\}.$$ Following this definition, it is a must that $X_{\tau}=a$. Hence it is unnecessary to be conditioned.

As far as I know, this type of questions usually asks to determine $$\mathbb{E}\left[\int_0^{\tau}X_t{\rm d}t\Bigg|X_0=x\right],$$ if you do not specify the initial value of $X_0$. Thus in this post, I will be reasoning with this form of conditional expectation.

In addition, we may consider a more general case. Suppose $\mu$ is the long-term expected position of $X_t$, which starts from $X_0=x$. Since the $x>\mu$ case and the $x<\mu$ case are symmetric, we may, without loss of generality, focus on the $x>\mu$ case.

Now, let me put our target in a clear way.

Consider a general Ornstein-Uhlenbeck process $${\rm d}X_t=\theta\left(\mu-X_t\right){\rm d}t+\sigma{\rm d}W_t.$$ Define a first passage time with respect to $X_t$ as $$\tau=\inf\left\{t>0:X_t=a\right\},$$ where $a\in\mathbb{R}$ is a fixed parameter. With these settings, determine $$\mathbb{E}\left[\int_0^{\tau}X_t{\rm d}t\Bigg|X_0=x\right],$$ where $x>\mu$ is another fixed parameter.

The following reasoning relies on the assumption that $\mathbb{E}\tau<\infty$ almost surely, meaning that Ornstein-Uhlenbeck processes starting from $x$ would, on average, hit $a$ after some finite time. Intuitively, this holds true only if $a\in\left[\mu,x\right)$. In fact, it is a basic fact that $\mathbb{E}\tau=\infty$ for Brownian motions, and the long-term behavior of $X_t$ is much less diffusive than the Brownian motion. Hence if $a\notin\left[\mu,x\right)$ or if $x=\mu$, we will have $\mathbb{E}\tau=\infty$ for $X_t$ as well, leaving $$\mathbb{E}\left[\int_0^{\tau}X_t{\rm d}t\Bigg|X_0=x\right]$$ either infinite or undefined.

Let $f=f(x)$ be some twice differentiable function defined on $\left(\mu,\infty\right)$, to be determined. Then Ito's formula, together with the Ornstein-Uhlenbeck process, yields \begin{align} {\rm d}f(X_t)&=f'(X_t){\rm d}X_t+\frac{1}{2}f''(X_t){\rm d}\left<X\right>_t\\ &=f'(X_t)\left[\theta\left(\mu-X_t\right){\rm d}t+\sigma{\rm d}W_t\right]+\frac{1}{2}f''(X_t)\left(\sigma^2{\rm d}t\right)\\ &=\left[\theta\left(\mu-X_t\right)f'(X_t)+\frac{1}{2}\sigma^2f''(X_t)\right]{\rm d}t+\sigma f'(X_t){\rm d}W_t. \end{align} As per this result, let $f$ be chosen such that $$\theta\left(\mu-x\right)f'(x)+\frac{1}{2}\sigma^2f''(x)=x. \tag{*}$$ With this choice, the differentiation could be simplified as $${\rm d}f(X_t)=X_t{\rm d}t+\sigma f'(X_t){\rm d}W_t,$$ whose integration reads $$f(X_u)-f(X_0)=\int_0^uX_t{\rm d}t+\int_0^u\sigma f'(X_t){\rm d}W_t,$$ where $u\ge 0$. Note that the last term is a martingale, on condition that $f'(X_t)$ is bounded. Thus thanks to our assumption $\mathbb{E}\tau<\infty$, the optional stopping theorem for continuous-time martingales applies, i.e., $$\mathbb{E}\left[\int_0^{\tau}\sigma f'(X_t){\rm d}W_t\right]=0.$$ This immediately leads to $$\mathbb{E}\left[f(X_{\tau})-f(X_0)-\int_0^{\tau}X_t{\rm d}t\right]=0\iff\mathbb{E}\left[\int_0^{\tau}X_t{\rm d}t\right]=\mathbb{E}f(X_{\tau})-\mathbb{E}f(X_0),$$ or in the conditional expectation form, $$\mathbb{E}\left[\int_0^{\tau}X_t{\rm d}t\Bigg|X_0=x\right]=f(a)-f(x),$$ where we use the fact that $X_{\tau}=a$ holds unconditionally due to the definition of $\tau$.

Let us now figure out an appropriate form of $f(x)$ for $x\in\left(\mu,\infty\right)$ by solving $(*)$. This equation is equivalent to \begin{align} {\rm d}\left[f'(x)\exp\left(-\frac{\theta}{\sigma^2}\left(x-\mu\right)^2\right)\right]&=\frac{2}{\sigma^2}x\exp\left(-\frac{\theta}{\sigma^2}\left(x-\mu\right)^2\right){\rm d}x\\ &={\rm d}\left[\sqrt{\frac{\pi}{\theta}}\frac{2\mu}{\sigma}\Phi(y)-\frac{1}{\theta}\exp\left(-\frac{1}{2}y^2\right)\right], \end{align} where $\Phi(\cdot)$ is the cumulative distribution function of the standard normal distribution, while $$y=\frac{\sqrt{2\theta}\left(x-\mu\right)}{\sigma}.$$ Therefore, \begin{align} f'(x)&=\exp\left(\frac{\theta}{\sigma^2}\left(x-\mu\right)^2\right)\left[\sqrt{\frac{\pi}{\theta}}\frac{2\mu}{\sigma}\Phi(y)-\frac{1}{\theta}\exp\left(-\frac{1}{2}y^2\right)+C\right]\\ &=\exp\left(\frac{1}{2}y^2\right)\left[\sqrt{\frac{\pi}{\theta}}\frac{2\mu}{\sigma}\Phi(y)-\frac{1}{\theta}\exp\left(-\frac{1}{2}y^2\right)+C\right]\\ &=-\frac{1}{\theta}+\left[\sqrt{\frac{\pi}{\theta}}\frac{2\mu}{\sigma}\Phi(y)+C\right]\exp\left(\frac{1}{2}y^2\right), \end{align} where $C$ is a constant of integration. We shall determine this constant, using the boundedness requirement for $f'(X_t)$. In the $x>\mu$ case, it suffices to require $f'(x)$ to be bounded for $x\in\left(\mu,\infty\right)$, or equivalently, for $y>0$. Regarding the asymptotic behavior of $$\left[\sqrt{\frac{\pi}{\theta}}\frac{2\mu}{\sigma}\Phi(y)+C\right]\exp\left(\frac{1}{2}y^2\right),$$ it is obvious that $$C=-\sqrt{\frac{\pi}{\theta}}\frac{2\mu}{\sigma}$$ is the only candidate that bounds this term for all $y>0$. Therefore, $$f'(x)=-\frac{1}{\theta}-\sqrt{\frac{\pi}{\theta}}\frac{2\mu}{\sigma}\left[1-\Phi(y)\right]\exp\left(\frac{1}{2}y^2\right),$$ or equivalently, $${\rm d}f(x)=-{\rm d}\left(\frac{x}{\theta}\right)-\frac{\mu}{\theta}\frac{1-\Phi(y)}{\Phi'(y)}{\rm d}y.$$ Define $$\Psi(z)=\int_0^z\frac{1-\Phi(y)}{\Phi'(y)}{\rm d}y$$ for all $z>0$, and we eventually obtain $$f(x)=-\frac{x}{\theta}-\frac{\mu}{\theta}\Psi\Biggl(\frac{\sqrt{2\theta}\left(x-\mu\right)}{\sigma}\Biggr).$$ This formula is meant for all $x\in\left(\mu,\infty\right)$, and the constant of integration for $f$ is dropped as it is, different from the $C$ above, not significant.

With this $f$, the conditional expectation would be figured out by $$\mathbb{E}\left[\int_0^{\tau}X_t{\rm d}t\Bigg|X_0=x\right]=f(a)-f(x)$$ for $a\in\left[\mu,x\right)$. When $\mu=0$, this formula observes a simplified form $$\mathbb{E}\left[\int_0^{\tau}X_t{\rm d}t\Bigg|X_0=x\right]=\frac{x-a}{\theta}.$$

Similar method also applies to calculate $\mathbb{E}\left(\tau|X_0=x\right)$, by setting the right-hand-side of $(*)$ as $1$ instead of $x$.