ReactiveBayes / RxInfer.jl

Julia package for automated Bayesian inference on a factor graph with reactive message passing
MIT License
237 stars 24 forks source link

Not able to multiply matrix with a vector of random Variable. #217

Closed prantik1998 closed 5 months ago

prantik1998 commented 5 months ago

Hello everyone.

I am not able to multiply matrix with a vector of random variable

This is the code

function f(x,a,b,c,d)
    A = [a b; c d]
    A*x
end
@model function coin_toss_model(A,m,n)
    lambda = 0.5
    x = randomvar(m)
    y = datavar(Int64,n)
    x .~ Beta(1,lambda)
    u ~ f(x, A[1, 1], A[1, 2], A[2, 1], A[2, 2])
    for i in 1:m
        y[i] ~ Bernoulli(u[i])
    end
end
HoangMHNguyen commented 5 months ago

Hi @prantik1998! Thank you for playing around with RxInfer.jl. I think this issue isn't related to multiplying a matrix with a vector of random variables but it comes from your model definition. It seems that you've defined an invalid model. For example, Bernoulli only accepts a real number as input, not a vector. Besides, the broadcasting feature isn't available in Rxinfer.jl yet.