Skip to content

Commit 87d6be7

Browse files
authored
Minor refactors (#25)
1 parent f5c5ac1 commit 87d6be7

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

docs/src/gibbs_polar.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# [Gibbsian Polar Slice Sampling](@id polar)
33

44
## Introduction
5-
Gibbsian polar slice sampling (GPSS) is a recent vector-valued slice sampling algorithm proposed by P. Schär, M. Habeck, and D. Rudolf[^SHR2023].
5+
Gibbsian polar slice sampling (GPSS) is a multivariate slice sampling algorithm proposed by P. Schär, M. Habeck, and D. Rudolf[^SHR2023].
66
It is an computationally efficient variant of polar slice sampler previously proposed by Roberts and Rosenthal[^RR2002].
77
Unlike other slice sampling algorithms, it operates a Gibbs sampler over polar coordinates, reminiscent of the elliptical slice sampler (ESS).
88
Due to the involvement of polar coordinates, GPSS only works reliably on more than one dimension.

src/multivariate/randpermgibbs.jl

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ struct GibbsState{T<:Transition}
2525
transition::T
2626
end
2727

28-
function AbstractMCMC.setparams!!(
29-
model::AbstractMCMC.LogDensityModel, state::GibbsState, params
30-
)
28+
function AbstractMCMC.setparams!!(model::AbstractMCMC.LogDensityModel, ::GibbsState, params)
3129
lp = LogDensityProblems.logdensity(model.logdensity, params)
3230
return GibbsState(Transition(params, lp, NamedTuple()))
3331
end

test/multivariate.jl

+6-8
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function LogDensityProblems.dimension(model::MultiModel)
5959
end
6060

6161
@testset "multivariate samplers" begin
62-
model = MultiModel(1.0, 1.0, [0.0])
62+
model = MultiModel(3.0, 3.0, [0.0])
6363
@testset for sampler in [
6464
# Vector-valued windows
6565
RandPermGibbs(Slice.(fill(1, LogDensityProblems.dimension(model)))),
@@ -74,14 +74,12 @@ end
7474
HitAndRun(SliceSteppingOut(1)),
7575
HitAndRun(SliceDoublingOut(1)),
7676

77-
# Latent slice sampling
77+
# Multivariate slice samplers
7878
LatentSlice(5),
79-
80-
# Gibbsian polar slice sampling
8179
GibbsPolarSlice(100),
8280
]
8381
@testset "initial_params" begin
84-
model = MultiModel(1.0, 1.0, [0.0])
82+
model = MultiModel(3.0, 3.0, [0.0])
8583
θ, y = MCMCTesting.sample_joint(Random.default_rng(), model)
8684
model′ = AbstractMCMC.LogDensityModel(@set model.y = y)
8785

@@ -92,7 +90,7 @@ end
9290

9391
@testset "initial_sample" begin
9492
rng = StableRNG(1)
95-
model = MultiModel(1.0, 1.0, [0.0])
93+
model = MultiModel(3.0, 3.0, [0.0])
9694
θ0 = SliceSampling.initial_sample(rng, model)
9795

9896
rng = StableRNG(1)
@@ -101,7 +99,7 @@ end
10199
end
102100

103101
@testset "determinism" begin
104-
model = MultiModel(1.0, 1.0, [0.0])
102+
model = MultiModel(3.0, 3.0, [0.0])
105103
θ, y = MCMCTesting.sample_joint(Random.default_rng(), model)
106104
model′ = AbstractMCMC.LogDensityModel(@set model.y = y)
107105

@@ -140,7 +138,7 @@ end
140138
n_mcmc_thin = 10
141139
test = ExactRankTest(n_samples, n_mcmc_steps, n_mcmc_thin)
142140

143-
model = MultiModel(1.0, 1.0, [0.0])
141+
model = MultiModel(3.0, 3.0, [0.0])
144142
subject = TestSubject(model, sampler)
145143
@test seqmcmctest(test, subject, 0.001, n_pvalue_samples; show_progress=false)
146144
end

test/turing.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
s ~ InverseGamma(2, 3)
55
m ~ Normal(0, sqrt(s))
66
1.5 ~ Normal(m, sqrt(s))
7-
return 2.0 ~ Normal(m, sqrt(s))
7+
2.0 ~ Normal(m, sqrt(s))
8+
return nothing
89
end
910

1011
n_samples = 1000

0 commit comments

Comments
 (0)