Skip to content

Add broadcasting tilde operation #10

@bvdmitri

Description

@bvdmitri

Would be nice to support broadcasting operation for tilde operation in the following way:

@model function mymodel(c)
     y = datavar(Float64, n)
     x = randomvar(n)
     
     x .~ Normal(0.0, 1.0) # iid, unrolls to for array automatically
     y .~ Normal(x, 1.0) # equivalent to 'for each y_i ~ Normal(x_i, 1.0)`
end

It should be relatively easy to implement with the built-in broadcast function.

Creating random variables from broadcasting operation with AutoVar might be challenging, not impossible though.

@model function mymodel(c)
     y = datavar(Float64, n)
     x = randomvar(n)
     
     x .~ Normal(0.0, 1.0) # iid, unrolls to for array automatically
     z .~ Normal(x, 1.0) #  z has not been defined before, but might be created automatically
     y .~ Normal(x, 1.0) # equivalent to 'for each y_i ~ Normal(x_i, 1.0)`
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions