Now largely built into gtsam.discrete.
source
sample_bayes_net
sample_bayes_net (bn:gtsam.gtsam.GaussianBayesNet, N:int)
High performance ancestral sampling. It returns a dictionary of nj x N samples, where n_j is the dimensionality for key j.
source
sample_conditional
sample_conditional (node:gtsam.gtsam.GaussianConditional, N:int,
parents:list=[], sample:dict={})
Sample from conditional
_x_, _y_ = 11, 12
bayesNet = gtsam.GaussianBayesNet()
I_1x1 = np.eye(1, dtype=float)
bayesNet.push_back(gtsam.GaussianConditional(_x_, [9.0], I_1x1, _y_, I_1x1))
bayesNet.push_back(gtsam.GaussianConditional(_y_, [5.0], I_1x1))
sample_bayes_net(bayesNet, 4)
{12: array([[2.83568484, 5.93936955, 3.94485894, 6.90187555]]),
11: array([[5.2819049 , 2.60654641, 4.86926211, 0.530073 ]])}