-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Safety for poisson random calls #2301
Comments
Hi @SamuelBrand1, thanks for the issue! Could you provide a MWE that shows what you're trying to do with Turing that causes this crash? My initial impression is that this seems like an upstream issue with Distributions. |
Hey @penelopeysm Its actually quite hard to construct a MWE here from a clean script, for example, using Turing, Distributions
@model function rw_model(rw₀, n)
ϵ_t ~ filldist(Normal(), n)
rw = rw₀ .+ cumsum(ϵ_t)
return rw
end
@model function data_model(ys, rw)
for i in eachindex(rw)
ys[i] ~ Poisson(exp(rw[i]))
end
return ys
end
@model function pois_rw(ys, rw₀)
n = length(ys)
@submodel rw = rw_model(rw₀, n)
@submodel gen_ys = data_model(ys, rw)
return rw, gen_ys
end
generative_mdl = pois_rw(fill(missing,10), 3.)
ys = generative_mdl()[2] .|> Int
inference_mdl = pois_rw(ys, 48.) #deliberately bad choice for rw_0
chn = sample(inference_mdl, NUTS(), 1000) Works ok with package versions:
And this is roughly analogous to what @seabbs and myself are doing atm. |
This seems to suggest that I should move down towards |
Agreeing this does seem to be a |
That's basically a myth, and I'm not really sure where it comes from. The sampler in SciML and Distributions are actually basically identical and already quite a few years ago I noticed that SciML is not faster: SciML/PoissonRandom.jl#6 |
Issue in Distributions for the problem here: JuliaStats/Distributions.jl#821 We should hopefully be able to fix it when overhauling |
Hi everyone,
Base Julia can't convert large floats into
Int
type usingfloor
orround
etc. This creates a problem for sampling from Poisson's with a large mean because this is used in fast polyalgo for Poisson sampling.e.g.
Now this would not be problematic, because the
logpdf
calls are not affected but for some reason arand
call comes into usingTuring
at inference time (not sure why...).Is there any chance of a safer version of the Poisson/Negative Binomial that can detect if
round(BigInt, ...
should be used?The text was updated successfully, but these errors were encountered: