@@ -19,11 +19,11 @@ function AbstractMCMC.setparams!!(
19
19
end
20
20
21
21
function rand_uniform_sphere_orthogonal_subspace (
22
- rng:: Random.AbstractRNG , subspace_vector:: AbstractVector
23
- )
22
+ rng:: Random.AbstractRNG , subspace_vector:: AbstractVector{T}
23
+ ) where {T <: Real }
24
24
z = subspace_vector
25
25
d = length (subspace_vector)
26
- v = randn (rng, d)
26
+ v = randn (rng, T, d)
27
27
v_proj = dot (z, v) / sum (abs2, z) * z
28
28
v_orth = v - v_proj
29
29
return v_orth / norm (v_orth)
@@ -34,9 +34,9 @@ function stereographic_projection(z::AbstractVector)
34
34
return z[1 : d] ./ (1 - z[d + 1 ])
35
35
end
36
36
37
- function stereographic_inverse_projection (x:: AbstractVector )
37
+ function stereographic_inverse_projection (x:: AbstractVector{T} ) where {T <: Real }
38
38
d = length (x)
39
- z = zeros (d + 1 )
39
+ z = zeros (T, d + 1 )
40
40
x_norm2 = sum (abs2, x)
41
41
z[1 : d] = 2 * x / (x_norm2 + 1 )
42
42
z[d + 1 ] = (x_norm2 - 1 ) / (x_norm2 + 1 )
@@ -79,7 +79,7 @@ function AbstractMCMC.step(
79
79
ℓp_sphere = logdensity_sphere (ℓp, x)
80
80
ℓw = ℓp_sphere - Random. randexp (rng, eltype (x))
81
81
82
- θ = convert (eltype (x), 2 π)* rand (rng)
82
+ θ = convert (eltype (x), 2 π) * rand (rng)
83
83
θ_max = θ
84
84
θ_min = θ - convert (eltype (x), 2 π)
85
85
@@ -107,7 +107,7 @@ function AbstractMCMC.step(
107
107
θ_max = θ
108
108
end
109
109
110
- θ = (θ_max - θ_min)* rand (rng)
110
+ θ = (θ_max - θ_min) * rand (rng)
111
111
end
112
112
t = Transition (x, ℓp, (num_proposals= props,))
113
113
return t, t
0 commit comments