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

particles failing on some For distributions #203

Closed
cscherrer opened this issue Sep 7, 2020 · 2 comments · Fixed by #204
Closed

particles failing on some For distributions #203

cscherrer opened this issue Sep 7, 2020 · 2 comments · Fixed by #204

Comments

@cscherrer
Copy link
Owner

@DilumAluthge saw a problem in cscherrer/SossMLJ.jl#110 that seems to have its root in Soss.particles:

julia> Soss.particles(For(identity, Normal.(randn(3), randn(3).^2)))
ERROR: MethodError: no method matching Particles(::Int64, ::For{typeof(identity),Array{Normal{Float64},1},Normal{Float64},Float64})
Closest candidates are:
  Particles(::Integer) at /home/chad/.julia/packages/MonteCarloMeasurements/ETaFe/src/types.jl:71
  Particles(::Integer, ::Distribution{Multivariate,S} where S<:ValueSupport) at /home/chad/.julia/packages/MonteCarloMeasurements/ETaFe/src/types.jl:84
  Particles(::Integer, ::Distribution{var"#s47",VS} where var"#s47"; kwargs...) where VS at /home/chad/.julia/packages/MonteCarloMeasurements/ETaFe/src/types.jl:71
  ...
Stacktrace:
 [1] particles(::For{typeof(identity),Array{Normal{Float64},1},Normal{Float64},Float64}, ::Int64) at /home/chad/.julia/packages/Soss/I6MSl/src/particles.jl:12 (repeats 2 times)
 [2] top-level scope at REPL[47]:1
 [3] include_string(::Function, ::Module, ::String, ::String) at ./loading.jl:1088
@cscherrer
Copy link
Owner Author

Also, for background on the weird Particles hack we're currently using in Soss, baggepinnen/MonteCarloMeasurements.jl#22

@cscherrer
Copy link
Owner Author

When a model contains a For, the generated code calls the helper function parts, which in this case is

parts(d::For, N::Int=DEFAULT_SAMPLE_SIZE) = parts.(d.f.(d.θ...), N)

Changing this to parts.(d.f.(d.θ), N) fixes the problem for this case, but may break other uses of For.

A good way around this could be to add a collect(::For) method that returns a Vector{Distribution}. Then it's (hopefully) easy to make this do the right thing for any instance

@cscherrer cscherrer linked a pull request Sep 7, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant