Skip to content
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

Investigate rand calls in EpiAware #422

Open
SamuelBrand1 opened this issue Aug 15, 2024 · 0 comments
Open

Investigate rand calls in EpiAware #422

SamuelBrand1 opened this issue Aug 15, 2024 · 0 comments
Labels

Comments

@SamuelBrand1
Copy link
Collaborator

One thing that became clear from trying to resolve #340 and doing #418 is that somewhere in an EpiAware model inference we are getting rand calls that triggered an error at large values of the mean.

However, its actually quite hard to recreate a MFE of this as per TuringLang/Turing.jl#2301

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 without needing SafePoisson. Clearly in this example the problematic rand call is being avoided despite being roughly analogous to an EpiAware model.

We should watch out for this, because it might indicate a suboptimal decision in design somewhere that we could fix more directly (as opposed to patching our own custom distribution types).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant