Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

266 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MarkovKernels.jl

A package implementing distributions, Markov kernels, and likelihoods that all play nice with eachother. The main motivation is to simplify the implementation of Bayesian filtering and smoothing algorithms. Let $\pi(x)$ be a probability distribution and $k(y\mid x)$ a Markov kernel then only the following operations are required for Bayesian state estimation

  • Marginalization:

$$ k(y) = \int k(y\mid x) \pi(x) \mathrm{d} x, $$

which gives the prediction step in Bayesian filtering.

  • Inverse factorization:

$$ k(y\mid x)\pi(x) = \pi(x \mid y) k(y), $$

where evaluation of $\pi(x \mid y)$ at $y$ gives Bayes' rule and $k(y)$ is the marginal distribution of $y$ (used for prediction error decomposition of the marginal likelihood). In fact, the prediction step may be implemented with the inverse factorization operation as well, in which case $\pi(x\mid y)$ is the backwards kernel used to compute smoothing distributions in the Rauch-Tung-Striebel recursion. Please see the tutorials in the documentation.

Stable Dev Build Status Coverage

Installation

] add MarkovKernels

Package specific types

Types for representing marginal distributions, Markov kernels, and likelihoods:

abstract type AbstractAffineMap end # used to represent affine conditional means

abstract type AbstractDistribution end
abstract type AbstractMarkovKernel end
abstract type AbstractLikelihood end

Currently, the following concrete types are defined:

ProbabilityVector # Distribution over finite outcomes
Normal # Vector/Scalar valued Normal distributons
Dirac  # Vector/Scalar valued Dirac distributions

NormalKernel # Vector valued Normal kernels
DiracKernel  # Vector valued Dirac kernels
IdentityKernel # acts as identity with respect to marginalize
StochasticMatrix # Kernel over categories

LikelihoodVector # Likelihood function for categories
FlatLikelihood # Makes posterior/htransform (Bayes' rule) an identity mapping
Likelihood   # AbstractMarkovKernel paired with a measurement
LogQuadraticLikelihood # Canonical parametrization of log-quadratic likelihood functions

The following aliases are defined:

const HomoskedasticNormalKernel{TM,TC} = NormalKernel{<:Homoskedastic,TM,TC} where {TM,TC} # constant conditional covariance
const AffineHomoskedasticNormalKernel{TM,TC} =
    NormalKernel{<:Homoskedastic,TM,TC} where {TM<:AbstractAffineMap,TC} # affine conditional mean, constant conditional covariance
const AffineHeteroskedasticNormalKernel{TM,TC} =
    NormalKernel{<:Heteroskedastic,TM,TC} where {TM<:AbstractAffineMap,TC} # affine conditional mean, non-constant covariance
const NonlinearNormalKernel{TM,TC} = NormalKernel{<:Heteroskedastic,TM,TC} where {TM,TC} # the general, nonlinear case
const AffineDiracKernel{T} = DiracKernel{<:AbstractAffineMap{T}} where {T}

Functions

For the purpose of Bayesian state estimation, ideally the following functions are defined:

forward_operator(k::AbstractMarkovKernel, d::AbstractDistribution)
backward_operator(h, k::AbstractMarkovKernel)
invert(d::AbstractDistribution, k::AbstractMarkovKernel)
posterior(d::AbstractDistribution, h::AbstractLikelihood)
posterior(k::AbstractMarkovKernel, h::AbstractLikelihood)
posterior_and_loglike(d::AbstractDistribution, h::AbstractLikelihood)
htransform_and_likelihood(k::AbstractMarkovKernel, h::AbstractLikelihood)

These are currently implemented for Normal, AffineNormalKernel, AffineDiracKernel. Additionally, marginalize is implemented for Dirac with respect to the aforementioned kernels.

In practice, these functions can not be implemented exactly for a given general distribution / Markov kernel pair. Therefore, it is up to the user to define, when required, appropriate approximations, i.e.:

predict(d::AbstractDistribution, k::AbstractMarkovKernel)
update(d::AbstractDistribution, h::AbstractLikelihood)

About

Marginal distributions and Markov kernels that play nice with each other for the purpose of Bayesian state estimation.

Topics

Resources

Stars

18 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages