Consider the stochastic differential equation of the Heston model for the dynamics of the log-spot
The Fokker-Planck partial differential forward equation describes the time evolution of the probability density function
with the initial condition
where denotes the Dirac delta distribution. A semi-closed form solution for this problem is presented in . When solving the Fokker-Planck forward equation special care must be taken with respect to the boundary conditions, especially if the Feller constraint
is violated. In this case the boundary at the origin is instantaneously attainable. A generalisation of Feller’s zero-flux boundary condition should be applied at the origin .
A three point forward differentiation formula can be used to calculate a second order accurate approximation of the partial derivative for .
The diagram below shows the solution of the forward equation for the model
The Feller constraint is violated for and this changes the shape of the solution completely.
The code for this example is available here and it is based on the latest QuantLib version from the SVN trunk. It also depends on RInside and Rcpp to generate the plots. In addition the zip contains a short movie clip of the time evolution of the solution for .
 A. Dragulescu, V. Yakovenko, Probability distribution of returns in the Heston model with stochastic volatility
 K. A. Kopecky, Numerical Differentiation