Skip to content

Commit

Permalink
Fix density computations
Browse files Browse the repository at this point in the history
Relates #13
  • Loading branch information
sethaxen committed Aug 22, 2021
1 parent 8102599 commit 3b607a0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/vonmisesfisher.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,28 +96,28 @@ function MeasureTheory.logdensity(d::VonMises{ℝ,(:μ, :κ)}, x)
end

function MeasureTheory.logdensity(d::VonMisesFisher{M,(:μ, :κ)}, x) where {M}
p = size(x, 1)
p = manifold_dimension(base_manifold(d)) + 1
κ = d.κ
return κ * real(dot(d.μ, x)) - lognorm_vmf(p, κ)
end
function MeasureTheory.logdensity(d::VonMisesFisher{M,(:c,)}, x) where {M}
p = size(x, 1)
p = manifold_dimension(base_manifold(d)) + 1
c = d.c
κ = norm(c)
return real(dot(c, x)) - lognorm_vmf(p, κ)
end
function MeasureTheory.logdensity(d::VonMisesFisher{M,(:F,)}, x) where {M}
n = size(x, 1)
n, _ = representation_size(base_manifold(d))
F = d.F
return real(dot(F, x)) - logpFq((), (n//2,), (F'F) / 4)
end
function MeasureTheory.logdensity(d::VonMisesFisher{M,(:U, :D, :V)}, x) where {M}
n = size(x, 1)
n, _ = representation_size(base_manifold(d))
D = Diagonal(d.D)
return real(dot(D * d.V', d.U' * x)) - logpFq((), (n//2,), D .^ 2 ./ 4)
end
function MeasureTheory.logdensity(d::VonMisesFisher{M,(:H, :P)}, x) where {M}
n = size(x, 1)
n, _ = representation_size(base_manifold(d))
P = d.P
return real(dot(d.H, P, x)) - logpFq((), (n//2,), (P^2) / 4)
end
Expand Down

0 comments on commit 3b607a0

Please sign in to comment.