05 - Trinomials models for Quantitative Finance

Creating a trinomial model and deriving the Forward Kolmogorov Equation.
Probability
Probability Density Function
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 \(\alpha\) or down with a probability of \(\alpha\) or stay the same with a probability of \(1 - 2\alpha\).

flowchart RL
  y' -- alpha --> y'+delta_y
  y' -- 1 - 2*alpha --> y
  y' -- alpha --> y'-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

\[Prob(a<y'<b \text{ at time t' } | \text{ y at time t}) = \int_a^b p(y, t; y', t') dy' \tag{1}\]

This (Equation 1) 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 (Equation 1) for conciseness as \(P(y, t; y', t')\).

Hence, another way to write (Equation 1) is \[P(y, t; y', t') = \alpha \cdot P(y, t; y'+\delta y, t'-\delta t) + (1-2\alpha) P(y, t; y', t'-\delta t) + \alpha \cdot P(y, t; y'-\delta y, t' - \delta t) \tag{2}\]

Each terms in the sum of (Equation 2) could be evaluated using a Taylor Series Expansion. Note that \(\delta t^2 << \delta t\) as \(\delta t\) is already quite small.

\[P(y, t; y' + \delta y, t'-\delta t) \approx P(y,t;y',t') + \delta y \frac{\partial P}{\partial y'} - \delta t \frac{\partial P}{\partial t'} + \frac{1}{2} \delta y^2 \frac{\partial^2 P}{\partial y'^2} + \dots\] \[P(y, t; y', t'-\delta t) \approx P(y,t;y',t') - \delta t \frac{\partial P}{\partial t'} + \dots\]

\[P(y, t; y'- \delta y, t'-\delta t) \approx P(y,t;y',t') - \delta y \frac{\partial P}{\partial y'} - \delta t \frac{\partial P}{\partial t'} + \frac{1}{2} \delta y^2 \frac{\partial^2 P}{\partial y'^2} + \dots\]

We have ignored all the terms less than \(\delta t\).

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

\[\delta t \frac{\partial P}{\partial t'} = \alpha \delta y^2 \frac{\partial^2 P}{\partial y'^2}\] \[\frac{\partial P}{\partial t'} = \alpha \frac{\delta y^2}{\delta t} \frac{\partial^2 P}{\partial y'^2}\]

Note how \(\alpha\), \(\delta t\) and \(\delta y\) are all positive values. Hence, we can let \(C^2 = \alpha \frac{\delta y^2}{\delta t}\), and we get: \[\frac{\partial P}{\partial t'} = C^2 \frac{\partial^2 P}{\partial y'^2} \tag{3}\]

This last (Equation 3) 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 \[P = t'^a f \left( \frac{y'}{t'^b} \right) \space a, b \in \mathbb{R} \tag{4}\]

Letting \(\xi = \frac{y'}{t'^b}\), we are looking for a solution of the form \[P = t'^a f(\xi) \]

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

\[\frac{\partial P}{\partial y'} = t'^a \cdot \frac{df}{d \xi} \cdot \frac{\partial \xi}{\partial y'}\] Note how f is just a function of \(\xi\) while \(\xi\) is a function of both \(y'\) and \(t'\); hence the difference in notation for the derivatives.

Since \(\frac{\partial \xi}{\partial y'} = t'^{-b}\), we have \[\frac{\partial P}{\partial y'} = t'^{a-b} \cdot \frac{df}{d \xi} \] \[\frac{\partial P^2}{\partial y'^2} = t'^{a-b} \frac{d^2f}{d \xi^2} \frac{\partial \xi}{\partial y'} = t'^{a-2b} \frac{d^2f}{d \xi^2}\]

Also, \(\frac{\partial \xi}{\partial t'} = -b \cdot y' \cdot t'^{-b-1}\). Using product rule to find \(\frac{\partial P}{\partial t'}\), we get: \[\frac{\partial P}{\partial t'} = a t'^{a-1} f(\xi) + t'^a \frac{df}{d \xi} \frac{\partial \xi}{\partial t'} = a \cdot t'^{a-1} \cdot f(\xi) - b \cdot t'^{a-b-1} \cdot y' \cdot \frac{df}{d \xi} \] which we could also re-write as: \[\frac{\partial P}{\partial t'} = a \cdot t'^{a-1} \cdot f(\xi) - b \cdot t'^{a-1} \cdot \xi \cdot \frac{df}{d \xi}\] since \(\xi = \frac{y'}{t'^b}\)

Putting everything back together into Equation 3, we get: \[a \cdot t'^{a-1} \cdot f(\xi) - b \cdot t'^{a-1} \cdot \xi \cdot \frac{df}{d \xi} = C^2 \cdot t'^{a-2b} \frac{d^2f}{d \xi^2} \tag{5}\]

Considering the exponents of \(t'\), we need to have \(a-1 = a-2b\). Hence \(b = \frac{1}{2}\). We can already re-write \(\xi = \frac{y'}{\sqrt{t'}}\)

To find the value of \(a\), we will use the fact that \[\int_{-\infty}^{\infty} P(y', t') dy' = 1\] \[\int_{-\infty}^{\infty} t'^a \cdot f \left( \frac{y'}{\sqrt{t'}} \right) dy' = 1\]

Using the substitution \(u = \frac{y'}{\sqrt{t'}}\), we have \(\frac{du}{dy'} = t'^\frac{-1}{2}\)

\[t'^a \int_{-\infty}^{\infty} f(u) du \cdot t'^\frac{1}{2} = 1\] \[t'^{a+\frac{1}{2}} \int_{-\infty}^{\infty} f(u) du = 1\]

Considering \[\int_{-\infty}^{\infty} f(u) du = 1\], we deduce that \[a+\frac{1}{2} = 0\] and \[a = \frac{-1}{2}\]

Re-writing Equation 5 using our new values for \(a\) and \(b\):

\[\frac{-1}{2} f(\xi) - \frac{1}{2} \xi = C^2 \frac{d^2f}{d \xi^2}\] \[\frac{-1}{2} \frac{d(\xi f(\xi))}{d(\xi)} = C^2 \frac{d^2f}{d \xi^2}\] \[\frac{-1}{2} \xi f(\xi)) = C^2 \frac{df}{d \xi} + const.\]

We make the constant = 0.

\[\frac{-1}{2} \xi = C^2 \frac{1}{f(\xi)} \frac{df}{d \xi}\] \[\frac{-1}{2} \xi = C^2 \frac{d(log \space f(\xi))}{d(f(\xi))} \]

Integrating both side for \(\xi\), we get: \[\frac{-1}{2} \int \xi \space d\xi= C^2 log \space f(\xi)\]

\[\frac{-1}{2} \frac{\xi^2}{2} + c_1= C^2 log \space f(\xi)\]

\[log \space f(\xi) = \frac{-1}{4 C^2} \xi^2 + c\]

\[f(\xi) = e^{\frac{-1}{4 C^2} \xi^2 + c} = A \cdot e^{\frac{-1}{4 C^2} \xi^2}\] Time, to revisit our initial solution Equation 4:

\[P(y, t; y', t') = \frac{1}{\sqrt{t}} A \cdot e^{\frac{-1}{4 C^2} \frac{y'^2}{t'}}\]

We choose \(A\) such that \[\int_\mathbb{R} f(\xi) \space d\xi = 1\]

\[A \cdot \int_\mathbb{R} e^{\frac{-1}{4 C^2} \xi^2} \space d\xi = 1\]

Using substitution \(x = \frac{\xi}{2C}\), we get \(\frac{dx}{d\xi} = \frac{1}{2C}\), hence:

\[A \cdot 2C \cdot \int_\mathbb{R} e^{-x^2} dx = 1\]

\[A = \frac{1}{2C \sqrt{\pi}}\] \[P(y, t; y', t') = \frac{1}{\sqrt{t}} \space \cdot \frac{1}{2C \sqrt{\pi}} \cdot e^{\frac{-1}{4 C^2} \frac{y'^2}{t'}}\]

Probability Density Function for normal distribution

Recall the Probability Density Function for a random normal variable.

\[f(x) = \frac{1}{\sigma \sqrt{2 \pi}} \cdot e^{\frac{-1}{2} \frac{(x-\mu)^2}{\sigma^2}}\]

With this in mind, we could set \(\sigma = C \cdot \sqrt{2t'}\) and \(\sigma^2 = 2 \cdot C^2 \cdot t'\)

\[P(y, t; y', t') = \frac{1}{\sigma \sqrt{2 \pi}} \space \cdot e^{\frac{-1}{2} \frac{y'^2}{\sigma^2}}\]

Hence \(y'\) is a random variable such that \[y' \sim N \left( 0, (C \sqrt{2t'} \space)^2 \right)\]

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 \(\delta y\) in time-step \(\delta t\).

Similarly to what we have done above, \[Prob(a<y'<b \text{ at time t' } | \text{ y at time t}) = \int_a^b p(y, t; y', t') dy'\] and

\[P(y, t; y', t') = \alpha \cdot P(y, t; y'+\delta y, t'-\delta t) + \alpha \cdot P(y, t; y'-\delta y, t' - \delta t)\] Because the random walk is symmetric \(\alpha\) has to be \(\frac{1}{2}\)

\[P(y, t; y' + \delta y, t'-\delta t) \approx P(y,t;y',t') + \delta y \frac{\partial P}{\partial y'} - \delta t \frac{\partial P}{\partial t'} + \frac{1}{2} \delta y^2 \frac{\partial^2 P}{\partial y'^2} + \dots\]

\[P(y, t; y'- \delta y, t'-\delta t) \approx P(y,t;y',t') - \delta y \frac{\partial P}{\partial y'} - \delta t \frac{\partial P}{\partial t'} + \frac{1}{2} \delta y^2 \frac{\partial^2 P}{\partial y'^2} + \dots\]

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

\[P(y', t') = P(y', t') - \delta t \frac{\partial P}{\partial t'} + \frac{1}{2} \delta y^2 \frac{\partial^2 P}{\partial y'^2}\]

\[\delta t \frac{\partial P}{\partial t'} = \frac{1}{2} \delta y^2 \frac{\partial^2 P}{\partial y'^2}\]

\[\frac{\partial P}{\partial t'} = \frac{1}{2} \frac{\delta y^2}{\delta t} \frac{\partial^2 P}{\partial y'^2}\]

When we take the limit for \(\delta t\) and \(\delta y'^2\) to tend -> 0, this expression would only make sense if \(\frac{\delta y^2}{\delta t} -> 1\); otherwise the probability will either be \(0\) or \(\infty\).

\[\frac{\partial P}{\partial t'} = \frac{1}{2} \frac{\partial^2 P}{\partial y'^2}\]