Skip to content

Commit

Permalink
v1.2.3 patch underflow bug in saddlepoint routine
Browse files Browse the repository at this point in the history
  • Loading branch information
wzhorton committed May 16, 2023
1 parent 38ca7a0 commit 495584b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PolyaGammaHybridSamplers"
uuid = "c636ee4f-4591-4d8c-9fae-2dea21daa433"
authors = ["W.Z. Horton"]
version = "1.2.2"
version = "1.2.3"

[deps]
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Expand Down
2 changes: 1 addition & 1 deletion src/rand_pgsaddlepoint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function rand_Jstar_tilted(b::Real, z::Real, rng::AbstractRNG)
lcn = 0.5 * log(0.5 * b *inv(π))
rt2rl = sqrt(2 * rl)

if abs(z) > 1e16 && iszero(K2md) # bypass for numerical stability
if abs(z) > 1e16 && K2md <= zero(K2md) # bypass for numerical stability
return rtigauss(inv(rt2rl), b, md, rng)
end

Expand Down
8 changes: 8 additions & 0 deletions test/rand_pgsaddlepoint_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ function test_rand_pgsaddlepoint_mean_var()
@test var(draws) var(s) rtol=0.005
end

function test_pgsaddlepoint_underflow()
b = 17
z = -6.128797345912032e16
s = PolyaGammaHybridSamplers.PolyaGammaHybridSampler(b, z, PolyaGammaHybridSamplers.SADDLEPOINT)
@test rand(s) 8.158207422758152e-18
end

# Run tests
@testset "Sampling method tests for Saddlepoint" begin
test_rand_pgsaddlepoint_mean_var()
test_pgsaddlepoint_underflow()
end

2 comments on commit 495584b

@wzhorton
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/83711

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.2.3 -m "<description of version>" 495584bf4be6cce528ad3f631395d10ffeb28d83
git push origin v1.2.3

Please sign in to comment.