jmschrei / pomegranate

Fast, flexible and easy to use probabilistic modelling in Python.
http://pomegranate.readthedocs.org/en/latest/
MIT License
3.29k stars 590 forks source link

Sample function of Bayesian network #1106

Open yfpeng1234 opened 1 week ago

yfpeng1234 commented 1 week ago

Dear author, I found there might be a bug in Bayesian network's sample function. image For the above structure, assuming that the distribution list is ['c', 'a', 'b']: so firstly we will sample for node 'c', but we don't have value of 'a' and 'b', then we will sample for 'a' and 'b'. Finally we will not get the value of 'c' am I right?

jmschrei commented 1 week ago

Hm, looks like you might be right. This algorithm works if the nodes/features are already topologically sorted but, if they're not, I might need to add a second pass over the loop.