Skip to content

Commit

Permalink
Merge pull request #3 from devmotion/fix_rng
Browse files Browse the repository at this point in the history
Fix undefined RNG in exported sampler
  • Loading branch information
ChrisRackauckas authored Jan 11, 2019
2 parents 7f07101 + 540478d commit 82d88c6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/PoissonRandom.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
__precompile__()

module PoissonRandom

using Random

export pois_rand

function count_rand(λ,rng::AbstractRNG=Random.GLOBAL_RNG)
n = 0
c = randexp(rng)
Expand Down Expand Up @@ -139,14 +139,12 @@ function procf(λ, K::Int, s::Float64)
return px,py,fx,fy
end

function pois_rand(λ,rng::AbstractRNG=Base.GLOBAL_RNG)
function pois_rand(λ,rng::AbstractRNG=Random.GLOBAL_RNG)
if λ < 6
return count_rand(λ,rng)
else
return ad_rand(λ,rng)
end
end

export pois_rand

end # module
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,8 @@ println("testing ad random sampler")
for λ in [5.0, 10.0, 15.0, 20.0, 30.0]
test_samples(PoissonRandom.ad_rand, Distributions.Poisson(λ), n_tsamples)
end

println("testing mixed random sampler")
for λ in [5.0, 10.0, 15.0, 20.0, 30.0]
test_samples(pois_rand, Distributions.Poisson(λ), n_tsamples)
end

0 comments on commit 82d88c6

Please sign in to comment.