Skip to content

Commit 82e0542

Browse files
luiarthurdevmotion
andauthored
Apply suggestions from code review
Co-authored-by: David Widmann <[email protected]>
1 parent ee0a56a commit 82e0542

File tree

1 file changed

+9
-26
lines changed

1 file changed

+9
-26
lines changed

src/mh-core.jl

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -194,37 +194,20 @@ end
194194
"""
195195
is_symmetric_proposal(proposal)
196196
197-
# Example:
198-
199-
```julia
200-
using Distributions, AdvancedMH
201-
202-
# Model definition.
203-
model = DensityModel(s -> logpdf(Normal(), s.x) + logpdf(Normal(5,.7), s.y))
204-
205-
# Set up the proposal.
206-
p = (x=RandomWalkProposal(Normal(0,.5)), y=RandomWalkProposal(Normal(0,.5)))
207-
208-
# Implementing this will skip the computation of the Hastings ratio.
209-
AdvancedMH.is_symmetric_proposal(proposal::typeof(p)) = true
210-
211-
# Sample from the posterior with initial parameters.
212-
chain = sample(m1, MetropolisHastings(p), 100000; chain_type=Vector{NamedTuple})
213-
```
214197
"""
215-
is_symmetric_proposal(proposal::P) where P = false
198+
is_symmetric_proposal(proposal) = false
216199

217200
# The following univariate random walk proposals are symmetric.
218-
is_symmetric_proposal(proposal::RandomWalkProposal{<:Normal}) = true
219-
is_symmetric_proposal(proposal::RandomWalkProposal{<:MvNormal}) = true
220-
is_symmetric_proposal(proposal::RandomWalkProposal{<:TDist}) = true
221-
is_symmetric_proposal(proposal::RandomWalkProposal{<:Cauchy}) = true
201+
is_symmetric_proposal(::RandomWalkProposal{<:Normal}) = true
202+
is_symmetric_proposal(::RandomWalkProposal{<:MvNormal}) = true
203+
is_symmetric_proposal(::RandomWalkProposal{<:TDist}) = true
204+
is_symmetric_proposal(::RandomWalkProposal{<:Cauchy}) = true
222205

223206
# The following multivariate random walk proposals are symmetric.
224-
is_symmetric_proposal(proposal::RandomWalkProposal{AbstractArray{<:Normal}}) = true
225-
is_symmetric_proposal(proposal::RandomWalkProposal{AbstractArray{<:MvNormal}}) = true
226-
is_symmetric_proposal(proposal::RandomWalkProposal{AbstractArray{<:TDist}}) = true
227-
is_symmetric_proposal(proposal::RandomWalkProposal{AbstractArray{<:Cauchy}}) = true
207+
is_symmetric_proposal(::RandomWalkProposal{<:AbstractArray{<:Normal}}) = true
208+
is_symmetric_proposal(::RandomWalkProposal{<:AbstractArray{<:MvNormal}}) = true
209+
is_symmetric_proposal(::RandomWalkProposal{<:AbstractArray{<:TDist}}) = true
210+
is_symmetric_proposal(::RandomWalkProposal{<:AbstractArray{<:Cauchy}}) = true
228211

229212
# Define the other sampling steps.
230213
# Return a 2-tuple consisting of the next sample and the the next state.

0 commit comments

Comments
 (0)