skoro v0.0.0

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.

Updated 2026-10-13 · 11 min read

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 VV. A mathematician working there never says which coordinate of which Rd\R^\dimension holds which quantity of interest: vectors are added, subspaces W⊆VW \subseteq V are taken, linear maps are composed, and the dimension can be anything. When a computation is needed, a basis is chosen, VV becomes Rd\R^\dimension, 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 (Ω,F,P)(\Omega, \mathscr F, \mathrm P). A modeller working there never says what Ω\Omega is, nor which sets are in F\mathscr F, nor what P\mathrm P assigns to them. Instead they introduce random variables x:Ω→X\randomPoint : \Omega \to \manifold, 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 VV 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 (Ω,F,P)(\Omega, \mathscr F, \mathrm P) carry random variables with the same joint law, and F\mathscr F may hold far more than the model ever mentions. Nothing in the model says which.

  • Conditioning needs regularity. The conditional law of x\randomPoint given y\otherRandomPoint, for x\randomPoint with values in X\manifold and y\otherRandomPoint in Y\otherManifold, defined as a kernel κ\kernel from Y\otherManifold to X\manifold characterized by

    P(x∈A, y∈B)=∫Bκ(y,A) P(y∈dy)for all measurable A⊆X, B⊆Y,(1) \mathrm P(\randomPoint \in A,\ \otherRandomPoint \in B) = \int_B \kernel(\otherPoint, A)\, \mathrm P(\otherRandomPoint \in \dd\otherPoint) \qquad \text{for all measurable } A \subseteq \manifold,\ B \subseteq \otherManifold, \tag{1}
    (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 y\otherRandomPoint’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 (x,x)(\randomPoint, \randomPoint) 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 (Ω,F,P)(\Omega, \mathscr F, \mathrm P), 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 Rd\R^\dimension (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.

Theorem 2(Radon–Nikodym).

Let ν\nu be a σ\sigma-finite measure on a measurable space (X,X)(\manifold, \mathscr X), and μ\mu a finite measure on it with μ≪ν\mu \ll \nu, that is, ν(A)=0\nu(A) = 0 implies μ(A)=0\mu(A) = 0. Then there is a measurable p:X→[0,∞)\density : \manifold \to [0, \infty) with

μ(A)=∫Ap dνfor every A∈X, \mu(A) = \int_A \density \,\dd\nu \qquad \text{for every } A \in \mathscr X,

and any two such functions agree ν\nu-almost everywhere. One writes p=dμ/dν\density = \dd\mu / \dd\nu and μ(dx)=p(x) ν(dx)\mu(\dd\point) = \density(\point)\, \nu(\dd\point).

With respect to Lebesgue measure, p\density is a probability density function: μ(dx)=p(x) dx\mu(\dd\point) = \density(\point)\, \dd\point, its values are not probabilities, every single point has measure zero, and p\density 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.

Proposition 3(A mass function is its measure on points).

Let X={x0,x1,… }\manifold = \{\point_0, \point_1, \dots\} be countable, with every subset measurable, and let ν=∑kδxk\nu = \sum_k \delta_{\point_k} be counting measure. Every probability measure μ\mu on X\manifold is absolutely continuous with respect to ν\nu, its density is unique, and it is

p(xk)=μ({xk}),so thatμ(dx)=∑kp(xk) δxk(dx). \density(\point_k) = \mu(\{\point_k\}), \qquad \text{so that} \qquad \mu(\dd\point) = \sum_k \density(\point_k)\, \delta_{\point_k}(\dd\point) .
Proof.

If ν(A)=0\nu(A) = 0 then A=∅A = \emptyset, so μ≪ν\mu \ll \nu, and ν\nu is σ\sigma-finite because X\manifold is countable. Countable additivity gives μ(A)=∑xk∈Aμ({xk})=∫Ap dν\mu(A) = \sum_{\point_k \in A} \mu(\{\point_k\}) = \int_A \density \,\dd\nu with p(xk)=μ({xk})\density(\point_k) = \mu(\{\point_k\}), and uniqueness almost everywhere is uniqueness everywhere, since the only null set is empty.

∎

This is why p\density 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.

Definition 4(A model built forward).

A model built forward is a finite sequence of quantities i=1,…,ni = 1, \dots, n, each with

  1. a space (Xi,Xi)(\manifold_i, \mathscr X_i) and a σ\sigma-finite reference measure νi\nu_i on it: Lebesgue measure on Rdi\R^{\dimension_i} or on an open subset of it, or counting measure on a countable set; and
  2. a conditional density: a measurable function pi:Xi×X1×⋯×Xi−1→[0,∞)\density_i : \manifold_i \times \manifold_1 \times \cdots \times \manifold_{i-1} \to [0, \infty) such that pi(⋅∣x<i)\density_i(\cdot \mid \point_{<i}) is a probability density with respect to νi\nu_i for every x<i=(x1,…,xi−1)\point_{<i} = (\point_1, \dots, \point_{i-1}).

Its joint density is p(x)=∏i=1npi(xi∣x<i)\density(\point) = \prod_{i=1}^n \density_i(\point_i \mid \point_{<i}), with respect to the product measure ν=ν1⊗⋯⊗νn\nu = \nu_1 \otimes \cdots \otimes \nu_n on X=X1×⋯×Xn\manifold = \manifold_1 \times \cdots \times \manifold_n.

A conditional density written as pi(xi∣x<i)=qi(xi;θi(x<i))\density_i(\point_i \mid \point_{<i}) = q_i(\point_i; \theta_i(\point_{<i})), a family of densities qiq_i with parameters computed from earlier quantities by a measurable map θi\theta_i, 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 Rd\R^\dimension.

Proposition 5(The joint law of a model built forward).

The measure μ(dx)=p(x) ν(dx)\mu(\dd\point) = \density(\point)\, \nu(\dd\point) is a probability measure on X\manifold. For each ii, its marginal on the first ii quantities has density ∏j≤ipj(xj∣x<j)\prod_{j \le i} \density_j(\point_j \mid \point_{<j}) with respect to ν1⊗⋯⊗νi\nu_1 \otimes \cdots \otimes \nu_i, and

κi(x<i,A)=∫Api(xi∣x<i) νi(dxi) \kernel_i(\point_{<i}, A) = \int_A \density_i(\point_i \mid \point_{<i})\, \nu_i(\dd\point_i)

is a regular conditional distribution of the ii-th quantity given the ones before it.

Proof.

The function p\density is non-negative and measurable on the product. By Tonelli’s theorem, integrating over xn\point_n first, then xn−1\point_{n-1}, and so on, each factor pi(⋅∣x<i)\density_i(\cdot \mid \point_{<i}) integrates to 11 against νi\nu_i whatever the earlier coordinates are, so ∫p dν=1\int \density \,\dd\nu = 1, and stopping after the last n−in - i integrals leaves the marginal density on the first ii. For measurable B⊆X<iB \subseteq \manifold_{<i} and A⊆XiA \subseteq \manifold_i, Tonelli again gives μ(x<i∈B, xi∈A)=∫Bκi(x<i,A) μ<i(dx<i)\mu(\point_{<i} \in B,\ \point_i \in A) = \int_B \kernel_i(\point_{<i}, A)\, \mu_{<i}(\dd\point_{<i}), with μ<i\mu_{<i} the marginal on the first i−1i - 1, and κi(x<i,⋅)\kernel_i(\point_{<i}, \cdot) is a probability measure for every x<i\point_{<i} and measurable in x<i\point_{<i} for every AA, again by Tonelli.

∎

The probability space can then be taken to be Ω=X\Omega = \manifold, with its product σ\sigma-algebra, P=μ\mathrm P = \mu, 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 μ\mu 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.

Theorem 6(Ionescu-Tulcea).

Let (Xi,Xi)i≥1(\manifold_i, \mathscr X_i)_{i \ge 1} be any measurable spaces, μ1\mu_1 a probability measure on X1\manifold_1, and for each i≥2i \ge 2 let κi\kernel_i be a probability kernel from X1×⋯×Xi−1\manifold_1 \times \cdots \times \manifold_{i-1} to Xi\manifold_i. There is a unique probability measure μ\mu on ∏i≥1Xi\prod_{i \ge 1} \manifold_i, with its product σ\sigma-algebra, whose marginal on every finite initial product is μ1⊗κ2⊗⋯⊗κi\mu_1 \otimes \kernel_2 \otimes \cdots \otimes \kernel_i.

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 σ(x)\sigma(\randomPoint)-measurable ones, x=(x1,…,xn)\randomPoint = (\randomPoint_1, \dots, \randomPoint_n), and those are exactly the functions of the quantities.

Lemma 7(Doob–Dynkin).

Let x:Ω→X\randomPoint : \Omega \to \manifold be a measurable map from a measurable space (Ω,F)(\Omega, \mathscr F) to any measurable space (X,X)(\manifold, \mathscr X), and y:Ω→R\otherRandomPoint : \Omega \to \R. Then y\otherRandomPoint is σ(x)\sigma(\randomPoint)-measurable if and only if y=g∘x\otherRandomPoint = g \circ \randomPoint for some measurable g:X→Rg : \manifold \to \R.

Proof.

If y=g∘x\otherRandomPoint = g \circ \randomPoint, then y−1(B)=x−1(g−1(B))∈σ(x)\otherRandomPoint^{-1}(B) = \randomPoint^{-1}(g^{-1}(B)) \in \sigma(\randomPoint). Conversely, every set in σ(x)\sigma(\randomPoint) is x−1(A)\randomPoint^{-1}(A) for some A∈XA \in \mathscr X, so an indicator 1x−1(A)\mathbf 1_{\randomPoint^{-1}(A)} is 1A∘x\mathbf 1_A \circ \randomPoint, and by linearity every σ(x)\sigma(\randomPoint)-measurable simple function is g∘xg \circ \randomPoint for a simple gg. A σ(x)\sigma(\randomPoint)-measurable y\otherRandomPoint is a pointwise limit of such functions gk∘xg_k \circ \randomPoint; the set where (gk)(g_k) converges is measurable, and g=lim⁡kgkg = \lim_k g_k there and 00 elsewhere is measurable with y=g∘x\otherRandomPoint = g \circ \randomPoint, because the sequence converges at every point of the image of x\randomPoint.

∎
Corollary 8(Every expectation is an integral against the joint density).

Let a model built forward be carried by quantities x=(x1,…,xn)\randomPoint = (\randomPoint_1, \dots, \randomPoint_n) on a probability space (Ω,F,P)(\Omega, \mathscr F, \mathrm P), so that x\randomPoint has law μ\mu. Every random variable y\otherRandomPoint the model can express, that is every σ(x)\sigma(\randomPoint)-measurable one, is g∘xg \circ \randomPoint for a measurable gg, and when it is integrable,

E[y]=∫Xg(x) p(x) ν(dx)=∫X1 ⁣ ⁣⋯∫Xng(x)∏i=1npi(xi∣x<i) νn(dxn)⋯ν1(dx1). \E[\otherRandomPoint] = \int_{\manifold} g(\point)\, \density(\point)\, \nu(\dd\point) = \int_{\manifold_1} \!\!\cdots \int_{\manifold_n} g(\point) \prod_{i=1}^n \density_i(\point_i \mid \point_{<i})\, \nu_n(\dd\point_n) \cdots \nu_1(\dd\point_1) .
Proof.

The first claim is Lemma 7. For the second, the law of x\randomPoint is μ\mu, so E[g∘x]=∫g dμ\E[g \circ \randomPoint] = \int g \,\dd\mu by the change of variables for image measures, and ∫g dμ=∫gp dν\int g \,\dd\mu = \int g \density \,\dd\nu because p=dμ/dν\density = \dd\mu / \dd\nu. The iterated form is Fubini’s theorem, which applies because gpg \density is ν\nu-integrable.

∎

This is the probabilistic half of the analogy made precise. In linear algebra, a vector of VV 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.

Proposition 9(Conditioning is division of densities).

Split the quantities of a model built forward into observed ones OO and free ones FF, and let

pO(xO)=∫p(xF,xO) νF(dxF). \density_O(\point_O) = \int \density(\point_F, \point_O)\, \nu_F(\dd\point_F) .

Then pO\density_O is a density of the law of xO\randomPoint_O, finite νO\nu_O-almost everywhere, and the kernel

κ(xO,dxF)=p(xF,xO)pO(xO) νF(dxF)where 0<pO(xO)<∞, \kernel(\point_O, \dd\point_F) = \frac{\density(\point_F, \point_O)}{\density_O(\point_O)}\, \nu_F(\dd\point_F) \qquad \text{where } 0 < \density_O(\point_O) < \infty,

defined arbitrarily elsewhere, is a regular conditional distribution of xF\randomPoint_F given xO\randomPoint_O.

Proof.

By Tonelli, pO\density_O is measurable and ∫pO dνO=1\int \density_O \,\dd\nu_O = 1, so it is a density of the law of xO\randomPoint_O and is finite νO\nu_O-almost everywhere. The set where it is 00 has probability 00 under that law, and so does the set where it is infinite. For measurable AA and BB,

P(xF∈A, xO∈B)=∫B∫Ap(xF,xO) νF(dxF) νO(dxO)=∫Bκ(xO,A) pO(xO) νO(dxO), \mathrm P(\randomPoint_F \in A,\ \randomPoint_O \in B) = \int_B \int_A \density(\point_F, \point_O)\, \nu_F(\dd\point_F)\, \nu_O(\dd\point_O) = \int_B \kernel(\point_O, A)\, \density_O(\point_O)\, \nu_O(\dd\point_O),

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 κ\kernel 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.

Proposition 10(A likelihood factor is a change of measure).

Let L:X→[0,∞)L : \manifold \to [0, \infty) be measurable with 0<Z=∫L dμ<∞0 < Z = \int L \,\dd\mu < \infty. Then μL(dx)=L(x) μ(dx)/Z\mu_L(\dd\point) = L(\point)\, \mu(\dd\point) / Z is a probability measure with density Lp/ZL \density / Z with respect to ν\nu. If L(x)=h(y0∣x)L(\point) = h(\otherPoint_0 \mid \point) for a conditional density hh of a further quantity y\otherRandomPoint appended to the model, then μL\mu_L is the conditional law of x\randomPoint given y=y0\otherRandomPoint = \otherPoint_0, as conditioning by densities gives it.

Proof.

μL\mu_L is a probability measure because ∫L dμ=Z\int L \,\dd\mu = Z, and its density with respect to ν\nu is Lp/ZL \density / Z. With y\otherRandomPoint appended, the joint density is p(x) h(y∣x)\density(\point)\, h(\otherPoint \mid \point), so Proposition 9, with x\randomPoint free and y\otherRandomPoint observed at y0\otherPoint_0, gives the conditional density p(x) h(y0∣x)/py(y0)\density(\point)\, h(\otherPoint_0 \mid \point) / \density_{\otherRandomPoint}(\otherPoint_0), where py(y0)=∫h(y0∣x) μ(dx)=Z\density_{\otherRandomPoint}(\otherPoint_0) = \int h(\otherPoint_0 \mid \point)\, \mu(\dd\point) = Z.

∎

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 μ\mu, 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 σ\sigma-finite measure rather than a probability. Conditioning by division of densities still makes sense when the normalizing integral that results, the ZZ or pO\density_O 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 p\density 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 p\density is only one.

  • Quantities are specified by their augmenting kernels. Each quantity xi\randomPoint_i enters the model with the kernel that augments the space built so far,

    κi(x<i,dxi)=pi(xi∣x<i) νi(dxi),(11) \kernel_i(\point_{<i}, \dd\point_i) = \density_i(\point_i \mid \point_{<i})\, \nu_i(\dd\point_i), \tag{11}
    (11)

    the kernel of Proposition 5, so that the model is μ=κ1⊗κ2⊗⋯⊗κn\mu = \kernel_1 \otimes \kernel_2 \otimes \cdots \otimes \kernel_n and appending a quantity is appending a kernel, as in Theorem 6.

  • Likelihoods are built incrementally too. A likelihood factor LjL_j 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 L=∏jLjL = \prod_j L_j. The measure the model describes is then L μL\, \mu, normalized, by Proposition 10.

  • The model can be sampled, with weights. Drawing from the kernels in order samples μ\mu. In a query that observes xO\randomPoint_O, drawing the free quantities from their kernels, with the observed ones held at their values, samples a measure whose density with respect to νF\nu_F is the product of the free quantities’ conditional densities, and the target of the query, the conditional law of Proposition 9 reweighted by LL, differs from it by the weight

    w(xF)=L(x)∏i∈Opi(xi∣x<i),(12) \weight(\point_F) = L(\point) \prod_{i \in O} \density_i(\point_i \mid \point_{<i}), \tag{12}
    (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, qi≠pi\proposal_i \ne \density_i, contributes pi/qi\density_i / \proposal_i to the weight as well. The weight distorts the sampling measure into the target only up to a constant, pO(xO)\density_O(\point_O) and ZZ among others, and that is all an algorithm needs: a self-normalized estimate E[w h]/E[w]\E[\weight\, h] / \E[\weight], a Metropolis–Hastings ratio, a gradient of log⁡w\log \weight 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 f(x)f(\randomPoint) is never scored, since its law f#μf_\# \mu 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 κj(x<j,⋅)=qj(⋅ ;θj(x<j))\kernel_j(\point_{<j}, \cdot) = q_j(\cdot\,; \theta_j(\point_{<j})) is written by building its parameters θj\theta_j 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 log⁡p\log \density or of log⁡w\log \weight 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