Models built forward, for the measure theorist
Why an abstract probability space serves modelling as an abstract vector space serves linear algebra, why the way back to coordinates is harder in probability, and how building a model forward from densities restores it, so that every random variable factors through the quantities and every expectation is an explicit integral.
This note is for the reader who knows measure theory far better than statistics, and who wants to know what a probabilistic model is before being told how to compute with one. Its argument is an analogy with linear algebra, and its conclusion is that the models skoro builds sit in a corner of probability theory where the analogy is exact: one can reason abstractly and compute concretely, and move between the two without meeting the edge cases that usually make the move painful.
The abstraction, and the way back#
Linear algebra is done in an abstract vector space . A mathematician working there never says which coordinate of which holds which quantity of interest: vectors are added, subspaces are taken, linear maps are composed, and the dimension can be anything. When a computation is needed, a basis is chosen, becomes , and the abstract statements become statements about arrays of numbers. The way back is a single theorem: every finite-dimensional vector space is isomorphic to a coordinate space, and every choice of basis gives such an isomorphism.
Probability is done in an abstract probability space . A modeller working there never says what is, nor which sets are in , nor what assigns to them. Instead they introduce random variables , measurable maps into the spaces where the quantities of the model live, and speak only of those: their laws, their joint laws, the independence of one from another, the conditional law of one given another. Any number of them may be introduced, and new ones may be introduced later, provided the space is rich enough to carry them. The abstraction does for the modeller what does for the linear algebraist: it relieves them of a coordinate system they do not need.
The way back to coordinates is where the analogy usually breaks. Several things can go wrong at once:
The space is underdetermined. Many triples carry random variables with the same joint law, and may hold far more than the model ever mentions. Nothing in the model says which.
Conditioning needs regularity. The conditional law of given , for with values in and in , defined as a kernel from to characterized by
(1)a regular conditional distribution, exists only under assumptions on the spaces (standard Borel is the usual one), and even then only up to null sets of ’s law. Conditioning on an event of probability zero, which is what observing a continuous quantity does, depends on which version is chosen; the Borel–Kolmogorov paradox is the classic example of two natural versions disagreeing.
Densities need a reference. A density is a Radon–Nikodym derivative, and exists only when the law is absolutely continuous with respect to a chosen measure. The law of a function of quantities, such as or a projection, often has none.
Existence needs a theorem. Writing down a family of random variables does not make a space that carries them. Kolmogorov’s extension theorem builds one from consistent finite-dimensional laws, but asks for topological regularity of the spaces to do so.
So the modeller who wants to compute, to write a probability as an integral and evaluate it, has to justify every step back from , and usually does not.
A corner of probability where the way back is clean#
Applied models are almost never as general as the theory allows. They are built from two ingredients, and both remove an edge case.
Seeds with densities. Every quantity lives in a space with a reference measure: Lebesgue measure on (or an open subset of it, such as the positive orthant), or counting measure on a countable set, which may itself sit inside a vector space, such as the integers. Every distribution a quantity is drawn from is absolutely continuous with respect to its reference measure, so it is given by a function.
Let be a -finite measure on a measurable space , and a finite measure on it with , that is, implies . Then there is a measurable with
and any two such functions agree -almost everywhere. One writes and .
With respect to Lebesgue measure, is a probability density function: , its values are not probabilities, every single point has measure zero, and is determined only up to a Lebesgue-null set. With respect to counting measure, nothing is null but the empty set, and the density is pinned down completely by the mass it gives to points.
Let be countable, with every subset measurable, and let be counting measure. Every probability measure on is absolutely continuous with respect to , its density is unique, and it is
If then , so , and is -finite because is countable. Countable additivity gives with , and uniqueness almost everywhere is uniqueness everywhere, since the only null set is empty.
∎This is why is called a probability mass function in that case, and why the two cases can be treated as one: a density is always with respect to a reference measure, and a mass function is a density with respect to counting measure.
Quantities introduced one at a time. Each quantity is drawn from a distribution whose parameters may depend on any quantity introduced before it, through any measurable map, however nonlinear. A vehicle’s position is drawn given its previous position, pushed through a motion model; a range measurement is drawn given the vehicle and a landmark, through the distance between them.
A model built forward is a finite sequence of quantities , each with
- a space and a -finite reference measure on it: Lebesgue measure on or on an open subset of it, or counting measure on a countable set; and
- a conditional density: a measurable function such that is a probability density with respect to for every .
Its joint density is , with respect to the product measure on .
A conditional density written as , a family of densities with parameters computed from earlier quantities by a measurable map , is measurable as a composition of measurable maps, so any such nonlinear dependence is allowed. Nothing else is: there are no quantities without a density, and no dependence on a quantity introduced later.
What the restriction buys#
The first thing it buys is a canonical coordinate space, in the role of .
The measure is a probability measure on . For each , its marginal on the first quantities has density with respect to , and
is a regular conditional distribution of the -th quantity given the ones before it.
The function is non-negative and measurable on the product. By Tonelli’s theorem, integrating over first, then , and so on, each factor integrates to against whatever the earlier coordinates are, so , and stopping after the last integrals leaves the marginal density on the first . For measurable and , Tonelli again gives , with the marginal on the first , and is a probability measure for every and measurable in for every , again by Tonelli.
∎The probability space can then be taken to be , with its product -algebra, , and the quantities the coordinate projections. This is the analogue of choosing a basis: the quantities are the coordinates. Nothing is lost by the choice, because every statement the model makes is about the joint law of its quantities, and that law is on any space that carries them.
Nor is the restriction to finitely many quantities essential. The construction never used anything about the spaces beyond measurability, and it extends to infinitely many quantities built forward, with no topological assumption, by a theorem that is the right one for models built this way.
Let be any measurable spaces, a probability measure on , and for each let be a probability kernel from to . There is a unique probability measure on , with its product -algebra, whose marginal on every finite initial product is .
Kolmogorov’s theorem builds a law from consistent marginals, and needs the spaces to be nice for the marginals to determine one. Ionescu-Tulcea builds it from successive conditional laws, which is exactly what a model built forward provides, and needs nothing. Appending a quantity is extending a basis: the old coordinates keep their joint law, and a new one is added with its conditional law given them.
The second thing the restriction buys is a guarantee about what the model can say. A model speaks only of its quantities, so the random variables it can express are the -measurable ones, , and those are exactly the functions of the quantities.
Let be a measurable map from a measurable space to any measurable space , and . Then is -measurable if and only if for some measurable .
If , then . Conversely, every set in is for some , so an indicator is , and by linearity every -measurable simple function is for a simple . A -measurable is a pointwise limit of such functions ; the set where converges is measurable, and there and elsewhere is measurable with , because the sequence converges at every point of the image of .
∎Let a model built forward be carried by quantities on a probability space , so that has law . Every random variable the model can express, that is every -measurable one, is for a measurable , and when it is integrable,
The first claim is Lemma 7. For the second, the law of is , so by the change of variables for image measures, and because . The iterated form is Fubini’s theorem, which applies because is -integrable.
∎This is the probabilistic half of the analogy made precise. In linear algebra, a vector of is a combination of basis vectors and a linear functional is a combination of coordinates. Here, a random variable is a function of the quantities, an event of the model is a measurable set of their values, and its probability, an expectation, a marginal or a moment is an integral against the product of the conditional densities, in the order the model was built. The integral is explicit, though it is rarely available in closed form; estimating it is what inference algorithms are for.
Conditioning and likelihoods#
Observing quantities is conditioning on them, and in this corner it needs no existence theorem: the conditional law is written down from the densities.
Split the quantities of a model built forward into observed ones and free ones , and let
Then is a density of the law of , finite -almost everywhere, and the kernel
defined arbitrarily elsewhere, is a regular conditional distribution of given .
By Tonelli, is measurable and , so it is a density of the law of and is finite -almost everywhere. The set where it is has probability under that law, and so does the set where it is infinite. For measurable and ,
the two exceptional sets contributing nothing to either side, which is the defining property of a regular conditional distribution.
∎The version is chosen, not discovered: changing the densities on a null set, or the reference measures by a change of coordinates, changes on a null set of observations, which is all the freedom the Borel–Kolmogorov paradox exploits. In a model built forward the choice is made once, by the densities and reference measures the model was written with, and every observation is conditioned on by that same rule. That is also why two densities may only be compared, or divided, when they are with respect to the same reference measure.
The same computation explains a factor that scores no quantity. Multiplying the joint density by a non-negative function and normalizing is a change of measure, and it is always conditioning on data that the model does not carry as a quantity.
Let be measurable with . Then is a probability measure with density with respect to . If for a conditional density of a further quantity appended to the model, then is the conditional law of given , as conditioning by densities gives it.
is a probability measure because , and its density with respect to is . With appended, the joint density is , so Proposition 9, with free and observed at , gives the conditional density , where .
∎So a likelihood factor is exactly what its name says: the likelihood of an observation that is not a quantity of the model, already conditioned on.
What is left outside#
Two things a measure theorist might expect are deliberately absent. A function of quantities, a mapped value, has a law, the image of , but in general no density with respect to any reference measure, so a model built forward never scores one: densities are given for quantities, which were introduced with them, and for nothing else. And an improper seed, a “density” with infinite integral such as a flat density on a line, is not a probability measure at all, and the joint law above is then a -finite measure rather than a probability. Conditioning by division of densities still makes sense when the normalizing integral that results, the or above, is finite and positive, and then yields a probability measure. Whether it is depends on what is observed: it is a condition on the query, not on the model.
How skoro is built on this#
Skoro is designed by this philosophy. A skoro model is not a function to be evaluated, but a probability space built forward, quantity by quantity, and the library sets out to let its users work with that space in every way the measure theory above allows, of which evaluating is only one.
Quantities are specified by their augmenting kernels. Each quantity enters the model with the kernel that augments the space built so far,
(11)the kernel of Proposition 5, so that the model is and appending a quantity is appending a kernel, as in Theorem 6.
Likelihoods are built incrementally too. A likelihood factor may be added at any point, as a function of the quantities that exist when it is added, and the model’s likelihood is their product . The measure the model describes is then , normalized, by Proposition 10.
The model can be sampled, with weights. Drawing from the kernels in order samples . In a query that observes , drawing the free quantities from their kernels, with the observed ones held at their values, samples a measure whose density with respect to is the product of the free quantities’ conditional densities, and the target of the query, the conditional law of Proposition 9 reweighted by , differs from it by the weight
(12)the likelihood of the observations and of the likelihood factors at the drawn point. A kernel drawn from a sampler with a density of its own, , contributes to the weight as well. The weight distorts the sampling measure into the target only up to a constant, and among others, and that is all an algorithm needs: a self-normalized estimate , a Metropolis–Hastings ratio, a gradient of or a resampling step in a particle filter is unchanged when every weight is multiplied by the same number.
Functions of quantities belong in the model. A mapped value is never scored, since its law has no density in general, but it is put in the model all the same. It is generated whenever its arguments are, so its law is sampled even without a density; its expectations are integrals by Corollary 8; and, most of all, later kernels may be parameterized by it. A kernel is written by building its parameters out of mapped values, composed as freely as any measurable map allows, and derivatives flow through them to the quantities they are built from.
And so on: the gradient of or of in tangent charts for optimizers and Hamiltonian samplers, marginalizing quantities out when they retire, conditioning anew in every query, and holding several models at once when the structure itself is uncertain. Each is an operation on the probability space the kernels built, rather than on a single density function.
Built on by
- The problem The mathematics the core rests on, from quantities, their charts and their products, through operations and their derivatives of first and second order composed over programs, to queries, terms, importance weights, random keys and retirement.