Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

DiscreteConditional

A DiscreteConditional represents a conditional probability distribution, P(Frontal∣Parents)P(\text{Frontal} | \text{Parents}), for a set of discrete variables. It is a fundamental building block for representing directed graphical models, like Bayes Nets.

It is a DecisionTreeFactor underneath, but with the additional structure that it distinguishes between frontal (child) and parent variables. The stored values are the probabilities, and for any given assignment to the parent variables, the probabilities of the frontal variable(s) sum to 1.

Open In Colab

Creating a DiscreteConditional

A DiscreteConditional is created by specifying the frontal (child) key(s), the parent key(s), and the conditional probability table (CPT). The CPT can be given as a list of numbers or a formatted string.

--- P(Cloudy) ---
Discrete Conditional
 P( c0 ):
 Leaf  0.5


--- P(Sprinkler | Cloudy) ---
Discrete Conditional
 P( s0 | c0 ):
 Choice(s0) 
 0 Choice(c0) 
 0 0 Leaf  0.5
 0 1 Leaf  0.9
 1 Choice(c0) 
 1 0 Leaf  0.5
 1 1 Leaf  0.1


--- P(Rain | Cloudy) ---
Discrete Conditional
 P( r0 | c0 ):
 Choice(r0) 
 0 Choice(c0) 
 0 0 Leaf  0.2
 0 1 Leaf  0.8
 1 Choice(c0) 
 1 0 Leaf  0.8
 1 1 Leaf  0.2

Operations on DiscreteConditional

P(S=0|C=1) = 0.9 (log: -0.10536051565782628)

Sample for Sprinkler given Cloudy=true: 0
Most likely state for Sprinkler given Cloudy=true: 0
P(S | C=false):
Discrete Conditional
 P( s0 ):
 Leaf  0.5


Likelihood L(C | S=true):
DecisionTreeFactor
 f[ (c0,2), ]
 Choice(c0) 
 0 Leaf  0.5
 1 Leaf  0.1

Displaying with Markdown/HTML

The rich display for a conditional shows the full CPT.

Loading...