Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/PoissonRandom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function ad_rand(rng::AbstractRNG, λ::Real)
end

# Procedure F
function procf(λ::Real, K::Int, s::Float64)
function procf(λ::Real, K::Int, s::Real)
# can be pre-computed, but does not seem to affect performance
INV_SQRT_2PI = inv(sqrt(2pi))
ω = INV_SQRT_2PI / s
Expand Down
24 changes: 24 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,30 @@ for λ in [5.0, 10.0, 15.0, 20.0, 30.0]
test_samples(pois_rand, Distributions.Poisson(λ), n_tsamples)
end

@testset "BigFloat support" begin
@testset "count_rand with BigFloat (λ < 6)" begin
for _ in 1:100
result = pois_rand(BigFloat(3.0))
@test result isa Integer
@test result >= 0
end
end
@testset "ad_rand with BigFloat (λ >= 6)" begin
for _ in 1:100
result = pois_rand(BigFloat(15.0))
@test result isa Integer
@test result >= 0
end
end
@testset "statistical validity with BigFloat" begin
n = 10000
λ = BigFloat(10.0)
samples = [pois_rand(λ) for _ in 1:n]
sample_mean = mean(samples)
@test abs(sample_mean - Float64(λ)) < 3 * sqrt(Float64(λ))
end
end

if get(ENV, "GROUP", "all") == "all" || get(ENV, "GROUP", "all") == "nopre"
@testset "Allocation Tests" begin
include("alloc_tests.jl")
Expand Down
Loading