First-passage-time for stochastic differential equations

A.C. Guidoum and K. Boukhetala

2016-11-13

The fptsde function

A new algorithm based on the Monte Carlo technique to generate the random variable FPT of a time homogeneous diffusion process (1, 2 and 3D) through a time-dependent boundary, order to estimate her probability density function.

Let \(X_t\) be a diffusion process which is the unique solution of the following stochastic differential equation:

\[\begin{equation}\label{eds01} dX_t = \mu(t,X_t) dt + \sigma(t,X_t) dW_t,\quad X_{t_{0}}=x_{0} \end{equation}\]

if \(S(t)\) is a time-dependent boundary, we are interested in generating the first passage time (FPT) of the diffusion process through this boundary that is we will study the following random variable:

\[ \tau_{S(t)}= \left\{ \begin{array}{ll} inf \left\{t: X_{t} \geq S(t)|X_{t_{0}}=x_{0} \right\} & \hbox{if} \quad x_{0} \leq S(t_{0}) \\ inf \left\{t: X_{t} \leq S(t)|X_{t_{0}}=x_{0} \right\} & \hbox{if} \quad x_{0} \geq S(t_{0}) \end{array} \right. \]

The main arguments to ‘random’ rfptsdekd() (where k=1,2,3) consist:

The main arguments to ‘density’ dfptsdekd() (where k=1,2,3) consist:

Examples

FPT for 1-Dim SDE

Consider the following SDE and linear boundary:

\[\begin{align*} dX_{t}= & \frac{1}{2} \alpha^2 X_{t} dt + \alpha X_{t} dW_{t},~x_{0} \neq 0.\\ S(t)= & a+bt \end{align*}\]

The analytical solution of this model is: \[ X_t = x_{0}\exp\left(\alpha W_{t}\right) \] generating the first passage time (FPT) of this model through this boundary: \[ \tau_{S(t)}= \inf \left\{t: X_{t} \geq S(t) |X_{t_{0}}=x_{0} \right\} ~~ \text{if} \quad x_{0} \leq S(t_{0}) \]

Set the model \(X_t\):

alpha=2
f <- expression( alpha^2 * x )
g <- expression( alpha * x )
mod1d <- snssde1d(drift=f,diffusion=g,x0=0.5,M=1000)

Generate the first-passage-time \(\tau_{S(t)}\), with rfptsde1d() function:

St  <- expression( -5*t+1 )
fpt1d <- rfptsde1d(mod1d, boundary = St)
summary(fpt1d)
##     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
## 0.007853 0.043320 0.071150 0.077720 0.106300 0.191600

The kernel density of \(\tau_{S(t)}\) with boundary \(S(t) = -5t+1\), using dfptsde1d() function, see e.g. Figure 2.

den <- dfptsde1d(mod1d, boundary = St, bw ='ucv')
den 
## 
##  Kernel density for the F.P.T of X(t)
##  T(S,X) = inf{t >= 0 : X(t) >= -5 * t + 1}
## 
## Data: fpt (1000 obs.);   Bandwidth 'bw' = 0.006655
## 
##        x                    f(x)          
##  Min.   :-0.01211119   Min.   : 0.001272  
##  1st Qu.: 0.04380376   1st Qu.: 1.477957  
##  Median : 0.09971872   Median : 4.197139  
##  Mean   : 0.09971872   Mean   : 4.466684  
##  3rd Qu.: 0.15563367   3rd Qu.: 7.658616  
##  Max.   : 0.21154863   Max.   :10.109089
plot(den)

FPT for 2-Dim SDE’s

The following \(2\)-dimensional SDE’s with a vector of drift and a diagonal matrix of diffusion coefficients:

\[\begin{equation}\label{eq:09} \begin{cases} dX_t = f_{x}(t,X_{t},Y_{t}) dt + g_{x}(t,X_{t},Y_{t}) dW_{1,t}\\ dY_t = f_{y}(t,X_{t},Y_{t}) dt + g_{y}(t,X_{t},Y_{t}) dW_{2,t} \end{cases} \end{equation}\]

\(W_{1,t}\) and \(W_{2,t}\) is a two independent standard Wiener process. First passage time (2D) \((\tau_{(S(t),X_{t})},\tau_{(S(t),Y_{t})})\) is defined as:

\[ \left\{ \begin{array}{ll} \tau_{S(t),X_{t}}=\inf \left\{t: X_{t} \geq S(t)|X_{t_{0}}=x_{0} \right\} & \hbox{if} \quad x_{0} \leq S(t_{0}) \\ \tau_{S(t),Y_{t}}=\inf \left\{t: Y_{t} \geq S(t)|Y_{t_{0}}=y_{0} \right\} & \hbox{if} \quad y_{0} \leq S(t_{0}) \end{array} \right. \] and \[ \left\{ \begin{array}{ll} \tau_{S(t),X_{t}}= \inf \left\{t: X_{t} \leq S(t)|X_{t_{0}}=x_{0} \right\} & \hbox{if} \quad x_{0} \geq S(t_{0}) \\ \tau_{S(t),Y_{t}}= \inf \left\{t: Y_{t} \leq S(t)|Y_{t_{0}}=y_{0} \right\} & \hbox{if} \quad y_{0} \geq S(t_{0}) \end{array} \right. \]

Assume that we want to describe the following SDE’s (2D):

\[\begin{equation}\label{eq016} \begin{cases} dX_t = 5 (-1-Y_{t}) X_{t} dt + 0.5 dW_{1,t}\\ dY_t = 5 (-1-X_{t}) Y_{t} dt + 0.5 dW_{2,t} \end{cases} \end{equation}\]

and \[ S(t)=-3+5t \]

Set the system \((X_t , Y_t)\):

fx <- expression(5*(-1-y)*x , 5*(-1-x)*y)
gx <- rep(expression(0.5),2)
mod2d <- snssde2d(drift=fx,diffusion=gx,x0=c(x=2,y=-2),M=1000)

Generate the couple \((\tau_{(S(t),X_{t})},\tau_{(S(t),Y_{t})})\), with rfptsde2d() function::

St <- expression(-3+5*t)
fpt2d <- rfptsde2d(mod2d, boundary = St)
summary(fpt2d)
##        x                y         
##  Min.   :0.5540   Min.   :0.5222  
##  1st Qu.:0.6122   1st Qu.:0.5783  
##  Median :0.6311   Median :0.5976  
##  Mean   :0.6317   Mean   :0.5972  
##  3rd Qu.:0.6506   3rd Qu.:0.6152  
##  Max.   :0.7147   Max.   :0.6884

The marginal density of \((\tau_{(S(t),X_{t})},\tau_{(S(t),Y_{t})})\) are reported using dfptsde2d() function, see e.g. Figure 4.

denM <- dfptsde2d(mod2d, boundary = St, pdf = 'M')
denM
## 
##  Marginal density for the F.P.T of X(t)
##  T(S,X) = inf{t >= 0 : X(t) <= -3 + 5 * t}
## 
## Data: out[, "x"] (1000 obs.);    Bandwidth 'bw' = 0.006297
## 
##        x                  f(x)          
##  Min.   :0.5351016   Min.   : 0.000730  
##  1st Qu.:0.5847197   1st Qu.: 0.537723  
##  Median :0.6343378   Median : 2.994386  
##  Mean   :0.6343378   Mean   : 5.033548  
##  3rd Qu.:0.6839559   3rd Qu.: 9.767502  
##  Max.   :0.7335740   Max.   :13.419473  
## 
##  Marginal density for the F.P.T of Y(t)
##  T(S,Y) = inf{t >= 0 : Y(t) <= -3 + 5 * t}
## 
## Data: out[, "y"] (1000 obs.);    Bandwidth 'bw' = 0.006221
## 
##        y                  f(y)          
##  Min.   :0.5035176   Min.   : 0.001430  
##  1st Qu.:0.5544017   1st Qu.: 0.351427  
##  Median :0.6052858   Median : 2.611994  
##  Mean   :0.6052858   Mean   : 4.908299  
##  3rd Qu.:0.6561699   3rd Qu.: 9.420772  
##  Max.   :0.7070540   Max.   :14.397577
plot(denM)

A contour and image plot of density obtained from a realization of system \((\tau_{(S(t),X_{t})},\tau_{(S(t),Y_{t})})\).

denJ <- dfptsde2d(mod2d, boundary = St, pdf = 'J')
denJ
## 
##  Joint density for the F.P.T of (X(t),Y(t))
##  T(S,X,Y) = inf{t >= 0 : X(t) <=  -3 + 5 * t  and Y(t) <=  -3 + 5 * t}
## 
## Data: (x,y) (2 x 1000 obs.);
## 
##        x                   y                 f(x,y)         
##  Min.   :0.5539918   Min.   :0.5221792   Min.   :  0.00000  
##  1st Qu.:0.5941648   1st Qu.:0.5637325   1st Qu.:  3.42150  
##  Median :0.6343378   Median :0.6052858   Median : 13.75017  
##  Mean   :0.6343378   Mean   :0.6052858   Mean   : 36.46653  
##  3rd Qu.:0.6745108   3rd Qu.:0.6468391   3rd Qu.: 52.33053  
##  Max.   :0.7146838   Max.   :0.6883924   Max.   :190.38953
plot(denJ,display="contour",main="Bivariate Density")
plot(denJ,display="image",drawpoints=TRUE,col.pt="green",cex=0.25,pch=19,main="Bivariate Density")

A \(3\)D plot of the Joint density with:

plot(denJ,display="persp",main="Bivariate Density")

FPT for 3-Dim SDE’s

The following \(3\)-dimensional SDE’s with a vector of drift and a diagonal matrix of diffusion coefficients:

Ito form: \[\begin{equation}\label{eq17} \begin{cases} dX_t = f_{x}(t,X_{t},Y_{t},Z_{t}) dt + g_{x}(t,X_{t},Y_{t},Z_{t}) dW_{1,t}\\ dY_t = f_{y}(t,X_{t},Y_{t},Z_{t}) dt + g_{y}(t,X_{t},Y_{t},Z_{t}) dW_{2,t}\\ dZ_t = f_{z}(t,X_{t},Y_{t},Z_{t}) dt + g_{z}(t,X_{t},Y_{t},Z_{t}) dW_{3,t} \end{cases} \end{equation}\]

\(W_{1,t}\), \(W_{2,t}\) and \(W_{3,t}\) is a 3 independent standard Wiener process. First passage time (3D) \((\tau_{(S(t),X_{t})},\tau_{(S(t),Y_{t})},\tau_{(S(t),Z_{t})})\) is defined as:

\[ \left\{ \begin{array}{ll} \tau_{S(t),X_{t}}=\inf \left\{t: X_{t} \geq S(t)|X_{t_{0}}=x_{0} \right\} & \hbox{if} \quad x_{0} \leq S(t_{0}) \\ \tau_{S(t),Y_{t}}=\inf \left\{t: Y_{t} \geq S(t)|Y_{t_{0}}=y_{0} \right\} & \hbox{if} \quad y_{0} \leq S(t_{0}) \\ \tau_{S(t),Z_{t}}=\inf \left\{t: Z_{t} \geq S(t)|Z_{t_{0}}=z_{0} \right\} & \hbox{if} \quad z_{0} \leq S(t_{0}) \end{array} \right. \] and \[ \left\{ \begin{array}{ll} \tau_{S(t),X_{t}}= \inf \left\{t: X_{t} \leq S(t)|X_{t_{0}}=x_{0} \right\} & \hbox{if} \quad x_{0} \geq S(t_{0}) \\ \tau_{S(t),Y_{t}}= \inf \left\{t: Y_{t} \leq S(t)|Y_{t_{0}}=y_{0} \right\} & \hbox{if} \quad y_{0} \geq S(t_{0}) \\ \tau_{S(t),Z_{t}}= \inf \left\{t: Z_{t} \leq S(t)|Z_{t_{0}}=z_{0} \right\} & \hbox{if} \quad z_{0} \geq S(t_{0}) \\ \end{array} \right. \]

Assume that we want to describe the following SDE’s (3D): \[\begin{equation}\label{eq0166} \begin{cases} dX_t = 4 (-1-X_{t}) Y_{t} dt + 0.2 dW_{1,t}\\ dY_t = 4 (1-Y_{t}) X_{t} dt + 0.2 dW_{2,t}\\ dZ_t = 4 (1-Z_{t}) Y_{t} dt + 0.2 dW_{3,t} \end{cases} \end{equation}\]

and \[ S(t)=-3+5t \]

Set the system \((X_t , Y_t , Z_t)\):

fx <- expression(4*(-1-x)*y , 4*(1-y)*x , 4*(1-z)*y) 
gx <- rep(expression(0.2),3)
mod3d <- snssde3d(drift=fx,diffusion=gx,x0=c(x=2,y=-2,z=0),M=1000)

Generate the triplet \((\tau_{(S(t),X_{t})},\tau_{(S(t),Y_{t})},\tau_{(S(t),Z_{t})})\), with rfptsde3d() function::

St <- expression(-3+5*t)
fpt3d <- rfptsde3d(mod3d, boundary = St)
## missing output are removed
summary(fpt3d)
##        x                y                z         
##  Min.   :0.5462   Min.   :0.7129   Min.   :0.7195  
##  1st Qu.:0.5729   1st Qu.:0.7639   1st Qu.:0.7586  
##  Median :0.5810   Median :0.7843   Median :0.7697  
##  Mean   :0.5812   Mean   :0.7882   Mean   :0.7692  
##  3rd Qu.:0.5895   3rd Qu.:0.8063   3rd Qu.:0.7808  
##  Max.   :0.6181   Max.   :0.9746   Max.   :0.8170

The marginal density of \((\tau_{(S(t),X_{t})},\tau_{(S(t),Y_{t})},\tau_{(S(t),Z_{t})})\) are reported using dfptsde3d() function, see e.g. Figure 4.

denM <- dfptsde3d(mod3d, boundary = St)
## missing output are removed
denM
## 
##  Marginal density for the F.P.T of X(t)
##  T(S,X) = inf{t >= 0 : X(t) <= -3 + 5 * t}
## 
## Data: out[, "x"] (997 obs.); Bandwidth 'bw' = 0.002562
## 
##        x                  f(x)         
##  Min.   :0.5385170   Min.   : 0.00202  
##  1st Qu.:0.5603377   1st Qu.: 0.65273  
##  Median :0.5821583   Median : 5.31717  
##  Mean   :0.5821583   Mean   :11.44583  
##  3rd Qu.:0.6039789   3rd Qu.:24.71753  
##  Max.   :0.6257995   Max.   :32.59780  
## 
##  Marginal density for the F.P.T of Y(t)
##  T(S,Y) = inf{t >= 0 : Y(t) <= -3 + 5 * t}
## 
## Data: out[, "y"] (997 obs.); Bandwidth 'bw' = 0.007173
## 
##        y                  f(y)          
##  Min.   :0.6913526   Min.   : 0.000636  
##  1st Qu.:0.7675465   1st Qu.: 0.077169  
##  Median :0.8437405   Median : 0.821949  
##  Mean   :0.8437405   Mean   : 3.277886  
##  3rd Qu.:0.9199344   3rd Qu.: 5.757135  
##  Max.   :0.9961283   Max.   :12.414648  
## 
##  Marginal density for the F.P.T of Z(t)
##  T(S,Z) = inf{t >= 0 : Z(t) <= -3 + 5 * t}
## 
## Data: out[, "z"] (997 obs.); Bandwidth 'bw' = 0.003721
## 
##        z                  f(z)          
##  Min.   :0.7083621   Min.   : 0.001281  
##  1st Qu.:0.7383142   1st Qu.: 0.824233  
##  Median :0.7682663   Median : 4.796056  
##  Mean   :0.7682663   Mean   : 8.338474  
##  3rd Qu.:0.7982185   3rd Qu.:15.505158  
##  Max.   :0.8281706   Max.   :24.675313
plot(denM)

For Joint density for \((\tau_{(S(t),X_{t})},\tau_{(S(t),Y_{t})},\tau_{(S(t),Z_{t})})\) see package sm or ks.

library(sm)
sm.density(fpt3d,display="rgl")

##

library(ks)
fhat <- kde(x=fpt3d)
plot(fhat, drawpoints=TRUE)