Skip to content

Commit 6d630d9

Browse files
authored
Improve docs for GPSS (#7)
1 parent 2f49ad6 commit 6d630d9

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ This package implements slice sampling algorithms accessible through the `Abstra
99
For general usage, please refer to [here](https://turinglang.org/SliceSampling.jl/dev/general/).
1010

1111
## Implemented Algorithms
12-
- [Univariate slice sampling](https://turinglang.org/SliceSampling.jl/dev/univariate_slice/) algorithms with coordinate-wise Gibbs sampling by R. Neal [^N2003].
13-
- [Latent slice sampling](https://turinglang.org/SliceSampling.jl/dev/latent_slice/) by Li and Walker[^LW2023]
14-
- [Gibbsian polar slice sampling](https://turinglang.org/SliceSampling.jl/dev/gibbs_polar/) by P. Schär, M. Habeck, and D. Rudolf[^SHR2023].
12+
- Univariate slice sampling ([Slice](https://turinglang.org/SliceSampling.jl/dev/univariate_slice/)) algorithms with coordinate-wise Gibbs sampling by R. Neal [^N2003].
13+
- Latent slice sampling ([LSS](https://turinglang.org/SliceSampling.jl/dev/latent_slice/)) by Li and Walker[^LW2023]
14+
- Gibbsian polar slice sampling ([GPSS](https://turinglang.org/SliceSampling.jl/dev/gibbs_polar/)) by P. Schär, M. Habeck, and D. Rudolf[^SHR2023].
1515

1616
## Example with Turing Models
1717
This package supports the [Turing](https://github.com/TuringLang/Turing.jl) probabilistic programming framework:

docs/src/gibbs_polar.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ However, unlike ESS, GPSS is applicable to any target distribution.
1010

1111

1212
## Description
13-
For a $$d$$-dimensional target distribution, GPSS utilizes the following augmented target distribution:
13+
For a $$d$$-dimensional target distribution $$\pi$$, GPSS utilizes the following augmented target distribution:
1414
```math
1515
\begin{aligned}
1616
p(x, T) &= \varrho_{\pi}^{(0)}(x) \varrho_{\pi}^{(1)}(x) \, \operatorname{Uniform}\left(T; 0, \varrho^1(x)\right) \\
@@ -26,7 +26,7 @@ In a high-level view, GPSS operates a Gibbs sampler in the following fashion:
2626
T_n &\sim \operatorname{Uniform}\left(0, \varrho^{(1)}\left(x_{n-1}\right)\right) \\
2727
\theta_n &\sim \operatorname{Uniform}\left\{ \theta \in \mathbb{S}^{d-1} \mid \varrho^{(1)}\left(r_{n-1} \theta\right) > T_n \right\} \\
2828
r_n &\sim \operatorname{Uniform}\left\{ r \in \mathbb{R}_{\geq 0} \mid \varrho^{(1)}\left(r \theta_n\right) > T_n \right\} \\
29-
x &= \theta r,
29+
x_n &= \theta_n r_n,
3030
\end{aligned}
3131
```
3232
where $$T_n$$ is the usual acceptance threshold auxiliary variable, while $$\theta$$ and $$r$$ are the sampler states in polar coordinates.
@@ -51,7 +51,9 @@ GibbsPolarSlice
5151
```
5252

5353
## Demonstration
54-
As illustrated in the original paper, GPSS shows good performance on heavy-tailed targets despite being a multivariate slice sampler:
54+
As illustrated in the original paper, GPSS shows good performance on heavy-tailed targets despite being a multivariate slice sampler.
55+
Consider a 10-dimensional Student-$$t$$ target with 1-degree of freedom (this corresponds to a multivariate Cauchy):
56+
5557
```@example gpss
5658
using Distributions
5759
using Turing
@@ -64,12 +66,17 @@ using Plots
6466
end
6567
model = demo()
6668
67-
n_samples = 10000
68-
chain = sample(model, externalsampler(GibbsPolarSlice(10)), n_samples; initial_params=ones(10))
69-
histogram(chain[:,1,:], xlims=[-10,10])
70-
savefig("cauchy_gpss.svg")
69+
n_samples = 1000
70+
latent_chain = sample(model, externalsampler(LatentSlice(10)), n_samples; initial_params=ones(10))
71+
polar_chain = sample(model, externalsampler(GibbsPolarSlice(10)), n_samples; initial_params=ones(10))
72+
stephist( rand(TDist(1), 10000), bins=-10:1:10, normed=true, label="true", linewidth=3)
73+
stephist!(latent_chain[:,1,:], bins=-10:1:10, fill=true, alpha=0.5, normed=true, label="LSS")
74+
stephist!(polar_chain[:,1,:], bins=-10:1:10, fill=true, alpha=0.5, normed=true, label="GPSS")
75+
savefig("student_latent_gpss.svg")
7176
```
72-
![](cauchy_gpss.svg)
77+
![](student_latent_gpss.svg)
78+
79+
Clearly, for 1000 samples, GPSS is mixing much quicker than the [latent slice sampler](@ref latent) (LSS) at a similar per-iteration cost.
7380

7481

7582
[^SHR2023]: Schär, P., Habeck, M., & Rudolf, D. (2023, July). Gibbsian polar slice sampling. In International Conference on Machine Learning.

0 commit comments

Comments
 (0)