Julia-Tempering / Pigeons.jl

Sampling from intractable distributions, with support for distributed and parallel methods
https://pigeons.run/dev/
GNU Affero General Public License v3.0
83 stars 8 forks source link

Multimodal posterior distributions #111

Open itsdfish opened 1 year ago

itsdfish commented 1 year ago

Hello,

My understanding is that multimodal distributions are a common use case for parallel tempering. I'm assuming that this is true for this particular algorithm in Pigeons.jl. If so, it might be useful to advertise that in the documentation.

alexandrebouchard commented 1 year ago

Absolutely! In fact we are in the process of collecting examples from our research projects and those of others, of challenging posterior distributions for benchmarking, including multimodal ones. Open call for hard posteriors distributions to include in that benchmark set...

alexandrebouchard commented 1 year ago

...and good point for the doc, we should definitely say that multimodality is one of the use cases.

itsdfish commented 1 year ago

I am working with a model that might be a good candidate. I'm not quite sure when it will be ready. Would you still be interested in considering a model in the next month or two?

alexandrebouchard commented 1 year ago

Absolutely!

nikola-sur commented 1 year ago

Definitely! I would be happy to hear about that model + data when it is ready :)

itsdfish commented 10 months ago

Sorry for the long delay. The model I originally wanted to share is still not ready. However, I can share a similar model which has the benefit of being simpler. The quantum model, which is taken from Pothos & Busemeyer (2009), provides an explanation of the interference effect in the prisoner's dilemma. The documentation for the model can be found here.

The code to generate the plot below is:

using Pigeons
using QuantumPrisonersDilemmaModel
using Random
using StatsPlots
using Turing

Random.seed!(65)

# Generate some data with known parameters
n = 50
model = QPDM(;μd=1.0, γ=2.0)
data = rand(model, n)

# Specify turing model
@model function turing_model(data)
    γ ~ Normal(0, 3)
    data ~ QPDM(;μd=1.0, γ)
end

# Estimate the parameters
pt = pigeons(
    target=TuringLogPotential(turing_model((n, data))), 
    record=[traces])
samples = Chains(sample_array(pt), ["γ"])
plot(samples)

Here is the posterior distribution of the entanglement parameter:

example

Please feel free to use this if you think it is a helpful example of multimodal posterior distributions.

nikola-sur commented 10 months ago

Thank you for sharing this example!

alexandrebouchard commented 9 months ago

That's really cool. We are in the process of curating examples to put in a showcase website, we will be in touch soon!