-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more examples to docs #10
Comments
Exciting to see this work being done in Julia! Do you think it would make sense to include an example of how you could use the results of this package to initialize MCMC in Turing/Soss/Stan/etc? |
Sorry @joshualeond for the late reply! Yes, this is a great idea. We now have a Turing example, and a Soss one is planned. A Stan example would require one of the Stan interface packages exposing a log density function and its gradient, and I haven't found this functionality in any of the packages. |
I'm not sure where you think these should go in the docs, but I've got a donut example, using where |
@burtonjosh these look very nice, and I'd be happy to include them as examples! I think a new docs section "More examples" with a subpage for each would be a good way to go. Those pages could be pretty simple, with a couple sentences explaining why the example is interesting (e.g. "The donut is a challenging distribution that is impossible to fit well with single-path Pathfinder."), the formula of the model, definition of logp, running Pathfinder, and viewing draws over a marginal contour map (if possible) or verses exact draws with HMC. The logp of the multimodal distribution in the paper you referenced could be implemented something like: using Distributions, LinearAlgebra
struct MultimodalModel{T,Y,P1,P2}
σₚ::T
σₗ::T
y::Y
p1::P1
p2::P2
end
function (m::MultimodalModel)(θ)
(; σₚ, σₗ, y, p1, p2) = m
lp = logpdf(MvNormal(σₚ^2 * I(2)), θ)
d = MixtureModel(Normal.([p1(θ[1]), p2(θ[2])], σₗ))
lp += loglikelihood(d, y)
return lp
end Another multimodal distribution that might be worth looking into is a decaying periodic function in 2 dimensions. e.g. something like using Plots
logp(θ) = prod(x -> sin(5x), θ) - sum(abs2, θ)/2
contour(-3:0.01:3, -3:0.01:3, exp ∘ logp ∘ Base.vect) The first option is better for demonstrating performance with well-separated modes. The second option is better for demonstrating performance when the distribution is very bumpy, the modes are not well-separated, and each mode is non-normal. |
We should add at least the following examples to the docs:
The text was updated successfully, but these errors were encountered: