forward_sample#
- causalbase.io.forward_sample(bn, n, seed)[source]#
Draw n i.i.d. samples from bn by ancestral (forward) sampling.
- Parameters:
- bnDiscreteBN
The network to sample from, as returned by
causalbase.io.xbif.load_xbif().- nint
Number of rows to sample.
- seedint
Random seed. The same seed always gives the same data.
- Returns:
- DiscreteDataset
The samples, with variables in bn’s order and levels coded in sorted order, as DiscreteDataset.from_csv does.