'given' method with multiple arguments

Issue #18 closed
Pierre Denis repo owner created an issue

The "given" method, used for conditional probabilities and Bayesian reasoning, should be generalised to get multiple evidence conditions as arguments. This should be a handy alternative to ANDing conditions together. Example:

dice.given((4<=dice)&(dice<8))

could be replaced by

dice.given(4<=dice,dice<8)

This presents several advantages:

  1. The expression is simpler since parentheses can be removed.
  2. A set of conditions can be passed easily (with * prefix), which expresses more naturally a set of evidences.
  3. Performance can be improved greatly compared to ANDing evidences, providing the new "given" method uses short-circuit evaluation, i.e. exploration can be pruned as soon as a condition is evaluated to false.

The sole (minor) drawback is that an exception raised with an AND could not occur with the new technique, since some value combinations could be dropped due to short-circuit evaluation.

Comments (4)

  1. Log in to comment