liveBook · Manning

Probability distribution

As explained in Causal AI

A distribution specifies the probabilities or densities of the possible values of a random variable or set of variables.

Suppose a website feature changes how users engage. A single predicted engagement number hides variation across users. A probability distribution represents that variation: it assigns probability values to possible outcomes of a random variable. P(X) denotes the distribution over X; P(X=x) denotes the value assigned to one outcome. For a finite set of discrete outcomes, the distribution can be written as a table. section 2.3.1 section 2.1.2

A three-outcome distribution

Let X have outcomes 1, 2, and 3 with probabilities 0.45, 0.30, and 0.25. Then P(X=1)=0.45, and the three values sum to one. To parameterize another distribution with the same outcomes, choose the first two probabilities; the third is one minus their sum. In pgmpy, DiscreteFactor stores the outcome labels, cardinality, and values, and dist.sample(n=1) generates a one-row pandas DataFrame. section 2.1.2 section 2.1.6 section 2.2.2

Listing 2.1 Implementing a discrete distribution table in pgmpy
from pgmpy.factors.discrete import DiscreteFactor
dist = DiscreteFactor(
    variables=["X"],    #1
    cardinality=[3],    #2
    values=[.45, .30, .25],  #3
    state_names= {'X': ['1', '2', '3']}     #4
)
print(dist)

The pgmpy listing makes the table concrete: variables names X, cardinality sets its three outcomes, and values supplies their probabilities. section 2.1.2

The distribution needed depends on the question:

  • For a population question, a conditional distribution can isolate a subpopulation. P(E|F=True) describes engagement among users exposed to a feature; adding another condition narrows that population further. section 2.3.1
  • For simulation, sample outcomes from the specified distribution. A computer uses a seeded pseudo-random number generator to emulate random generation; sampling does not replace specifying the distribution. section 2.2.2
  • For a causal question, distinguish an observed action distribution from an intervention. P(X|C) can describe investors’ choices under economic conditions, but asking what would happen if you chose equity calls for intervention-based reasoning. Fixing an intervention target can change distributions of its causal descendants. section 12.1.2 section 7.3

A bar plot can display a discrete distribution; a curve can display a continuous normal distribution. Neither should be confused with a histogram of observed values. Distributions can also cover several variables jointly: an autoregressive language model, for example, assigns probabilities to token sequences by factoring their joint distribution into probabilities conditioned on preceding tokens. That predictive factorization does not, by itself, answer an intervention question. section 2.1.8 section 13.2.1 section 12.1.2

How Causal AI covers it

How deep it goes
Defines outcome probabilities, works through tabular parameters and sampling, and distinguishes observed distributions from intervention effects.
Examples
Uses a three-outcome table, website engagement subpopulations, investors’ actions, and token-sequence probabilities.
What it assumes
Introduces random-variable outcome notation and tabular probabilities before using parameterized distributions and computational sampling.
What you can do after
Apply it via pgmpy DiscreteFactor to specify and sample a finite discrete distribution.
How it connects
Connects conditional probability, joint distributions, random sampling, population models, and interventions.

Also explained in

Compare how 27 books explain probability distribution →

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.