This package provides a set of tools to work with Markov Processes defined on a 1-dimensional grid
The package allows you to compute compute expectations involving Markov processes
using InfinitesimalGenerators
# Create a diffusion process (here, the Ornstein–Uhlenbeck dx = -0.03 * x * dt + 0.01 * dZ_t)
# Note that the package assumes reflecting boundaries at the limits
x = range(-1, 1, length = 100)
μx = .- 0.03 .* x
σx = 0.01 .* ones(length(x))
X = DiffusionProcess(x, μx, σx)
# Return its stationary distribution
g = stationary_distribution(X)
# Return the associated generator as a matrix (i.e. the operator `f -> ∂_tE[f(x_t)|x_0=x]`)
MX = generator(X)
# Use the generator to compute E[∫_0^T e^{-∫_0^t v(x_s)ds}f(x_t)dt + e^{-∫_0^T v(x_s)ds}ψ(x_T) | x_0 = x]
feynman_kac(MX, range(0, 100, step = 1/12); f = zeros(length(x)), ψ = ones(length(x)), v = zeros(length(x)))
M = AdditiveFunctional(X, μm, σm)
creates, given a discretized Markov Process, the Additive Functional with driftμm
and volatilityσm
generator(M)
returns its associated generator (i.e. the operatorf -> ∂_tE[e^{m}f(x_t)|x_0=x]
)cgf(m)
returns the long run scaled CGF ofm
tail_index(m)
returns the tail index of the stationary distribution ofe^m
The package also allows you to compute (lazy) first and second derivatives of a function on a grid using a finite difference schemes
using InfinitesimalGenerators
x = range(-1, 1, length = 100)
f = sin.(x)
FirstDerivative(x, f, direction = :upward, bc = (0, 0))
FirstDerivative(x, f, direction = :downward, bc = (0, 0))
SecondDerivative(x, f, bc = (0, 0))
The argument bc
refers to the value of the first-derivative at each limit of the grid. This argument defaults to zero, which is the right condition when solving problems with reflecting boundaries.
- SimpleDifferentialOperators contains more general tools to define operators with different boundary counditions. In contrast, InfinitesimalGenerators always assumes reflecting boundaries.