Skip to content

matthieugomez/InfinitesimalGenerators.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

329 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build status Coverage Stable documentation Documentation

InfinitesimalGenerators.jl computes stationary distributions, conditional expectations, and tail indices of continuous-time Markov processes. It works in two steps. The first step is to build the generator matrix: a Markov-chain approximation of the process on a finite grid, representing transition rates between grid points (in particular, rows must sum to zero and off-diagonal elements are non-negative).

The second step is to use this generator to turn the linear PDEs associated with the process into linear algebra. In particular, the package covers the following problems:

The same generator matrices also appear inside finite-difference methods for nonlinear HJB equations. InfinitesimalGenerators.jl focuses on the linear PDEs once a process is known; for nonlinear HJB problems, see EconPDEs.jl and Application to a consumption-saving problem.

Installation

using Pkg
Pkg.add("InfinitesimalGenerators")

Example

using InfinitesimalGenerators

# an Ornstein-Uhlenbeck process dx = -0.03 x dt + 0.01 dZ, discretized on a grid
x = range(-1, 1, length = 100)
X = DiffusionProcess(x, -0.03 .* x, 0.01 .* ones(100))

generator(X)                                # the generator (transition-rate) matrix
stationary_distribution(X)                  # its stationary distribution
feynman_kac(X, 0:0.1:10; ψ = collect(x))    # conditional expectations E[x_T | x_t]

Beyond univariate diffusions, the package supports finite-state continuous-time Markov chains (ContinuousTimeMarkovChain), multivariate diffusions (MultivariateDiffusionProcess), and their compositions (ProductProcess, SwitchingProcess) — all through the same three verbs: generator, state_space, and size. Generators are discretized with the standard upwind finite-difference scheme, with reflecting boundaries.

Process types subtype ContinuousTimeMarkovProcess{N}, where N is the number of tensor-product state-space axes. For example, a scalar diffusion has N == 1, while ProductProcess(X, Z) has N == ndims(X) + ndims(Z).

The documentation has a manual — processes and generators and the operators that apply to them — and four tutorials, each showing the computation by hand from the generator matrix before introducing the helper function:

  1. Computing expectations (Kolmogorov backward) — the Kolmogorov backward equation and feynman_kac.
  2. Computing distributions (Kolmogorov forward) — the Kolmogorov forward equation and stationary_distribution.
  3. Application to a consumption-saving problem — how generator matrices enter implicit finite-difference methods for nonlinear HJB equations.
  4. Computing tail indices — principal eigenvalues of tilted generators, cgf, and tail_index.

Related packages

  • EconPDEs is focused on nonlinear PDEs resulting from optimization problems (HJB equations), while InfinitesimalGenerators is focused on solving linear PDEs. Of course, there is a decent overlap between the two: see this worked example in the EconPDEs documentation and Application to a consumption-saving problem in this one.
  • SimpleDifferentialOperators contains more general tools to define operators with different boundary conditions. In contrast, InfinitesimalGenerators always assumes reflecting boundaries.

About

Solve linear PDEs associated with Markov processes

Resources

License

Stars

9 stars

Watchers

2 watching

Forks

Packages

 
 
 

Contributors

Languages