@@ -28,8 +28,9 @@ struct GibbsPolarSlice{W<:Real} <: AbstractMultivariateSliceSampling
28
28
max_proposals:: Int
29
29
end
30
30
31
- GibbsPolarSlice (w:: Real ; max_proposals:: Int = DEFAULT_MAX_PROPOSALS) =
32
- GibbsPolarSlice (w, max_proposals)
31
+ function GibbsPolarSlice (w:: Real ; max_proposals:: Int = DEFAULT_MAX_PROPOSALS)
32
+ return GibbsPolarSlice (w, max_proposals)
33
+ end
33
34
34
35
struct GibbsPolarSliceState{T<: Transition ,R<: Real ,D<: AbstractVector }
35
36
" Current [`Transition`](@ref)."
48
49
49
50
function logdensity (target:: GibbsPolarSliceTarget , x)
50
51
d = length (x)
51
- (d - 1 ) * log (norm (x)) + LogDensityProblems. logdensity (target. model, x)
52
+ return (d - 1 ) * log (norm (x)) + LogDensityProblems. logdensity (target. model, x)
52
53
end
53
54
54
55
function AbstractMCMC. step (
55
56
rng:: Random.AbstractRNG ,
56
57
model:: AbstractMCMC.LogDensityModel ,
57
58
sampler:: GibbsPolarSlice ;
58
- initial_params = nothing ,
59
+ initial_params= nothing ,
59
60
kwargs... ,
60
61
)
61
62
logdensitymodel = model. logdensity
@@ -76,7 +77,7 @@ function rand_subsphere(rng::Random.AbstractRNG, θ::AbstractVector)
76
77
d = length (θ)
77
78
V1 = randn (rng, eltype (θ), d)
78
79
V2 = V1 - dot (θ, V1) * θ
79
- V2 / max (norm (V2), eps (eltype (θ)))
80
+ return V2 / max (norm (V2), eps (eltype (θ)))
80
81
end
81
82
82
83
function geodesic_shrinkage (
@@ -91,7 +92,7 @@ function geodesic_shrinkage(
91
92
ω_max = convert (F, 2 π) * rand (rng, F)
92
93
ω_min = ω_max - convert (F, 2 π)
93
94
94
- for n_props = 1 : max_prop
95
+ for n_props in 1 : max_prop
95
96
# `Uniform` had a type instability issue:
96
97
# https://github.com/JuliaStats/Distributions.jl/pull/1860
97
98
# ω = rand(rng, Uniform(ω_min, ω_max))
@@ -108,7 +109,7 @@ function geodesic_shrinkage(
108
109
ω_max = ω
109
110
end
110
111
end
111
- exceeded_max_prop (max_prop)
112
+ return exceeded_max_prop (max_prop)
112
113
end
113
114
114
115
function radius_shrinkage (
@@ -148,7 +149,7 @@ function radius_shrinkage(
148
149
end
149
150
n_props_total += n_props
150
151
151
- for n_props = 1 : max_prop
152
+ for n_props in 1 : max_prop
152
153
# `Uniform` had a type instability issue:
153
154
# https://github.com/JuliaStats/Distributions.jl/pull/1860
154
155
# r′ = rand(rng, Uniform{F}(r_min, r_max))
@@ -165,7 +166,7 @@ function radius_shrinkage(
165
166
r_max = r′
166
167
end
167
168
end
168
- exceeded_max_prop (max_prop)
169
+ return exceeded_max_prop (max_prop)
169
170
end
170
171
171
172
function AbstractMCMC. step (
@@ -194,9 +195,7 @@ function AbstractMCMC.step(
194
195
195
196
ℓp = LogDensityProblems. logdensity (logdensitymodel, x)
196
197
t = Transition (
197
- x,
198
- ℓp,
199
- (num_radius_proposals = n_props_r, num_direction_proposals = n_props_θ),
198
+ x, ℓp, (num_radius_proposals= n_props_r, num_direction_proposals= n_props_θ)
200
199
)
201
- t, GibbsPolarSliceState (t, θ, r)
200
+ return t, GibbsPolarSliceState (t, θ, r)
202
201
end
0 commit comments