Sampling
Use this module for sampling.
- class pybbn.sampling.sampling.LogicSampler(bbn)
Bases:
object
Logic sampling with rejection.
- __init__(bbn)
Ctor.
- Parameters:
bbn – BBN.
- get_samples(evidence={}, n_samples=100, seed=37)
Gets the samples.
- Parameters:
evidence – Evidence. Dictionary. Keys are ids and values are node values.
n_samples – Number of samples.
seed – Seed (default=37).
- Returns:
Samples.
- class pybbn.sampling.sampling.SortableNode(node_id, parent_ids)
Bases:
object
Sortable node.
- __init__(node_id, parent_ids)
Ctor.
- Parameters:
node_id – Node ID.
parent_ids – List of parent IDs.
- class pybbn.sampling.sampling.Table(node, parents=[])
Bases:
object
Table association parent instantiations with cumulative distributions of node values.
- __init__(node, parents=[])
Ctor.
- Parameters:
node – BBN node.
parents – List of parent BBN nodes.
- get_value(prob, sample=None)
Gets the value associated with the specified probability.
- Parameters:
prob – Probability.
sample – Dictionary of variable-value sampled so far.
- Returns:
Value.
- has_parents()
Checks if the node associated with this table has parents.
- Returns:
Boolean.