05 - Trinomials models for Quantitative Finance

Creating a trinomial model and deriving the Forward Kolmogorov Equation.
Author

Francois de Ryckel

Published

April 8, 2023

Modified

July 23, 2023

Transition Density Function

library(tibble)     # tibble()
library(dplyr)      # mutate()
library(ggplot2)    # ggplot()

Setting the stage

A discrete random variable (DRV) y can either go up with a probability of α or down with a probability of α or stay the same with a probability of 12α.

alpha1 - 2*alphaalphay'y'+delta_yyy'-delta_y

We call that a trinomial walk.

Generating an instance of a trinomial walk

alpha <- 0.3     # probability to go up or down 
                 # Hence, prob to stay the same is 0.4

#let's do a 252 steps trinomial walk (aka a year of daily movement). 

num_steps <- 252
prob <- runif(num_steps)

df <- tibble(step = 1:num_steps, prob = prob) |> 
  mutate(direction = if_else(prob < alpha, -1, if_else(prob > (1 - alpha), 1, 0)), 
         cum_walk = cumsum(direction))

ggplot(df, aes(x = step, y = cum_walk)) + 
  geom_line() + 
  ggtitle(label = 'Instance of a trinomial walk', subtitle = 'with 252 steps and symetric move') + 
  ylab(label = 'Cumulative distance')

This is just one instance of a trinomial walk. In reality, we are interested in getting to know the probabilistic properties of the y variable.

Deriving the Forward equation

(1)Prob(a<y<b at time t’ | y at time t)=abp(y,t;y,t)dy

This () means: What is the probability that the random variable y’ lies between a and b at time t’ given it was at y at time t? In this case (y, t) are given, they are constant, they are known; while (y’, t’) are the variables.

We re-write this () for conciseness as P(y,t;y,t).

Hence, another way to write () is (2)P(y,t;y,t)=αP(y,t;y+δy,tδt)+(12α)P(y,t;y,tδt)+αP(y,t;yδy,tδt)

Each terms in the sum of () could be evaluated using a Taylor Series Expansion. Note that δt2<<δt as δt is already quite small.

P(y,t;y+δy,tδt)P(y,t;y,t)+δyPyδtPt+12δy22Py2+ P(y,t;y,tδt)P(y,t;y,t)δtPt+

P(y,t;yδy,tδt)P(y,t;y,t)δyPyδtPt+12δy22Py2+

We have ignored all the terms less than δt.

Adding the 3 equations above with their coefficients, we end up with

δtPt=αδy22Py2 Pt=αδy2δt2Py2

Note how α, δt and δy are all positive values. Hence, we can let C2=αδy2δt, and we get: (3)Pt=C22Py2

This last () can be recognized as the Forward Kolmogorov Equation or Heat-diffusion equation or also Fokker-Plank equation.

Note that:

  • We used P instead of P(y,t;y,t) just for brievety
  • This is a PDE for p with 2 independent variables y and t
  • y and t are like parameters. They are fixed, they are starting point
  • This should model a random-walk that is finite in a finite time.

Solving the FKE (by similarity reduction)

To solve this PDE, we solve it by (as per the CQF) similarity reduction. We use a solution of the form (4)P=taf(ytb) a,bR

Letting ξ=ytb, we are looking for a solution of the form P=taf(ξ)

Finding the partial derivatives based on the above solution’s form.

Py=tadfdξξy Note how f is just a function of ξ while ξ is a function of both y and t; hence the difference in notation for the derivatives.

Since ξy=tb, we have Py=tabdfdξ P2y2=tabd2fdξ2ξy=ta2bd2fdξ2

Also, ξt=bytb1. Using product rule to find Pt, we get: Pt=ata1f(ξ)+tadfdξξt=ata1f(ξ)btab1ydfdξ which we could also re-write as: Pt=ata1f(ξ)bta1ξdfdξ since ξ=ytb

Putting everything back together into , we get: (5)ata1f(ξ)bta1ξdfdξ=C2ta2bd2fdξ2

Considering the exponents of t, we need to have a1=a2b. Hence b=12. We can already re-write ξ=yt

To find the value of a, we will use the fact that P(y,t)dy=1 taf(yt)dy=1

Using the substitution u=yt, we have dudy=t12

taf(u)dut12=1 ta+12f(u)du=1

Considering f(u)du=1, we deduce that a+12=0 and a=12

Re-writing using our new values for a and b:

12f(ξ)12ξ=C2d2fdξ2 12d(ξf(ξ))d(ξ)=C2d2fdξ2 12ξf(ξ))=C2dfdξ+const.

We make the constant = 0.

12ξ=C21f(ξ)dfdξ 12ξ=C2d(log f(ξ))d(f(ξ))

Integrating both side for ξ, we get: 12ξ dξ=C2log f(ξ)

12ξ22+c1=C2log f(ξ)

log f(ξ)=14C2ξ2+c

f(ξ)=e14C2ξ2+c=Ae14C2ξ2 Time, to revisit our initial solution :

P(y,t;y,t)=1tAe14C2y2t

We choose A such that Rf(ξ) dξ=1

ARe14C2ξ2 dξ=1

Using substitution x=ξ2C, we get dxdξ=12C, hence:

A2CRex2dx=1

A=12Cπ P(y,t;y,t)=1t 12Cπe14C2y2t

Probability Density Function for normal distribution

Recall the Probability Density Function for a random normal variable.

f(x)=1σ2πe12(xμ)2σ2

With this in mind, we could set σ=C2t and σ2=2C2t

P(y,t;y,t)=1σ2π e12y2σ2

Hence y is a random variable such that yN(0,(C2t )2)

An Alternative Situation

We could imagine that instead of the trinomial walk, we a have a Symmetric Random Walk. We defined some properties of such symmetric random walk in an earlier post

This mean that our random walker can move in steps δy in time-step δt.

Similarly to what we have done above, Prob(a<y<b at time t’ | y at time t)=abp(y,t;y,t)dy and

P(y,t;y,t)=αP(y,t;y+δy,tδt)+αP(y,t;yδy,tδt) Because the random walk is symmetric α has to be 12

P(y,t;y+δy,tδt)P(y,t;y,t)+δyPyδtPt+12δy22Py2+

P(y,t;yδy,tδt)P(y,t;y,t)δyPyδtPt+12δy22Py2+

Putting it all back together and again using P(y,t;y,t)=P(y,t) for brevity:

P(y,t)=P(y,t)δtPt+12δy22Py2

δtPt=12δy22Py2

Pt=12δy2δt2Py2

When we take the limit for δt and δy2 to tend -> 0, this expression would only make sense if δy2δt>1; otherwise the probability will either be 0 or .

Pt=122Py2