See notes and the realisation.
We assume the volatility of returns follows a stochastic process. Define it as the Ornstein-Uhlenbeck process,
$$dX_t = \kappa (\theta – X_t)dt +\sigma \ dW_t$$
What’s the distribution function of the Ornstein-Uhlenbeck process?
We could apply the MLE estimation to find the parameter of the above random process.
Recall our Vasicek Form Ornstein-Uhlenbeck process is like the following:
$$ dX_t = \kappa (\theta – X_t)dt +\sigma \ dW_t $$
Multiply both sides by e^{kt}, then we get,
$$ e^{kt}dX_t = \kappa e^{kt} \theta \ dt – \kappa e^{kt} X_t \ dt +\sigma e^{kt}\ dW_t $$
We know that d( e^{kt} X_t )=e^{kt}dX_t + k e^{kt}X_t dt, and substitute it inside. Then, we get,
$$ d(e^{kt}X_t)=e^{kt}\theta \ dt + e^{kt}\sigma \ dW_t $$
Take an integral from [0,T],
$$ \int_0^T d(e^{kt}X_t)= \int_0^T e^{kt}\theta \ dt + \int_0^T e^{kt}\sigma \ dW_t $$
$$ X_T = X_0 e^{-kT} +\theta (1-e^{-kT}) + \int_0^T e^{-k(T-t)}\sigma \ dW_t $$
$\int_0^T e^{-k(T-t)}\sigma \ dW_t \sim N(0, \sigma^2\int_0^T e^{-2k(T-t)}dt)$
We then find \mathbb{E}(X_T) and Var(X_T).
$ \mathbb{E}(X_T) =\mathbb{E}\bigg( X_0 e^{-kT} +\theta (1-e^{-kT}) + \int_0^T e^{-k(T-t)}\sigma \ dW_t \bigg)$
$ \mathbb{E}(X_T)= X_0 e^{-kT} +\theta (1-e^{-kT}) $
$Var(X_T) = \mathbb{E}\bigg( \big( X_T – \mathbb{E}(X_T) \big)^2 \bigg)$
$Var(X_T)= \mathbb{E}\bigg( \big( \int_0^T e^{-k(T-t)}\sigma \ dW_t \big)^2 \bigg) $
By Ito’s Isometry: I(t)=\int_0^t \Delta(s)dW_s, then
$Var[I(t)]=\mathbb{E}[(I^2(t))]=\int_0^t \Delta^2(s)ds$
Then,
$ Var(X_T)= \int_0^T e^{-2k(T-t)}\sigma^2 \ dt $
$ Var(X_T)= \frac{\sigma^2}{2k}\big( 1-e^{-2kT} \big) $
Therefore, we finally get,
$ X_T \sim N\bigg(X_0 e^{-kT} +\theta (1-e^{-kT}), \frac{\sigma^2}{2k}\big( 1-e^{-2kT} \big) \bigg)$
MLE of Ornsterin-Uhlenbeck Process
$X_t \sim N(\cdot,\cdot)$
,where \mathbb{E}(X_{t+\delta t})=X_0 e^{-k\ \delta t} +\theta (1-e^{-k\ \delta t}), and Var(X_{t+\delta t})= \frac{\sigma^2}{2k}(1-e^{-2k\ \delta t}).
$$ f_{\theta}(x_{t+\delta t}|\theta)=\frac{1}{\sqrt{2\pi \sigma^2}}e^{-\frac{(x-\mu)^2}{2\sigma^2}} $$
We replace \mu = \mathbb{E}(X_{t+\delta t}) and \sigma^2 = Var(X_{t+\delta t}) insider.
Code realisation could be found in notes.