@@ -32,7 +32,7 @@ Struct containing the results of the transition.
3232- `lp::Real`: Log-target density of the samples.
3333- `info::NamedTuple`: Named tuple containing information about the transition.
3434"""
35- struct Transition{P, L <: Real , I <: NamedTuple }
35+ struct Transition{P,L <: Real ,I <: NamedTuple }
3636 " current state of the slice sampling chain"
3737 params:: P
3838
@@ -53,47 +53,44 @@ Return the initial sample for the `model` using the random number generator `rng
5353- `model`: The target `LogDensityProblem`.
5454"""
5555function initial_sample (:: Random.AbstractRNG , :: Any )
56- error (
56+ return error (
5757 " `initial_sample` is not implemented but an initialization wasn't provided. " ,
58- " Consider supplying an initialization to `initial_params`."
58+ " Consider supplying an initialization to `initial_params`." ,
5959 )
6060end
6161
6262# If target is from `LogDensityProblemsAD`, unwrap target before calling `initial_sample`.
6363# This is necessary since Turing wraps `DynamicPPL.Model`s when passed to an `externalsampler`.
64- initial_sample (
65- rng:: Random.AbstractRNG ,
66- wrap:: LogDensityProblemsAD.ADGradientWrapper
67- ) = initial_sample (rng, parent (wrap))
64+ function initial_sample (
65+ rng:: Random.AbstractRNG , wrap:: LogDensityProblemsAD.ADGradientWrapper
66+ )
67+ return initial_sample (rng, parent (wrap))
68+ end
6869
6970function exceeded_max_prop (max_prop:: Int )
70- error (" Exceeded maximum number of proposal $(max_prop) , " ,
71- " which indicates an acceptance rate less than $(1 / max_prop* 100 ) %. " ,
72- " A quick fix is to increase `max_prop`, " ,
73- " but an acceptance rate that is too low often indicates that there is a problem. " ,
74- " Here are some possible causes:\n " ,
75- " - The model might be broken or degenerate (most likely cause).\n " ,
76- " - The tunable parameters of the sampler are suboptimal.\n " ,
77- " - The initialization is pathologic. (try supplying a (different) `initial_params`)\n " ,
78- " - There might be a bug in the sampler. (if this is suspected, file an issue to `SliceSampling`)\n "
79- )
71+ return error (
72+ " Exceeded maximum number of proposal $(max_prop) , " ,
73+ " which indicates an acceptance rate less than $(1 / max_prop* 100 ) %. " ,
74+ " A quick fix is to increase `max_prop`, " ,
75+ " but an acceptance rate that is too low often indicates that there is a problem. " ,
76+ " Here are some possible causes:\n " ,
77+ " - The model might be broken or degenerate (most likely cause).\n " ,
78+ " - The tunable parameters of the sampler are suboptimal.\n " ,
79+ " - The initialization is pathologic. (try supplying a (different) `initial_params`)\n " ,
80+ " - There might be a bug in the sampler. (if this is suspected, file an issue to `SliceSampling`)\n " ,
81+ )
8082end
8183
8284# # Univariate Slice Sampling Algorithms
8385export Slice, SliceSteppingOut, SliceDoublingOut
8486
85- abstract type AbstractUnivariateSliceSampling <: AbstractSliceSampling end
87+ abstract type AbstractUnivariateSliceSampling <: AbstractSliceSampling end
8688
87- accept_slice_proposal (
88- :: AbstractSliceSampling ,
89- :: Any ,
90- :: Real ,
91- :: Real ,
92- :: Real ,
93- :: Real ,
94- :: Real ,
95- :: Real ,
96- ) = true
89+ function accept_slice_proposal (
90+ :: AbstractSliceSampling , :: Any , :: Real , :: Real , :: Real , :: Real , :: Real , :: Real
91+ )
92+ return true
93+ end
9794
9895function find_interval end
9996
@@ -103,7 +100,7 @@ include("univariate/steppingout.jl")
103100include (" univariate/doublingout.jl" )
104101
105102# # Multivariate slice sampling algorithms
106- abstract type AbstractMultivariateSliceSampling <: AbstractSliceSampling end
103+ abstract type AbstractMultivariateSliceSampling <: AbstractSliceSampling end
107104
108105# Meta Multivariate Samplers
109106export RandPermGibbs, HitAndRun
0 commit comments