Skip to content

Commit 0581a04

Browse files
committed
apply formatter
1 parent 97f6e4a commit 0581a04

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/multivariate/stereographic.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Stereographic slice sampling algorithm by Bell, Latuszynski, and Roberts[^BLR].
77
# Keyword Arguments
88
- `max_proposals::Int`: Maximum number of proposals allowed until throwing an error (default: `$(DEFAULT_MAX_PROPOSALS)`).
99
"""
10-
@kwdef struct StereographicSlice{RType <: Real} <: AbstractMultivariateSliceSampling
11-
max_proposals :: Int = DEFAULT_MAX_PROPOSALS
10+
@kwdef struct StereographicSlice{RType<:Real} <: AbstractMultivariateSliceSampling
11+
max_proposals::Int = DEFAULT_MAX_PROPOSALS
1212
end
1313

1414
struct StereographicSliceState{T<:Transition}
@@ -22,23 +22,23 @@ function rand_uniform_sphere_orthogonal_subspace(
2222
z = subspace_vector
2323
d = length(subspace_vector)
2424
v = randn(rng, d)
25-
v_proj = dot(z, v)/sum(abs2, z)*z
25+
v_proj = dot(z, v) / sum(abs2, z) * z
2626
v_orth = v - v_proj
27-
v_orth / norm(v_orth)
27+
return v_orth / norm(v_orth)
2828
end
2929

3030
function stereographic_projection(z::AbstractVector)
3131
d = length(z) - 1
32-
return z[1:d] ./ (1 - z[d+1])
32+
return z[1:d] ./ (1 - z[d + 1])
3333
end
3434

3535
function stereographic_inverse_projection(x::AbstractVector)
36-
d = length(x)
37-
z = zeros(d + 1)
38-
x_norm2 = sum(abs2, x)
39-
z[1:d] = 2*x / (x_norm2 + 1)
40-
z[d+1] = (x_norm2 - 1)/(x_norm2 + 1)
41-
z
36+
d = length(x)
37+
z = zeros(d + 1)
38+
x_norm2 = sum(abs2, x)
39+
z[1:d] = 2 * x / (x_norm2 + 1)
40+
z[d + 1] = (x_norm2 - 1) / (x_norm2 + 1)
41+
return z
4242
end
4343

4444
function AbstractMCMC.step(
@@ -56,8 +56,8 @@ function AbstractMCMC.step(
5656
end
5757

5858
function logdensity_sphere(ℓπ::Real, x::AbstractVector)
59-
d = length(x)
60-
return ℓπ + d*log(1 + sum(abs2, x))
59+
d = length(x)
60+
return ℓπ + d * log(1 + sum(abs2, x))
6161
end
6262

6363
function AbstractMCMC.step(
@@ -85,7 +85,7 @@ function AbstractMCMC.step(
8585
while true
8686
props += 1
8787

88-
x_prop = stereographic_projection(z*cos(θ) + v*sin(θ))
88+
x_prop = stereographic_projection(z * cos(θ) + v * sin(θ))
8989
ℓp_prop = LogDensityProblems.logdensity(logdensitymodel, x_prop)
9090
ℓp_sphere_prop = logdensity_sphere(ℓp_prop, x_prop)
9191

0 commit comments

Comments
 (0)