A MATLAB mex implementation for numerically solving the Fokker-Planck equation using the Chang-Cooper method.
This package provides a C-based MEX function (FP4) for solving the Fokker-Planck equation, which describes the temporal evolution of probability densities in diffusion processes.
FP4.c- Source code for the MEX functionFP4.mex*- Compiled MEX binaries for different platforms (Windows, Mac, Linux)tutorial_FokkerPlanck.m- Example script demonstrating usage and comparing different numerical methods
[ufinal, Pt, Pt_bound, Pg0, Pxt] = FP4(xmesh, uinit, k, sigma, bound_change, bound_margin, dt)xmesh- Spatial grid (column vector)uinit- Initial probability density (column vector)k- Drift ratesigma- Standard deviation of the diffusion processbound_change- Matrix with two columns specifying how boundaries change over timebound_margin- Vector[lb_margin; ub_margin]specifying boundary marginsdt- Time step size
ufinal- Final probability densityPt- Survivor function (probability of not crossing bounds)Pt_bound- Probability of crossing lower and upper bounds at each time stepPg0- Probability of being above zero at each time stepPxt- Full probability density across space and time (optional, memory-intensive)
See tutorial_FokkerPlanck.m for an example comparing different numerical methods.
Kiani lab (roozbeh@nyu.edu)
http://www.cns.nyu.edu/kianilab/Home.html
The code is released under a BSD license.