biaslab / ForneyLab.jl

Julia package for automatically generating Bayesian inference algorithms through message passing on Forney-style factor graphs.
MIT License
149 stars 33 forks source link

Where are parameters stored in ForneyLab.Bernoulli? #199

Closed erlebach closed 2 years ago

erlebach commented 2 years ago

Consider the following code snippet:

using ForneyLab
g = FactorGraph()
@RV x ~ Bernoulli(0.7)

My question is: in what data structure is 0.7 stored? I found that Bernoulli is a struct.

albertpod commented 2 years ago

Hi @erlebach!

Roughly speaking, when you use @RV macro, ForneyLab integrates two nodes into your factor graph., i.e. Bernoulli node and clamped node that contains the value of 0.7.

I am not sure why you have this question, but you can access the value 0.7 as follows: g.nodes[:clamp_1].value

Why :clamp_1? You can access all of your nodes by running: g.nodes[:clamp_1].value.

erlebach commented 2 years ago

Why this question? Because before writing to Github, I was debugging my code, and was trying to trace information. That is how I learn. I was also looking at the source code, and had not come across "value". I will take another look.

ThijsvdLaar commented 2 years ago

Question seems to be answered, thanks Albert, I will close the issue.