diff --git a/src/PoissonRandom.jl b/src/PoissonRandom.jl index 2b01e9e..8c4509b 100644 --- a/src/PoissonRandom.jl +++ b/src/PoissonRandom.jl @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index e909f1a..24a1b34 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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")