datarekha
Statistics & Probability Medium Asked at GoogleAsked at MetaAsked at Amazon

Explain joint, marginal, and conditional distributions and how to move between them.

The short answer

The joint distribution P(X, Y) fully specifies two random variables together. Marginals P(X) and P(Y) are obtained by summing (or integrating) the joint over the other variable. Conditionals P(X|Y=y) are the joint sliced at a fixed y value, renormalized by the marginal P(Y=y).

How to think about it

Understanding how to navigate the joint-marginal-conditional triangle is essential for generative models, Bayesian inference, and feature independence assumptions in classifiers.

The joint distribution

P(X=x, Y=y) assigns a probability to every combination of X and Y. For a joint table, every cell is non-negative and all cells sum to 1.

Worked example. Suppose X = “ad clicked” (0/1) and Y = “device” (mobile/desktop).

MobileDesktop
Click0.200.10
No click0.450.25

Marginals — summing out the other variable

P(X = click) = 0.20 + 0.10 = 0.30
P(Y = mobile) = 0.20 + 0.45 = 0.65

For continuous variables, replace sum with integral: f_X(x) = ∫ f(x,y) dy.

Marginals live in the margins of the joint table — the row and column totals.

Conditionals — slicing and renormalizing

P(X = click | Y = mobile) = P(X=click, Y=mobile) / P(Y=mobile)
                           = 0.20 / 0.65 ≈ 0.308

The conditional is the row (or column) of the joint, divided by its marginal total. This rescales to sum to 1 within that slice.

Moving between the three

Joint = Conditional × Marginal       P(X,Y) = P(X|Y)·P(Y)
Marginal = Sum of joint              P(X) = Σ_y P(X,Y=y)
Conditional = Joint / Marginal       P(X|Y) = P(X,Y) / P(Y)

These three relations — combined with Bayes — let you move in any direction.

Independence check

X and Y are independent if and only if P(X,Y) = P(X)·P(Y) for every cell. In the example: P(click)×P(mobile) = 0.30×0.65 = 0.195 ≠ 0.20, so they are dependent — mobile users click slightly more.

Learn it properly What is probability

Keep practising

All Statistics & Probability questions

Explore further

Skip to content