Skip to content

Commit 2f946ce

Browse files
committed
fix: ClosedWilliamsProduct for Exponetial on LogNormal
1 parent 4fd8cc7 commit 2f946ce

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/Exponential/Exponential.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function mean(::ClosedWilliamsProduct, q::Exponential, p::ExpLogSquare)
3232
return 1/(2*σ^2)*(-1/λ*(-2*(eulergamma+μ) + log(λ)) - log(λ)/λ)
3333
end
3434

35-
function mean(::ClosedFormExpectation, q::Exponential, p::LogNormal)
35+
function mean(::ClosedWilliamsProduct, q::Exponential, p::LogNormal)
3636
μ, σ = p.μ, p.σ
3737
λ = mean(q)
3838
return 1/(2*σ^2)*(-1/λ*(-2*(eulergamma+μ) + log(λ)) - log(λ)/λ) - 1/λ

test/Exponential/williams_tests.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ end
4747
end
4848
end
4949

50-
@testitem "meanlog(::ClosedWilliamsProduct, q::Exponential, p::LogNormal)" begin
50+
@testitem "mean(::ClosedWilliamsProduct, q::Exponential, p::LogNormal)" begin
5151
using Distributions
5252
using ClosedFormExpectations
5353
using StableRNGs
@@ -64,12 +64,11 @@ end
6464
μ = rand(rng)*10
6565
σ = rand(rng)*10
6666
λ = rand(rng)*10
67-
N = 10^7
67+
N = 10^6
6868
samples = rand(rng, Exponential(λ), 10^6)
6969
fn(x) = logpdf(LogNormal(μ, σ), x)
7070
williams_product = map(x -> score(Exponential(λ), x)*fn(x), samples)
71-
expectation = mean(ClosedWilliamsProduct(), Exponential(λ), ExpLogSquare(μ, σ))
72-
@show mean(williams_product)
73-
@show expectation
71+
expectation = mean(ClosedWilliamsProduct(), Exponential(λ), LogNormal(μ, σ))
72+
@test sigma_rule(expectation, mean(williams_product), std(williams_product), N)
7473
end
7574
end

0 commit comments

Comments
 (0)