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

Implement dummy types for distributions #59

Open
kskyten opened this issue Nov 8, 2019 · 2 comments
Open

Implement dummy types for distributions #59

kskyten opened this issue Nov 8, 2019 · 2 comments

Comments

@kskyten
Copy link

kskyten commented Nov 8, 2019

Distributions.jl is not very flexible with respect to argument types. Implementing custom types, which are basically just wrappers for the arguments would allow more flexibility. For example, the following abuse of notation is not currently possible, since Poisson only allows scalar arguments (note that #14 is probably a better option for this)

simple_poisson = @model (α, β, traps) begin
    λ = α .+ β .* traps
    complaints ~ Poisson(λ)
end

These distribution types would also make it possible to separate the code generation for different back ends (Distributions.jl, Stan math, etc.) into different packages.

@kskyten
Copy link
Author

kskyten commented Nov 8, 2019

Keep an eye out for stan-dev/stanc3#324 as well.

@cscherrer
Copy link
Owner

Right, currently this requires a For. I like the idea of being able to express it more simply, But to keep things simple and lightweight, I try to lean as much as possible on other libraries. To be able to write this, I would need to implement Poisson(::Array). That's not to say that this is out of the question, rather that it wouldn't need to be a core part of Soss.

As you point out, there's also the option of broadcasting. Poisson.(λ::Array) already creates an Array{Poisson}, so adding support for .~ would allow us to write

complaints .~ Poisson.(λ)

I'll comment more on this in #14.

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

No branches or pull requests

2 participants