Counting parameters in graphical models: discrete and Gaussian variables
10 questions with small calculations on parameter counts for discrete and Gaussian graphs, chains, shared parameters, logistic conditionals and linear-Gaussian models.
- 10 questions
- Stopwatch
- Instant feedback
Sample questions
Play now ↑Answers stay hidden. Start the quiz to play them.
Sample 1
There are 10 binary variables. About how many free parameters does a fully general joint distribution have, and how many if the variables are independent?
- 20 and 10
- 1,023 and 10
- 100 and 20
How it works
- One question per screen. An answer is final once sent.
- You see right away whether you were right, with a short explanation.
- The stopwatch runs: on equal scores, the faster player ranks first.
- Only your best attempt counts, so replaying is never risky.
About this quiz
A weather forecaster wants a joint distribution over thirty yes-or-no questions: is it cloudy, is it windy, is the pressure falling and so on. A table that gives a probability to every combination of answers would have more than a billion entries, far more than anyone could estimate from data. Yet nobody believes that every question depends on every other in an arbitrarily complicated way. A graphical model uses that fact to slash the number of numbers the model needs. This quiz is about counting those numbers, and about what is given up each time a link is removed from the graph.
You will start with the cost of a general joint distribution over discrete variables, which grows exponentially with the number of variables, and compare it with the cost of treating them as independent, which grows only linearly. Between the two lie graphs with intermediate numbers of links, and you will compute the parameter count of the most useful one, a chain in which each variable depends only on its predecessor. You will see two further ways to economise: tying the conditional distributions along a chain to a single shared set of parameters, and replacing a table of conditional probabilities by a compact formula, a logistic function of a weighted sum of the parents.
The second half of the quiz repeats the exercise for Gaussian variables. If each variable has a Gaussian distribution whose mean is a linear function of its parents, the joint distribution is itself a Gaussian, and the structure of the graph decides how constrained its covariance matrix is. At one extreme there are no links and the covariance is diagonal, and at the other the graph is fully connected and the covariance is completely general. The questions use small numbers so that you can follow the arithmetic.
There are traps. People often forget that probabilities in a table must sum to one, which removes one free number from each distribution. They confuse the number of variables with the number of states. And they assume that removing links is harmless, when it is a modelling assumption that makes the model less flexible, in return for a model that can be learned from a realistic amount of data.
Counting parameters is also a good habit more generally, because the number of free parameters, set against the amount of data, tells you a lot about whether a model can be trusted. The quiz suits learners who know how graphs factorise distributions, and practitioners choosing between simple and flexible probabilistic models. There are 10 questions, each with an explanation, and it takes about four minutes.
Questions and answers
›How long does the quiz take?
About 3 to 4 minutes for 10 questions, at roughly 20 seconds each. An explanation follows each answer, with the counting written out step by step.
›Do I need to have studied graphical models?
It helps to know that a directed graph describes a factorisation of a joint distribution, which the quiz on directed graphical models explains. The questions here recall what is needed, and the arithmetic is only multiplication and addition.
›Why does a discrete joint distribution need so many parameters?
A general joint distribution over several discrete variables needs one probability for every combination of their values, less one because the probabilities must add up to one. With K states for each of M variables, the number of combinations is K to the power M, so the parameter count grows exponentially with the number of variables.
›How does independence change the count?
If the variables are independent, each has its own separate distribution with K minus one free parameters, so the total is M times K minus one, which grows only linearly with M. In graph terms, dropping all the links reduces the number of parameters dramatically, at the price of being able to describe only a very restricted class of distributions.
›What does a chain of discrete variables need?
The first variable needs K minus one parameters. Each of the remaining variables has a conditional distribution given its predecessor, needing K minus one parameters for each of the K values of the predecessor. The total grows linearly with the length of the chain, and quadratically with the number of states.
›What is parameter sharing in a chain?
It means requiring all the conditional distributions along the chain to use the same set of parameters. The model then no longer grows with the length of the chain, since one table of transition probabilities is used at every step. Together with the distribution of the first variable, the count depends only on the number of states.
›How can the cost of a conditional table be reduced?
By replacing a table, which needs one entry for every setting of the parents and so grows exponentially with their number, by a parameterised formula. A common choice is a logistic sigmoid applied to a weighted sum of the parent variables, whose number of parameters grows only linearly. It is a more restricted form, but a far cheaper one.
›What is a linear-Gaussian model?
It is a graphical model in which every node is a Gaussian variable whose mean is a linear function of the values of its parents, plus a constant, with its own variance. The joint distribution of all the variables is then Gaussian, and the graph determines how constrained its covariance matrix is. Probabilistic principal component analysis and factor analysis are examples.