AlgebraicInference.jl

Build Status Dev Docs Code Coverage

AlgebraicInference.jl is a library for performing Bayesian inference on wiring diagrams, building on Catlab.jl. See the documentation for example notebooks and an API.

How to Use

using AlgebraicInference
using Catlab.Programs

wd = @relation (x,) where (x::X, y::Y) begin
    prior(x)
    likelihood(x, y)
    evidence(y)
end

hom_map = Dict{Symbol, DenseGaussianSystem{Float64}}(
    :prior => normal(0, 1),           # x ~ N(0, 1)
    :likelihood => kernel([1], 0, 1), # y | x ~ N(x, 1)
    :evidence => normal(2, 0))        # y = 2

ob_map = Dict(
    :X => 1, # x ∈ ℝ¹
    :Y => 1) # y ∈ ℝ¹

ob_attr = :junction_type

# Solve directly.
Σ = oapply(wd, hom_map, ob_map; ob_attr)

# Solve using belief propagation.
ip = InferenceProblem(wd, hom_map, ob_map; ob_attr)
Σ = solve(ip, MinFill())

inference