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.

DiscreteDistribution

A DiscreteDistribution is a DiscreteConditional with no parents. It represents a prior probability on a single discrete variable, e.g., P(X)P(X). It can be thought of as a special case of a factor, specifically one that sums to 1.

It derives from gtsam.DiscreteConditional, so it can be used wherever a DiscreteConditional or another DiscreteFactor is expected, such as in a DiscreteFactorGraph or DiscreteBayesNet.

Open In Colab

Creating a DiscreteDistribution

A DiscreteDistribution is defined on a single DiscreteKey, which is a tuple of a gtsam Key (integer) and the variable’s cardinality (number of possible outcomes). They can be constructed in several ways.

Created from string:
Discrete Prior
 P( x0 ):
 Choice(x0) 
 0 Leaf  0.1
 1 Leaf  0.9


Created from vector:
Discrete Prior
 P( x0 ):
 Choice(x0) 
 0 Leaf  0.1
 1 Leaf  0.9

Operations on DiscreteDistribution

P(X0=0) = 0.1
P(X0=1) = 0.9

PMF vector: [0.1, 0.9]

Since DiscreteDistribution is a type of factor, it can be visualized.

Loading...

Displaying with Markdown/HTML

In a Jupyter environment, GTSAM objects often have a rich HTML display.

Loading...