-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
Can't get particles from a model with a Poisson likelihood #99
Comments
If we unwind what Soss is doing, we get to julia> λ = Particles(Normal(10000,1))
Part500(10000.0 ± 1.0)
julia> pois = Poisson(λ)
Poisson{Particles{Float64,500}}(
λ: 10000.0 ± 1.0
)
julia> Particles(500, pois)
ERROR: UndefVarError: maybe_particles not defined Originally all of the |
I can not reproduce it here, which version of MonteCarloMeasurements are you running? julia> λ = Particles(Normal(10000,1))
Part500(10000.0 ± 1.0)
julia> pois = Poisson(λ)
Poisson{Particles{Float64,500}}(
λ: 10000.0 ± 1.0
)
julia> Particles(500, pois)
ERROR: TypeError: non-boolean (Particles{Float64,500}) used in boolean context
Stacktrace:
[1] sampler at /home/fredrikb/.julia/packages/Distributions/KjaXI/src/univariate/discrete/poisson.jl:147 [inlined]
[2] rand at /home/fredrikb/.julia/packages/Distributions/KjaXI/src/univariates.jl:158 [inlined]
[3] rand at /home/fredrikb/.julia/packages/Distributions/KjaXI/src/genericrand.jl:24 [inlined]
[4] #Particles#110(::Bool, ::Bool, ::Type{Particles}, ::Int64, ::Poisson{Particles{Float64,500}}) at /home/fredrikb/.julia/packages/MonteCarloMeasurements/hYwGr/src/particles.jl:238
[5] Particles(::Int64, ::Poisson{Particles{Float64,500}}) at /home/fredrikb/.julia/packages/MonteCarloMeasurements/hYwGr/src/particles.jl:235
[6] top-level scope at none:0 I tried on Soss v0.9.0 which installs MCM v0.5.8 EDIT: I could reproduce the problem on master. Should be solved by the commit referenced below. |
I think I have found and solved the problem in baggepinnen/MonteCarloMeasurements.jl@84d5fb2 |
A new version is tagged, I hope it resolves this issue. |
Thanks @baggepinnen, the fix resolved that issue! I'm now seeing the error you posted: julia> using Soss, Distributions
[ Info: Precompiling Soss [8ce77f84-9b61-11e8-39ff-d17a774bf41c]
julia> m = @model begin
λ ~ Normal(10000, 1)
y ~ Poisson(λ)
end;
julia> particles(m())
ERROR: TypeError: non-boolean (Particles{Bool,1000}) used in boolean context
Stacktrace:
[1] sampler at /Users/saxen/.julia/packages/Distributions/KjaXI/src/univariate/discrete/poisson.jl:147 [inlined]
[2] rand at /Users/saxen/.julia/packages/Distributions/KjaXI/src/univariates.jl:158 [inlined]
[3] rand at /Users/saxen/.julia/packages/Distributions/KjaXI/src/genericrand.jl:26 [inlined]
[4] #Particles#18(::Bool, ::Bool, ::Type{Particles}, ::Random._GLOBAL_RNG, ::Int64, ::Poisson{Particles{Float64,1000}}) at /Users/saxen/.julia/packages/MonteCarloMeasurements/6Onbj/src/types.jl:63
[5] Particles at /Users/saxen/.julia/packages/MonteCarloMeasurements/6Onbj/src/types.jl:60 [inlined]
[6] #Particles#19 at /Users/saxen/.julia/packages/MonteCarloMeasurements/6Onbj/src/types.jl:68 [inlined]
[7] Particles at /Users/saxen/.julia/packages/MonteCarloMeasurements/6Onbj/src/types.jl:68 [inlined]
[8] parts at /Users/saxen/projects/Soss.jl/src/particles.jl:41 [inlined]
[9] macro expansion at /Users/saxen/.julia/packages/GeneralizedGenerated/EBwdX/src/closure_conv.jl:121 [inlined]
[10] _particles(::Type{TypeEncoding(Main)}, ::Model{NamedTuple{(),T} where T<:Tuple,TypeEncoding(begin
λ ~ Normal(10000, 1)
y ~ Poisson(λ)
end),TypeEncoding(Main)}, ::NamedTuple{(),Tuple{}}, ::Val{1000}) at /Users/saxen/.julia/packages/GeneralizedGenerated/EBwdX/src/closure_conv.jl:121
[11] particles at /Users/saxen/projects/Soss.jl/src/particles.jl:66 [inlined] (repeats 2 times)
[12] top-level scope at REPL[3]:1 This arises when the rate parameter of the Poisson distribution is a @cscherrer, @baggepinnen what's the recommended way to proceed here? This is the issue with having a |
Yeah that question is a bit harder to answer, see the full discussion here I have a draft solution that operates on the representation |
Calling
particles
on a model with aPoisson
distributed variable fails if its rate parameter is drawn from another distribution. eg:The text was updated successfully, but these errors were encountered: