From ca88d00ed63d6e64be48b8abf2ad149637964d6d Mon Sep 17 00:00:00 2001 From: Matthieu Gomez Date: Wed, 12 Jun 2024 13:18:55 -0400 Subject: [PATCH] Update README.md --- README.md | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 537ea9b..8cf0c9f 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,31 @@ [![Build status](https://github.com/matthieugomez/InfinitesimalGenerators.jl/workflows/CI/badge.svg)](https://github.com/matthieugomez/InfinitesimalGenerators.jl/actions) +This package provides a set of tools to work with Markov Processes defined on a 1-dimensional Gri + + + # Markov Processes -- `X = DiffusionProcess(x::AbstractVector, μ::AbstractVector, σ::AbstractVector)` creates the discretized Markov Process with drift `μ` and volatility `σ`, on a grid `x` with reflecting boundaries. -- `generator(X)` returns its associated generator (i.e. the operator `f -> ∂_tE[f(x_t)|x_0=x]`) -- `stationary_distribution(X)` returns its stationary distribution (i.e. the positive vector `g` such that `g * generator(X) = 0`) +The package allows you to compute compute expectations involving Markov processes + +```julia +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[\int_0^T e^{-\int_0^t f(x_s)ds}f(x_s) + e^{-\int_0^T v(x_s)ds}ψ(x_T) | x_0 = x] +feynman_kac(MX; t = range(0, 100, step = 1/12), f = zeros(length(x)), ψ = ones(length(x)), v = zeros(length(x))) +``` # Additive Functionals - `M = AdditiveFunctional(X, μm, σm)` creates, given a discretized Markov Process, the Additive Functional with drift `μm` and volatility `σm` @@ -11,5 +33,21 @@ - `cgf(m)` returns the long run scaled CGF of `m` - `tail_index(m)` returns the tail index of the stationary distribution of `e^m` + + +# Derivative +The package allows you to compute (lazyly) the first and second derivatives on a grid through finite difference schemes + +``` +using InfinitesimalGenerators +x = range(-1, 1, length = 100) +f = sin.(x) +FirstDerivative(x, sin, direction = :upward, bc = (0, 0)) +FirstDerivative(x, sin, direction = :downward, bc = (0, 0)) +SecondDerivative(x, sin, bc = (0, 0)) +``` +The argument `bc` refers to the value of the first-derivative at the limit + + ## Related Packages - [SimpleDifferentialOperators](https://github.com/QuantEcon/SimpleDifferentialOperators.jl) contains more general tools to define operators with different boundary counditions. In contrast, InfinitesimalGenerators always assumes reflecting boundaries.