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
- Marginalization:
which gives the prediction step in Bayesian filtering.
- Inverse factorization:
where evaluation of
] add MarkovKernelsTypes 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 endCurrently, 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 functionsThe 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}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)