Skip to content

Skipping the Hastings computation for symmetric proposals #46

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

Merged
merged 9 commits into from
Dec 9, 2020

Conversation

luiarthur
Copy link
Contributor

This is a do-over of #45 for #41 which adds a method is_symmmetric_proposal whose behavior can be extended by users.

Copy link
Member

@devmotion devmotion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a better way to skip computations for symmetric proposals 👍

I added some comments and suggestions.

src/mh-core.jl Outdated
@@ -191,6 +191,41 @@ function AbstractMCMC.step(
return transition, transition
end

"""
is_symmetric_proposal(proposal::P) where P

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some explanation here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just added some documentation there.

test/runtests.jl Outdated

# Set up the proposal.
p1 = (x=RandomWalkProposal(Normal(0,.5)), y=RandomWalkProposal(Normal(0,.5)))
AdvancedMH.is_symmetric_proposal(proposal::typeof(p1)) = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a very "nice" example - usually one would want to define the trait for a custom proposal or distribution.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe define a custom distribution, e.g., of normal distributions with zero mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just modified the test.

Copy link
Member

@cpfiffer cpfiffer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it! No comments from me, though could you increment the version number to 0.5.6 before this is merged in?

@luiarthur
Copy link
Contributor Author

luiarthur commented Dec 9, 2020

The tests seem to be passing. But in the logs, I see this at the beginning (before the tests are actually run):

┌ Error: Pkg.Resolve.ResolverError("Unsatisfiable requirements detected for package MCMCChains [c7f686f2]:\n MCMCChains [c7f686f2] log:\n ├─possible versions are: [0.2.4, 0.3.0-0.3.15, 0.4.0-0.4.1, 1.0.0-1.0.2, 2.0.0, 3.0.0-3.0.12, 4.0.0-4.0.4, 4.1.0, 4.2.0-4.2.4, 4.3.0-4.3.1] or uninstalled\n ├─restricted to versions * by an explicit requirement, leaving only versions [0.2.4, 0.3.0-0.3.15, 0.4.0-0.4.1, 1.0.0-1.0.2, 2.0.0, 3.0.0-3.0.12, 4.0.0-4.0.4, 4.1.0, 4.2.0-4.2.4, 4.3.0-4.3.1]\n ├─restricted by compatibility requirements with Distributions [31c24e10] to versions: [4.2.4, 4.3.0-4.3.1] or uninstalled, leaving only versions: [4.2.4, 4.3.0-4.3.1]\n │ └─Distributions [31c24e10] log:\n │ ├─possible versions are: [0.16.0-0.16.4, 0.17.0, 0.18.0, 0.19.1-0.19.2, 0.20.0, 0.21.0-0.21.3, 0.21.5-0.21.12, 0.22.0-0.22.6, 0.23.0-0.23.12, 0.24.0-0.24.6] or uninstalled\n │ ├─restricted to versions 0.20-0.24 by AdvancedMH [5b7e9947], leaving only versions [0.20.0, 0.21.0-0.21.3, 0.21.5-0.21.12, 0.22.0-0.22.6, 0.23.0-0.23.12, 0.24.0-0.24.6]\n │ │ └─AdvancedMH [5b7e9947] log:\n │ │ ├─possible versions are: 0.5.6 or uninstalled\n │ │ └─AdvancedMH [5b7e9947] is fixed to version 0.5.6\n │ └─restricted to versions 0.24.6 by an explicit requirement, leaving only versions 0.24.6\n └─restricted by compatibility requirements with SpecialFunctions [276daf66] to versions: uninstalled — no versions left\n └─SpecialFunctions [276daf66] log:\n ├─possible versions are: [0.7.0-0.7.2, 0.8.0, 0.9.0, 0.10.0-0.10.3, 1.0.0, 1.1.0] or uninstalled\n └─restricted to versions 1.1.0 by an explicit requirement, leaving only versions 1.1.0", nothing)

Any thoughts?

@cpfiffer
Copy link
Member

cpfiffer commented Dec 9, 2020

I think that's because of a hangup in MCMCChains (TuringLang/MCMCChains.jl#252), but it doesn't seem to have impacted the tests so I think we can ignore it.

@cpfiffer cpfiffer merged commit f75b675 into TuringLang:master Dec 9, 2020
@luiarthur luiarthur deleted the issue41-attempt2 branch December 9, 2020 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants