liveBook · Manning

Canonical distribution

As explained in Causal AI

A canonical distribution is a standard mathematically characterized probability distribution used as a primitive for probabilistic models.

Suppose you need to model how often users engage with a feature, or how long a device lasts before failure. A canonical distribution is a mathematically well-described family of probability distributions that can serve as a modeling primitive. Its parameters—such as location, scale, rate, or shape—specify a particular distribution within that family. section 2.5 section 2.3.1

Choose a family by asking what random process could have produced the observations, not just which curve looks familiar. Repeated coin flips lead to a binomial distribution. Many independent or weakly dependent small changes can yield a normal distribution. An exponential distribution models waiting time when time already waited does not change the remaining wait; the corresponding count of events in a fixed interval has a Poisson distribution. section 2.3.1

In a model, the choice has two practical parts:

  • Choose distributions for the population and, where needed, its conditional subpopulations—for example, engagement among users exposed to a feature, further conditioned on an age group. section 2.3.1
  • Set or estimate parameters. For exogenous noise in a structural causal model, compare candidate families by fit after parameter estimation, including through cross-validation. The distribution and assignment function together must capture the intended assumptions about how outcomes arise. section 6.4.2

From observations to causal kernels

To model purchases, first represent guild membership, then engagement conditional on membership, then purchases conditional on both. Observed group proportions can inform membership and engagement probabilities; purchase data can supply group-level summary statistics. A Pyro model uses canonical distributions, including Bernoulli and Normal, for these kernels. Once specified, the model can be modified with `pyro.do` to simulate outcomes under an intervention on engagement. section 7.1.6

Listing 2.10 Generating IID samples in Pyro
import pyro
from pyro.distributions import Bernoulli, Poisson, Gamma

def model():
    z = pyro.sample("z", Gamma(7.5, 1.0))
    x = pyro.sample("x", Poisson(z))
    with pyro.plate("IID", 10):     #1
        y = pyro.sample("y", Bernoulli(x / (5+x)))    #2
    return y

model()

The Pyro listing shows Gamma, Poisson, and Bernoulli distributions used as primitives in one random process, with a plate for repeated IID samples. section 2.3.1

How Causal AI covers it

How deep it goes
Motivates choices through generating processes and elaborates exogenous-noise parameterizations, without deriving individual distribution formulas.
Examples
Uses coin flips, waiting times, and a Pyro model of guild membership, engagement, and purchases.
What it assumes
Builds on random variables and conditional probability, while motivating distribution choices through stochastic processes.
What you can do after
Apply it via Pyro to specify causal kernels from data and simulate outcomes under interventions.
How it connects
Links stochastic processes and conditional probability to causal Markov kernels and interventions.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Causal AI. The section links point to the parts of the book it draws on.