pgmpy / pgmpy

Python Library for learning (Structure and Parameter), inference (Probabilistic and Causal), and simulations in Bayesian Networks.

Home Page:https://pgmpy.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

what sampling method does approximate inference class use?

hjyoon93 opened this issue · comments

Inside approximate inference using sampling class,

there is this "query" function as below.

query(variables, n_samples=10000, samples=None, evidence=None, virtual_evidence=None, joint=True, state_names=None, show_progress=True, seed=None)

If I sample using "n_samples=100", what sampling method does it use to sample 100 samples?

Is it forward sampling, rejection sampling or likelihood weighted sampling?

And If I use query method to do sampling, does it sample based on evidence I give?

@hjyoon93 When no evidence is provided, it does a forward sampling. When evidence is provided, it does a rejection sampling till the specified number of samples are generated that satisfy the given evidence.