@@ -32,7 +32,7 @@ Struct containing the results of the transition.
32
32
- `lp::Real`: Log-target density of the samples.
33
33
- `info::NamedTuple`: Named tuple containing information about the transition.
34
34
"""
35
- struct Transition{P, L <: Real , I <: NamedTuple }
35
+ struct Transition{P,L <: Real ,I <: NamedTuple }
36
36
" current state of the slice sampling chain"
37
37
params:: P
38
38
@@ -53,47 +53,44 @@ Return the initial sample for the `model` using the random number generator `rng
53
53
- `model`: The target `LogDensityProblem`.
54
54
"""
55
55
function initial_sample (:: Random.AbstractRNG , :: Any )
56
- error (
56
+ return error (
57
57
" `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`." ,
59
59
)
60
60
end
61
61
62
62
# If target is from `LogDensityProblemsAD`, unwrap target before calling `initial_sample`.
63
63
# 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
68
69
69
70
function 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
+ )
80
82
end
81
83
82
84
# # Univariate Slice Sampling Algorithms
83
85
export Slice, SliceSteppingOut, SliceDoublingOut
84
86
85
- abstract type AbstractUnivariateSliceSampling <: AbstractSliceSampling end
87
+ abstract type AbstractUnivariateSliceSampling <: AbstractSliceSampling end
86
88
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
97
94
98
95
function find_interval end
99
96
@@ -103,7 +100,7 @@ include("univariate/steppingout.jl")
103
100
include (" univariate/doublingout.jl" )
104
101
105
102
# # Multivariate slice sampling algorithms
106
- abstract type AbstractMultivariateSliceSampling <: AbstractSliceSampling end
103
+ abstract type AbstractMultivariateSliceSampling <: AbstractSliceSampling end
107
104
108
105
# Meta Multivariate Samplers
109
106
export RandPermGibbs, HitAndRun
0 commit comments