Conjugate inference

@filchristou ReactiveMP.jl supports infrastructure to run very efficient Bayesian inference in models with conjugate pairs. A large table of rules has been implemented for many conjugate pairs (but not for all…). You can check-out this example on Beta-Bernoulli distributions: Getting Started · ReactiveMP.jl. On my laptop ReactiveMP.jl computes exact posterior with less than 1 seconds from dataset with 100_000 points:

julia> p
0.75

julia> dataset = float.(rand(rng, Bernoulli(p), n))

julia> length(dataset)
100000

julia> @btime inference(
           model = Model($coin_model, length($dataset)),
           data  = (y = $dataset, )
       )
  693.036 ms (10499774 allocations: 465.60 MiB)

julia> result.posteriors[:θ][end]
Beta{Float64}(α=74987.0, β=25022.0)

julia> mean_var(result.posteriors[:θ][end])
(0.7498025177734003, 1.8757994411965801e-6)

If you are interested we have a list of examples available in the documentation and in the repository. Worth noting though that ReactiveMP supports not only conjugate pairs.

4 Likes