Skip to content

Broadcast mimic for Univariate nodes #35

Open
@kirill-kondrashov

Description

@kirill-kondrashov

In order to properly stack i.i.d. variables in a vector, I suggest to introduce a sort of broadcasting for (some of?) ::Univariate nodes.

Let’s say, I have a distribution, for example, Gamma, which is available only as ::Univariate. I can do that:

D = 2
x = Vector{Variable}(undef, D)
for d in 1:D
  @RV x[d] ~ Gamma(1, 1)
end

But further in the code x is ::Vector{Variable}, so you cannot use it in the model with some kind of vector arithmetics. I'd rather want it as follows:

@RV x ~ Gamma(ones(2), ones(2))

so that further x is a proper vector of two i.i.d. Gamma components.

The broadcast mimic option for Gamma node in this sense follows the spirit of other Julia packages (for instance, I can type pdf.(Gamma(1,1), x) where x can be either Array or scalar).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Broadcast mimic for Univariate nodes · Issue #35 · biaslab/ForneyLab.jl