skoro v0.0.0

Mathematics

How a query of a model is linearized at a point into factors of whitened rows and linear terms over its free quantities' tangent coordinates, and how eliminating those factors gives the step of a Gauss–Newton or Levenberg–Marquardt method, a Laplace approximation's marginals, and a retirement's replacement, an improper Gaussian that is the update and prediction of a Kalman filter when it determines the blanket; and how the roots of the expected information give a second assembly, for Fisher scoring of free scales.

Updated 2026-11-14 · 44 min read

The problem#

skoro can build a model, query it and differentiate the query to second order, and its normal distribution binds, on every term, the whitened residual that a least-squares reader needs (the normal’s roles). What it cannot yet do is turn those residuals into a step, a covariance or a summary. Every method that does is built on the same two pieces.

  • Linearization replaces a query’s negative log-density, near a point, by a sum of squared affine residuals and a linear term in the tangent coordinates of its free quantities: the rows that the residuals’ Jacobians give, one block of rows for each term. A second assembly, for a model whose scales are free, takes its rows from the roots of the terms’ expected information instead, as Fisher scoring does.
  • Elimination solves the linear problem those rows pose, or removes some of its variables from it, one at a time, by orthogonal factorizations of the rows rather than by the normal equations.

A Gauss–Newton step is the minimizer of the linearization; a Levenberg–Marquardt step is the same with damping rows appended. A Laplace approximation reads its covariance and its marginals off the linearization at a mode, and its evidence off the determinant of the eliminated rows. A retirement (the core’s retirement) needs a replacement for the terms it removes, an integral the core leaves to the caller, and eliminating the retired quantities from the linearization of those terms gives it as an improper Gaussian in the blanket’s tangent coordinates. When the retired terms determine the whole blanket, its value is that of the form the normal already writes, its Stacked replacement. When they do not, as for a landmark seen by bearing from one pose, it keeps what they say about a quantity that cannot yet be estimated, so that a model can accumulate information before it estimates. On a chain of states that replacement is the update and the prediction of a Kalman filter, exact for linear-Gaussian terms and, for others, an extended Kalman filter’s.

This document works out the mathematics of linearizing a query and of eliminating its linearization, at the level the implementation needs: what the rows and the linear terms are, what is approximated and what it costs, which quantities are variables, what each method asks of the elimination, and what the replacement of a retirement is, constants included. The linear algebra of elimination stands on its own, and is in the note elimination in square-root form; this document says how skoro’s objects meet it. The methods themselves, an optimizer’s loop, a damping schedule, a filter, are left to the entries that bring them.

Setting#

A query at a point. A query partitions the quantities its targets reach into observed and free. Its free continuous quantities, in an order the reader chooses, are one point xF=(x1,…,xn)\point_F = (\point_1, \dots, \point_n) of the product of their types, whose tangent space is the stacked Rd\R^\dimension of (1), d=∑idi\dimension = \sum_i \dimension_i, and whose step is the product’s retraction (17). Write x^\hat \point for the point at which the query is linearized, v∈Rd\tangent \in \R^\dimension for a tangent vector there, f=−log⁡pf = -\log \density for the query’s negative log-density (16), and gg for its chart gradient at x^\hat \point (1). Every derivative below is in the charts of the free quantities, so that on a curved quantity it is the derivative of a function of x^⊕v\hat \point \oplus \tangent at v=0\tangent = 0. Computation is batched, and every row of a batch has a point and a linearization of its own.

Residuals and remainders. A term tt binds a whitened residual when a node rtr_t is bound under the residual role. What a reader of that role may assume of the rest of the log-density is the role’s contract, which the normal keeps: the log-density is the squares, a normalizer and, where the term binds one under the log-volume role, a log-volume,

ℓt=−12∣rt∣2+nt−λt,(1) \logterm_t = -\tfrac12 \lvert r_t \rvert^2 + n_t - \lambda_t , \tag{1}
(1)

and ρt=nt−λt\rho_t = n_t - \lambda_t is its remainder. For the normal’s term (3), nt=∑ilog⁡Wii−d2log⁡2πn_t = \sum_i \log W_{ii} - \tfrac{\dimension}{2} \log 2\pi, which is constant when the scale is fixed, and λt=λμ(x⊖μ)\lambda_t = \lambda_\mu(\point \ominus \mu), which the normal binds only where it is not identically zero, on positive and curved types. For a retirement’s Gaussian replacement (10), ntn_t is the normalizer and the constant cc, and there is no log-volume. For an improper replacement (13), nt=cn_t = c, and λt=η⊤δ\lambda_t = \eta\transpose \delta where a linear term remains: the varying part of the remainder, which is all (1) asks of λt\lambda_t. A term that binds a residual and no log-volume promises a remainder constant whenever its scale is fixed.

The variables and the factors. The core reads off the compilation graph the quantities VtV_t that each term involves (terms). For a query, the term’s variables are its free continuous quantities,

Kt=Vt∩F,(2) K_t = V_t \cap F , \tag{2}
(2)

and a term with KtK_t empty is reached from no free quantity: its log-density is a constant of the query, part of f(x^)f(\hat \point) and of nothing else below. The terms with KtK_t not empty are the query’s factors. Which factor involves which free quantity is the factor structure of the note: a bipartite graph with a node for each free continuous quantity and each factor, and an edge between a factor tt and each quantity of KtK_t. It is the probabilistic graph with the observed quantities and the constant terms removed and the directions of its edges forgotten, and it depends on the query, not only on the model: what is observed is not a variable.

The running example is the core’s: a vehicle at x0\randomPoint_0 and then x1\randomPoint_1, which measures a landmark m\bfm from each, as z0\bfz_0 and z1\bfz_1, moved by an IMU’s model driven by its reading ζ1\bfzeta_1, with the platform’s own motion model LL of scale σ\bfsigma as a likelihood factor. Here every term is taken to be a normal, LL among them as a normal’s likelihood factor over the step x1−x0\point_1 - \point_0, so that every term binds a residual; the core wrote LL’s log-density by hand, from primitives, and a term written so would be refused. A query for the positions and the landmark observes the measurements, the reading and the scale, and its factor structure is:

The factor structure of the example
t1t_1 x0\randomPoint_0 t3t_3 t6t_6 t4t_4 x1\randomPoint_1 m\bfm t5t_5 t2t_2
  • Free quantity
  • Factor
  • has a block for
The factor structure of the example. A query of the core's example free in x0\randomPoint_0, x1\randomPoint_1 and m\bfm, with z0\bfz_0, z1\bfz_1, ζ1\bfzeta_1 and σ\bfsigma observed. Each term reached from a free quantity is a factor, joined to the free quantities among those it involves; the observed quantities are not variables, and the score t7t_7 of σ\bfsigma, reached from no free quantity, is a constant of the query and no factor.

Linearizing a query#

Definition 3(The linearization of a query).

Let a query have no free discrete quantity, let its free continuous quantities, in an order, have the stacked tangent Rd\R^\dimension, and let every term tt whose log-density is reached from a free quantity bind a whitened residual rtr_t, of any number of components, none included, with

ℓt=−12∣rt∣2+nt−λt, \logterm_t = -\tfrac12 \lvert r_t \rvert^2 + n_t - \lambda_t ,

ntn_t constant in the query and λt\lambda_t the node the term binds under the log-volume role, or zero where it binds none. Call the log-volume folded when the residual is rt=Wt str_t = W_t\, s_t for a constant invertible WtW_t and λt\lambda_t is a function of sts_t alone, and set c^t=Wt−⊤∇λt(st)\hat c_t = W_t^{-\top} \nabla \lambda_t(s_t), the gradient of the log-volume with respect to the residual; otherwise set c^t=0\hat c_t = 0. With f=−log⁡pf = -\log \density the query’s negative log-density, its linearization at a point x^\hat \point is the function of v∈Rd\tangent \in \R^\dimension

m(v)=c0+∑t12∣Jtv+rt+c^t∣2+η⊤v, m(\tangent) = c_0 + \sum_t \tfrac12 \bigl\lvert J_t \tangent + r_t + \hat c_t \bigr\rvert^2 + \eta\transpose \tangent ,

where

η=∑t not folded∇λt(x^)andc0=f(x^)−12∑t∣rt+c^t∣2, \eta = \sum_{t \text{ not folded}} \nabla \lambda_t(\hat \point) \qquad \text{and} \qquad c_0 = f(\hat \point) - \tfrac12 \sum_t \lvert r_t + \hat c_t \rvert^2 ,

where rtr_t is the residual at x^\hat \point and Jt=Drt(x^)J_t = \D r_t(\hat \point) and ∇λt\nabla \lambda_t are the Jacobian and the gradient in the charts of the free quantities. Its chart linearization is the linearization of f(x^⊕v)−λx^(v)f(\hat \point \oplus \tangent) - \lambda_{\hat \point}(\tangent), with λx^\lambda_{\hat \point} the log-volume of the chart at x^\hat \point of the free quantities: the same rows, with η−∇λx^(0)\eta - \nabla \lambda_{\hat \point}(0) and c0−λx^(0)c_0 - \lambda_{\hat \point}(0) in place of η\eta and c0c_0.

The linearization agrees with ff to first order, and its curvature is the Gauss–Newton matrix:

m(0)=f(x^),∇m(0)=g,∇2m=∑tJt⊤Jt.(4) m(0) = f(\hat \point), \qquad \nabla m(0) = g, \qquad \nabla^2 m = \sum_t J_t\transpose J_t . \tag{4}
(4)

The first holds by the choice of c0c_0. The second holds because g=−∑t∇ℓt=∑tJt⊤rt+∑t∇λtg = -\sum_t \nabla \logterm_t = \sum_t J_t\transpose r_t + \sum_t \nabla \lambda_t by (1), the normalizers being constant, while the gradient of mm at v=0\tangent = 0 is ∑tJt⊤(rt+c^t)+η\sum_t J_t\transpose (r_t + \hat c_t) + \eta. For a folded term, Drt=WtDst\D r_t = W_t \D s_t, so ∇λt=Dst⊤∇λt(st)=Jt⊤Wt−⊤∇λt(st)=Jt⊤c^t\nabla \lambda_t = \D s_t\transpose \nabla \lambda_t(s_t) = J_t\transpose W_t^{-\top} \nabla \lambda_t(s_t) = J_t\transpose \hat c_t.

Folding a log-volume into its rows. A folded log-volume’s gradient lies in the row space of its own term’s rows, so it is carried by the right-hand side, −(rt+c^t)-(r_t + \hat c_t), rather than by a linear term. The normal’s log-volume is folded on the Euclidean types, where it is zero, and on the curved ones, where it is a function of st=x⊖μs_t = \point \ominus \mu alone: λe(st)\lambda_e(s_t) on a group whose chart translates the identity’s, and a function of ∣st∣\lvert s_t \rvert on the sphere with orthonormal bases. On a positive type it is ∑ilog⁡xi\sum_i \log \point_i, which depends on the quantity and not only on sts_t, and it stays in η\eta. Folding is decided by the term’s type, not by any number, so every row of a batch folds the same terms. It costs nothing, since c^t\hat c_t is a gradient of the size of sts_t’s own components, and it gains two things. A folded linear term is solved with the residuals, at κ(J)\kappa(J), rather than at κ(J)2\kappa(J)^2 as the note says a linear term is. And elimination keeps it in the rows: by the note, a linear term in the row space stays in the row space of every new factor, so a model of Euclidean and curved quantities has η=0\eta = 0 exactly, before and after any elimination.

Why η\eta is read off the log-volumes. In exact arithmetic η=g−∑tJt⊤(rt+c^t)\eta = g - \sum_t J_t\transpose (r_t + \hat c_t), and both terms of that difference are passes the linearization runs anyway. It is not computed so. On a model of normals with fixed scales on the Euclidean and curved types, η\eta is exactly zero, while gg and ∑tJt⊤rt\sum_t J_t\transpose r_t are each of the size of ∣J∣∣r∣\lvert J \rvert \lvert r \rvert and each rounded at the query’s precision: their difference is rounding of that size, not zero. The note shows that a linear term is solved at κ(J)2\kappa(J)^2, so the noise is amplified by the square of the condition number, which is the very loss that solving by the rows rather than the normal equations exists to avoid. Where the Jacobians are computed in single precision on a device and the step solved in double on the host, as the charter allows, a unit roundoff of 6×10−86 \times 10^{-8} times κ(J)2\kappa(J)^2 swamps the step for a moderate κ(J)\kappa(J). Read off the bound log-volumes that are not folded, η\eta is exactly zero wherever there are none, and otherwise only as large, and as rounded, as their own gradients. The constant c0c_0 is a difference of the same kind, but it enters only additively, in an evidence or a replacement’s constant ((14)), with an absolute error of the query’s unit roundoff times ∑t∣rt∣2\sum_t \lvert r_t \rvert^2, and no solve amplifies it.

The linearization is the note’s problem (9) with one factor for each term, with the rows At=JtA_t = J_t, of the dimension of rtr_t, over the blocks of KtK_t, and the right-hand side bt=−(rt+c^t)b_t = -(r_t + \hat c_t), and the linear term η\eta, split by block. Each piece of the linear term involves a single block, so the factor structure is that of the terms alone.

What is left out. The Hessian of v↦f(x^⊕v)\tangent \mapsto f(\hat \point \oplus \tangent) at v=0\tangent = 0, which at a stationary point is the chart Hessian of Proposition 3, is

∇2f=∑tJt⊤Jt+∑t∑i(rt)i ∇2(rt)i+∑t∇2λt.(5) \nabla^2 f = \sum_t J_t\transpose J_t + \sum_t \sum_i (r_t)_i\, \nabla^2 (r_t)_i + \sum_t \nabla^2 \lambda_t . \tag{5}
(5)

The linearization keeps the first sum. The second is what every Gauss–Newton method omits: it is small where the residuals are, and it is what makes the Hessian indefinite far from a mode. On a curved type it is of the same order as the third, even at a mode (What the covariance leaves out). The third is the curvature of the log-volumes: zero on the Euclidean types, zero on the positive ones, whose log-volume is linear in their chart, and on a curved type of the relative order of the noise’s variance, by the bound of the normal’s Gauss–Newton reading. The folded right-hand sides and the linear term keep the log-volumes’ gradients exactly. So a step that minimizes the linearization is the iteration of Proposition 13, with s=∑tλts = \sum_t \lambda_t there: it stops only where g=0g = 0, at a stationary point of ff itself, log-volumes included, and it converges there at the linear rate the omitted curvature sets. When every direction is determined by the rows, the minimizer is

v∗=−(∑tJt⊤Jt)−1g,(6) \tangent^* = -\Bigl(\sum_t J_t\transpose J_t\Bigr)^{-1} g , \tag{6}
(6)

and it is computed as the note computes (7): the part from the right-hand sides, folded log-volumes included, at κ(J)\kappa(J), and the part from η\eta at κ(J)2\kappa(J)^2, as the normal equations would. On a model of normals with fixed scales on the Euclidean and curved types, η=0\eta = 0 and the whole step is a least-squares solution.

What is refused. The linearization is defined when every factor binds a residual, and when the omitted curvature is of the kind the iteration tolerates. Following the charter’s rule that an algorithm refuses by structure rather than skip what it cannot read (position 6), it refuses, naming the quantity or the term:

  1. a free discrete quantity, since no derivative is taken with respect to it and the gradient at given values is not the target’s (discrete quantities in a query);
  2. a factor that binds no residual, since its curvature would be missing from the rows altogether, not approximated, and nothing would say what its gradient is beyond its squares. A residual of no components is a residual: an improper replacement ((13)) may bind one, and its remainder is then affine in the logarithmic chart of the positive quantities where such a factor arises, so no curvature is missing;
  3. a factor whose scale is reached from a free quantity, read off the scale it binds under the normal’s roles, since its normalizer then moves, which (1) excludes. Carrying the normalizer’s gradient in η\eta would not save it. Its residual depends on the scale, and the residual’s own curvature in the scale’s coordinates, which the rows omit, is as large as what they keep. For an isotropic scale in its logarithmic chart u=log⁡σu = \log \sigma, r=e−uεr = e^{-u} \varepsilon, so the rows’ curvature in uu is ∣r∣2\lvert r \rvert^2 and the squares’ is 2∣r∣22 \lvert r \rvert^2, while the normalizer −du-\dimension u is linear. At the stationary point ∣r∣2=d\lvert r \rvert^2 = \dimension, the omitted part equals the kept part, and the rate of Proposition 13 is one: the iteration need not converge. Such a scale is estimated by the expected information instead (Information roots).

The passes. The linearization needs first-order derivatives only, of the order every continuous quantity’s operations have. The Jacobians JtJ_t are a tangent pass with the identity frame of the free quantities, or a cotangent pass with the identity frame of the residuals, whichever is narrower; only the columns of KtK_t are nonzero in JtJ_t. The linear term η\eta is one cotangent pass of the sum of the bound log-volumes, and none where no term binds one, and c0c_0 needs the query’s log-density and its residuals at x^\hat \point. All run at the query’s precision, and the elimination after them runs on the host in double precision, as the charter has every solve that conditioning governs (position 11).

Proposition 7(Linear-Gaussian terms).

Let the free quantities of a query be of flat-in-disguise types, and let every term reached from one of them bind a residual that is an affine function of their chart coordinates and a log-volume, if any, that is affine in them. Then at every point x^\hat \point the linearization is exact, m(v)=f(x^⊕v)m(\tangent) = f(\hat \point \oplus \tangent) for every v∈Rd\tangent \in \R^\dimension, and so is the chart linearization.

Proof.

On a flat-in-disguise type the chart at x^\hat \point and the chart at any other point differ by a translation, by (1), so a function affine in one chart’s coordinates is affine in every chart’s, and the hypothesis does not depend on x^\hat \point. An affine residual has rt(x^⊕v)=rt+Jtvr_t(\hat \point \oplus \tangent) = r_t + J_t \tangent exactly, and an affine log-volume is equal to its first-order expansion, so f(x^⊕v)=∑t12∣rt+Jtv∣2+∑tλt(x^⊕v)f(\hat \point \oplus \tangent) = \sum_t \tfrac12 \lvert r_t + J_t \tangent \rvert^2 + \sum_t \lambda_t(\hat \point \oplus \tangent), plus the constant normalizers and terms, is m(v)m(\tangent). The log-volume of a flat-in-disguise type is zero or, on a positive factor, ∑i(log⁡x^i+vi)\sum_i (\log \hat \point_i + \tangent_i) (2), affine in v\tangent, so the chart linearization is exact too.

∎

The normal on the Euclidean types with a fixed scale and a mean affine in the free quantities is such a term, and so is the normal on a positive type, the log-normal, with a mean whose logarithm is affine in their logarithms. A model of such terms is linear-Gaussian.

Damping#

A Levenberg–Marquardt step minimizes the linearization plus the damping 12λ v⊤Dv\tfrac12 \lambda\, \tangent\transpose D \tangent, which the note writes as one factor of rows for each free quantity (15): appending them changes neither the factor structure nor the plan of the elimination, and it makes every direction determined for λ>0\lambda > 0. The damped minimizer v\tangent solves (J⊤J+λD) v=−g(J\transpose J + \lambda D)\, \tangent = -g, and the decrease of the undamped linearization that it promises is

m(0)−m(v)=12∣Jv∣2+λ v⊤Dv,(8) m(0) - m(\tangent) = \tfrac12 \lvert J \tangent \rvert^2 + \lambda\, \tangent\transpose D \tangent , \tag{8}
(8)

since m(0)−m(v)=−g⊤v−12v⊤J⊤Jvm(0) - m(\tangent) = -g\transpose \tangent - \tfrac12 \tangent\transpose J\transpose J \tangent and −g⊤v=v⊤(J⊤J+λD)v-g\transpose \tangent = \tangent\transpose (J\transpose J + \lambda D) \tangent. The ratio of the decrease actually obtained, f(x^)−f(x^⊕v)f(\hat \point) - f(\hat \point \oplus \tangent), to (8) is what a Levenberg–Marquardt method compares with one to adapt λ\lambda; its schedule, its choice of DD and its stopping rule are that method’s entry’s.

Eliminating the linearization#

The linearization is eliminated as the note eliminates (9), one free quantity at a time, each a block of its dimension. In the example, with the order x0,x1,m\randomPoint_0, \randomPoint_1, \bfm, eliminating x0\randomPoint_0 collects the four factors joined to it, t1t_1, t3t_3, t4t_4 and t6t_6, and leaves a conditional of x0\randomPoint_0 on its separator {x1,m}\{\randomPoint_1, \bfm\} and one new factor there, with the linear terms of x0\randomPoint_0 pushed onto it; eliminating x1\randomPoint_1 then collects t5t_5 and the new factor, with the separator {m}\{\bfm\}.

The elimination tree of the example
m\bfm rootx1\randomPoint_1 x0\randomPoint_0
  • Free quantity
  • parent of
The elimination tree of the example. The order x0,x1,m\randomPoint_0, \randomPoint_1, \bfm. Eliminating x0\randomPoint_0 collects t1t_1, t3t_3, t4t_4 and t6t_6 and leaves a new factor on its separator {x1,m}\{\randomPoint_1, \bfm\}; its parent is x1\randomPoint_1, the first of them eliminated after it. Eliminating x1\randomPoint_1 collects t5t_5 and that factor, with the separator {m}\{\bfm\}. An arrow runs from a parent to its child, so the root m\bfm, eliminated last, has no incoming arrow.

Three things follow from skoro’s side of the problem.

  • Batch rows share the plan. The factor structure is read off the probabilistic graph and the query, not off any number, so every row of a batch has the same one. One order and one elimination tree serve all rows, and only the numeric elimination is done row by row. A retirement changes the model, and so the structure; a step of an optimizer does not.
  • Each block is the tangent of one quantity. A conditional solves for the tangent coordinates of its quantity at x^\hat \point, and the step returns to the model by the retraction (17), quantity by quantity. A quantity whose rows do not determine it, a zero or a small diagonal entry in its conditional, is refused, naming the quantity: an unobserved direction, such as the position of a landmark seen from one place along one bearing, or a gauge freedom of the whole model, is the model’s to fix by a prior or by damping, not the elimination’s to guess.
  • The order is free, except where a reduction constrains it. A step eliminates everything, in any order that keeps the fill small. A marginal on quantities KK eliminates them last, and a retirement eliminates the retired quantities from their own terms alone.

The Laplace approximation#

A Laplace approximation replaces an integral against the model’s density by the integral of a Gaussian. The integral is against the reference measures of the free quantities’ types, so it is refused for a quantity whose type declares no volume, naming the quantity. Otherwise it is taken in the chart at x^\hat \point, where the reference measure has the density of its log-volume, (11):

∫e−f dν=∫Ux^e−f(x^⊕v)+λx^(v) dv.(9) \int e^{-f} \, \dd \nu = \int_{U_{\hat \point}} e^{-f(\hat \point \oplus \tangent) + \lambda_{\hat \point}(\tangent)} \, \dd \tangent . \tag{9}
(9)

What is approximated by a Gaussian in v\tangent is therefore the chart objective f(x^⊕v)−λx^(v)f(\hat \point \oplus \tangent) - \lambda_{\hat \point}(\tangent), whose linearization is the chart linearization of Definition 3, and not ff alone. The difference is in two places.

  • Its centre. The Gaussian is centred at v=0\tangent = 0 when x^\hat \point is a stationary point of the chart objective, where g=∇λx^(0)g = \nabla \lambda_{\hat \point}(0), rather than of ff. On the Euclidean types λ=0\lambda = 0. On a group whose chart translates the identity’s, as the Cayley chart of the rotations does, λx^=λe\lambda_{\hat \point} = \lambda_e, and the Cayley chart’s λe\lambda_e is even in v\tangent, as the stereographic chart’s of the sphere is, so its gradient at 00 is zero: on these types the centre is a mode of ff. On a positive type ∇λx^(0)=1\nabla \lambda_{\hat \point}(0) = 1 in each coordinate, and the centre is the mode in the logarithmic chart. For a quantity scored by a log-normal of median μ\mu, it is μ\mu itself, where log⁡x\log \randomPoint is centred, while the mode with respect to Lebesgue measure is μ e−σ2\mu\, e^{-\sigma^2}, below it. A Gaussian in the tangent coordinates is a Gaussian in the logarithms, and is centred where they are.
  • Its constant. λx^(0)\lambda_{\hat \point}(0) is ∑ilog⁡x^i\sum_i \log \hat \point_i on a positive type and zero on the others the library has: the volume of the reference measure near x^\hat \point.

With the chart linearization mm of rows of full rank, e−me^{-m} is a constant times a normal density on Rd\R^\dimension, and every quantity a Laplace approximation asks for is a computation of the note on its rows:

asked forcomputed by
the mean, in the tangent at x^\hat \pointthe minimizer v∗\tangent^*, zero at the centre
the covariance, and its marginal on quantities KKpartial elimination of the others, Corollary 13, and the triangular root WW of what is left on KK: W−1W−⊤W^{-1} W^{-\top}
a drawx^⊕(v∗+R−1z)\hat \point \oplus (\tangent^* + R^{-1} z), with zz standard normal
the evidencelog⁡∫e−fdν≈d2log⁡2π−m(v∗)−∑ilog⁡∣Rii∣\log \int e^{-f} \dd \nu \approx \tfrac{\dimension}{2} \log 2\pi - m(\tangent^*) - \sum_i \log \lvert R_{ii} \rvert, by (12)

The draw lies in the chart’s domain on every type the normal accepts, whose chart is global; on a type whose chart is not, the Gaussian’s mass outside its domain is the error of the note on chart volumes and is not part of this approximation’s accounting.

What the covariance leaves out#

The Gaussian’s precision is the rows’, J⊤JJ\transpose J. The Hessian of the chart objective at the centre is that and

D=∑t∑i(rt)i ∇2(rt)i+∑t∇2λt−∇2λx^(0),(10) D = \sum_t \sum_i (r_t)_i\, \nabla^2 (r_t)_i + \sum_t \nabla^2 \lambda_t - \nabla^2 \lambda_{\hat \point}(0) , \tag{10}
(10)

the curvature of the residuals, of the terms’ log-volumes and of the chart’s log-volume: the omitted part of (5), with the chart’s term added. For linear-Gaussian terms D=0D = 0, by Proposition 7. Otherwise, on the Euclidean and positive types, only the first sum remains, the curvature that every Gauss–Newton method leaves out. On a curved type all three parts are of the same order. Each is of order one, while J⊤JJ\transpose J is of the order of the precisions Λt\Lambda_t, so each changes the covariance by a relative amount of the order of the noise’s variance, σ2\sigma^2.

  • The chart’s part is positive. On every curved type the library has, the chart’s log-volume is −2log⁡(1+∣v∣2/4)-2 \log(1 + \lvert \tangent \rvert^2 / 4), whose Hessian at zero is −I-I. So the chart adds +I+I on each curved quantity that is integrated over.
  • The terms’ part is negative. Let GtG_t be the derivative of the term’s tangent coordinate x⊖μ\point \ominus \mu with respect to v\tangent. A term’s log-volume adds about −Gt⊤Gt-G_t\transpose G_t, against the Gt⊤ΛtGtG_t\transpose \Lambda_t G_t that its rows keep. This is the replacement of Λ\Lambda by Λ−I\Lambda - I that the normal’s properties describe for a measurement.
  • The residuals’ part is not small, even at the mode. Along the retraction, the second derivative of x⊖μ\point \ominus \mu is of first order in the residual. The first sum of (10) is therefore quadratic in the residuals, of order one like the others, and it vanishes only where the residuals do. For a rotation measured in the Cayley chart, it averages about +12I+\tfrac12 I over the noise, against the log-volume’s −I-I. This was computed numerically, from 4000 draws at σ=0.1\sigma = 0.1.

The sign is not fixed. One covariance is smaller than another exactly when its precision is larger, and then every marginal of it is smaller too. So the rows’ covariance is smaller than the second-order Laplace covariance (J⊤J+D)−1(J\transpose J + D)^{-1} in every direction when DD is negative semidefinite, and larger in every direction when DD is positive semidefinite. Neither holds in general: the chart’s part is positive, the terms’ log-volumes negative, and the residuals’ part can be of either sign.

What a covariance is meant to describe, though, is the posterior, and the second-order Laplace approximation is itself in error on a curved type, at the same relative order σ2\sigma^2. Two examples on the rotations, in the Cayley chart with an isotropic σ\sigma, show how the three covariances compare with the posterior’s. Both were computed numerically: the posterior’s covariance in the chart at the mode by importance sampling, or exactly from the chain that generates it.

The first example is a rotation with a prior of fixed mean and kk measurements of it, linearized at the posterior mode. The table gives the trace of each covariance divided by the posterior’s, averaged over six data sets:

σ\sigmakkrowsrows and log-volumesfull Hessian
0.30.3110.9760.9761.0211.0211.0041.004
0.30.3330.9710.9711.0381.0381.0031.003
0.150.15110.9930.9931.0041.0041.0001.000
0.150.15330.9920.9921.0081.0080.9990.999

The rows are over-confident by about half of the σ2k/(k+1)\sigma^2 k / (k + 1) that the log-volumes alone would predict. Adding the log-volumes’ curvature overshoots, to an under-confidence of about the same size, because the residuals’ curvature cancels about half of it. The full Hessian is close to the posterior.

The second example is a chain: x0\randomPoint_0 with a prior of fixed mean, and x1=x0⊕ε\randomPoint_1 = \randomPoint_0 \oplus \varepsilon, with nothing observed. It is linearized at its mode, where every residual is zero. The residuals’ curvature therefore vanishes, and the rows with the log-volumes’ curvature are the full Hessian. The variance of x1\randomPoint_1, per axis, is:

σ\sigmarowsfull Hessianposterior
0.30.30.1800.1800.1590.1590.1940.194
0.150.150.04500.04500.04350.04350.04570.0457

Both approximations are over-confident here, and the rows are the closer. They are exact on x0\randomPoint_0, where the full Hessian gives 0.0830.083 against 0.090.09 at σ=0.3\sigma = 0.3. The second-order approximation matches the curvature at the mode exactly, and that does not match the spread: the posterior is a Gaussian in the chart of x0\randomPoint_0 and in that of the transition, not in the joint chart at the mode.

The replacement’s covariance. A retirement’s replacement differs in two ways. The chart’s part of (10) is there only for the integrated quantities EFE_F, so nothing offsets the terms’ log-volumes on the blanket’s BFB_F. And the replacement is a log-density with respect to the blanket’s reference measure, not a Gaussian in its chart, so a later query that reads it applies the chart’s volume to it again. The second example, read as a retirement of x0\randomPoint_0 that keeps x1\randomPoint_1, shows both. The exact replacement is the logarithm of the marginal density of x1\randomPoint_1, whose curvature at the anchor was computed numerically from draws of x0\randomPoint_0:

σ\sigmarowswith (10)with (10) and the log-determinantexact
0.30.35.5565.5565.2945.2945.4575.4575.4555.455
0.150.1522.2222.2221.9721.9722.1022.1022.1022.10

These are precisions per axis. The rows are over-confident at the anchor, by 2 %2\,\% at σ=0.3\sigma = 0.3 and 0.6 %0.6\,\% at 0.150.15. The second-order Schur complement overshoots, by about as much, the other way. The exact curvature needs one more term: how the log-determinant of the eliminated block’s Hessian varies with vB\tangent_B, the correction of Laplace’s method of the next order. So at the anchor the pattern is that of the first example.

The larger cost lies elsewhere. The exact replacement is not a Gaussian in the anchor’s chart, whatever its curvature, and the departure is of the order of the replacement’s own variance. With the exact curvature, a later query that holds the replacement alone gives x1\randomPoint_1 the variance 0.1590.159 per axis, against the 0.1930.193 of the exact marginal at σ=0.3\sigma = 0.3, and 0.04350.0435 against 0.04580.0458 at σ=0.15\sigma = 0.15. A filter that predicts without measuring retires one state after another, and its replacement’s variance grows. Its error grows with it. At σ=0.15\sigma = 0.15, after kk retirements along the chain, the variance that the replacement gives the newest state, divided by the exact one, is:

kk1122334455
rows0.940.940.910.910.880.880.850.850.820.82
with (10)0.940.940.900.900.840.840.770.770.710.71

This is the over-confidence of an extended Kalman filter on a curved state, and it is a cost of the Gaussian form that Stacked takes, not of the omitted curvature. Adding the curvature makes it worse after the first step. Measurements bound the replacement’s variance, and with it this error.

So, on a curved quantity:

  • Confidence. Compared with the second-order Laplace approximation, the rows’ covariance may be over- or under-confident, depending on the direction. Compared with the posterior, it was slightly over-confident in every case computed here: by 11 to 2 %2\,\% at σ=0.15\sigma = 0.15 rad and 33 to 7 %7\,\% at σ=0.3\sigma = 0.3 rad. No argument shows that it must be. A replacement was over-confident in every case computed, by a relative amount of the order of its own variance in rad2^2, and this grows over a sequence of retirements that measure nothing. On the Euclidean and positive types with linear-Gaussian terms, both are exact.
  • Consistency. Adding the log-volumes’ curvature to the kept marginal is not the consistent choice. It adds one of three parts of the same order and leaves out the residuals’, which in the first example cancels about half of it. Added on the kept quantities alone, it also leaves out the curvature on the eliminated ones, which reaches the marginal through their conditionals. To first order in DD, the marginal precision on KK changes by P⊤DPP\transpose D P, not by DKKD_{KK}. Here PP lifts a tangent vector on KK to the whole tangent by the conditionals of the eliminated quantities EE, with the right-hand sides set to zero: with Λ=J⊤J\Lambda = J\transpose J in blocks, P=(I,−ΛEE−1ΛEK)P = (I, -\Lambda_{EE}^{-1} \Lambda_{EK}). The consistent second-order approximation is the full Hessian. It needs Hessian passes, it can be indefinite, and in the second example it is no closer to the posterior.
  • Definiteness. The rows’ precision is positive definite whenever the rows determine every direction. With the log-volumes’ curvature, the terms’ and the chart’s parts sum to about ∑tGt⊤(Λt−I)Gt+I\sum_t G_t\transpose (\Lambda_t - I) G_t + I on the curved blocks. That is positive definite whenever every Λt−I\Lambda_t - I is, that is, when every curved term’s noise is less than one in its chart’s coordinates. This is the condition under which a normal’s mean is a mode of its density. Definiteness is lost only where the normals themselves are broad, and the residuals’ part can still move this boundary. On a replacement’s BFB_F there is no +I+I, so the margin is smaller there: the sum is ∑tGt⊤(Λt−I)Gt\sum_t G_t\transpose (\Lambda_t - I) G_t alone.

A retirement’s replacement#

A retirement removes the quantities EE, fixing those of EOE_O at given values and integrating those of EFE_F out of the terms TE\mathcal T_E joined to them, and replaces those terms by one likelihood factor ℓB\logterm_B over their Markov blanket BB (22), the integral of Proposition 23. The core computes EE, TE\mathcal T_E and BB and applies the change; the caller computes ℓB\logterm_B. The linearization computes it as follows.

Take the query of the terms TE\mathcal T_E alone, whose log-density is their sum: free in EFE_F and in the continuous quantities BFB_F of the blanket that the replacement is to depend on, and observing everything else they involve, the quantities of EOE_O at their given values among them. Linearize it at a point x^=(x^E,x^B)\hat \point = (\hat \point_E, \hat \point_B), with the chart’s log-volume of EFE_F alone, since EFE_F is integrated over and BFB_F is not, and eliminate the blocks of EFE_F by integration, part 2 of Lemma 10, from these factors only. This is the note’s replacement (14): the terms outside TE\mathcal T_E stay in the model, and folding them in would count them twice. A quantity of EFE_F whose type declares no volume has no reference measure to integrate against, and its retirement is refused, naming it, as is a discrete one.

Proposition 11(The linearized replacement).

Let a retirement retire the quantities EE, with EOE_O given values and EFE_F continuous, of types with a volume and of total dimension dEd_E, and let BFB_F be continuous quantities of its blanket BB, of total dimension DD. Let mTm_T be the linearization at x^=(x^E,x^B)\hat \point = (\hat \point_E, \hat \point_B) of the query of the terms TE\mathcal T_E alone, free in EFE_F and BFB_F and observing every other quantity, taken with the chart’s log-volume of EFE_F alone, and let the columns of its rows for EFE_F have rank dEd_E. Then, for every vB∈RD\tangent_B \in \R^D,

log⁡∫RdEe−mT(vE,vB) dvE=−12∣AvB−b∣2−η⊤vB+c, \log \int_{\R^{d_E}} e^{-m_T(\tangent_E, \tangent_B)} \, \dd \tangent_E = -\tfrac12 \lvert A \tangent_B - b \rvert^2 - \eta\transpose \tangent_B + c ,

where AA has min⁡(m′,D)\min(m', D) rows, with m′m' the number of components of the retired residuals less dEd_E, and AA, bb, η\eta and cc are those of (12). Replacing the integrand of the replacement ℓB\logterm_B by e−mTe^{-m_T} gives ℓB(x^B⊕vB)\logterm_B(\hat \point_B \oplus \tangent_B) approximately as this right-hand side.

If the rows have rank dE+Dd_E + D, the number of their columns, then the right-hand side is ℓN(vB; m,W)+log⁡Z\logterm_{\mathcal N}(\tangent_B;\, m, W) + \log Z, with Z=∫e−mTZ = \int e^{-m_T}, and with mm the mean and WW the lower-triangular whitening, with a positive diagonal, of the marginal on vB\tangent_B of the normal density proportional to e−mTe^{-m_T}.

Proof.

By (11) over EFE_F, ℓB(xB)=log⁡∫eℓT(xE,xB)dν(xE)\logterm_B(\point_B) = \log \int e^{\logterm_T(\point_E, \point_B)} \dd \nu(\point_E), with ℓT\logterm_T the sum of the terms of TE\mathcal T_E, is the logarithm of the integral over vE\tangent_E of e−ϕ(vE,vB)e^{-\phi(\tangent_E, \tangent_B)}, with ϕ=−ℓT(x^⊕v)−λx^E(vE)\phi = -\logterm_T(\hat \point \oplus \tangent) - \lambda_{\hat \point_E}(\tangent_E) the chart objective of the query above, at xB=x^B⊕vB\point_B = \hat \point_B \oplus \tangent_B. The approximation replaces ϕ\phi by its linearization mTm_T.

The columns of the rows for EFE_F have rank dEd_E, so eliminating the blocks of EFE_F one at a time, in any order, meets a nonsingular triangular block RkR_k at each. Part 2 of Lemma 10, applied to each in turn, gives

∫RdEe−mT(vE,vB) dvE=(2π)dE/2∏i∈EF∣Rii∣−1e−c0−Γ−ϕB(vB), \int_{\R^{d_E}} e^{-m_T(\tangent_E, \tangent_B)} \, \dd \tangent_E = (2\pi)^{d_E / 2} \prod_{i \in E_F} \lvert R_{ii} \rvert^{-1} e^{-c_0 - \Gamma - \phi_B(\tangent_B)} ,

where the product is over the diagonal entries of the blocks of EFE_F, Γ\Gamma is the sum of their constants γ\gamma, and ϕB(vB)=12∣A′vB−b′∣2+η′⊤vB\phi_B(\tangent_B) = \tfrac12 \lvert A' \tangent_B - b' \rvert^2 + \eta'^\top \tangent_B is the sum of the factors left on BFB_F. This holds for every vB\tangent_B, and asks nothing of the rows on BFB_F.

One reduction brings ϕB\phi_B to the form stated. An orthogonal factorization of [A′   b′][A' \;\, b'], with no pivoting and no decision of rank, leaves min⁡(m′,D)\min(m', D) rows [A   b][A \;\, b], with m′m' the number of rows of A′A', and, when m′>Dm' > D, a residual ee in the rows below, so that 12∣A′vB−b′∣2=12∣AvB−b∣2+12∣e∣2\tfrac12 \lvert A' \tangent_B - b' \rvert^2 = \tfrac12 \lvert A \tangent_B - b \rvert^2 + \tfrac12 \lvert e \rvert^2. The linear term is kept as it is, η=η′\eta = \eta'. Collecting the constants,

c=dE2log⁡2π−∑i∈EFlog⁡∣Rii∣−c0−Γ−12∣e∣2.(12) c = \tfrac{d_E}{2} \log 2\pi - \sum_{i \in E_F} \log \lvert R_{ii} \rvert - c_0 - \Gamma - \tfrac12 \lvert e \rvert^2 . \tag{12}
(12)

The number of rows, min⁡(m′,D)\min(m', D), and whether η\eta is present at all, are fixed by the terms and their types alone: m′m' is the number of components of the retired residuals less dEd_E, and η\eta is present only where a log-volume is not folded or a chart’s log-volume of EFE_F has a gradient, which happens only on the positive types. The numbers decide neither, so every row of a batch has a replacement of one shape. A replacement whose rows are numerically singular is not a different shape. It is a quantity the rows do not determine, which a later query that needs it refuses.

If the rows have rank dE+Dd_E + D, the matrix of ϕB\phi_B is the Schur complement of a positive definite matrix, so AA is square and nonsingular, and η\eta, if present, lies in its row space and folds into bb as the note’s linear terms do. The right-hand side is then a Gaussian in vB\tangent_B with the precision A⊤AA\transpose A and the mean m=A−1(b−A−⊤η)m = A^{-1} (b - A^{-\top} \eta), which by Corollary 13 are those of the marginal of the normal density proportional to e−mTe^{-m_T}, and integrating it over vB\tangent_B gives ZZ.

The integral of e−mTe^{-m_T} is over the whole of RdE\R^{d_E}, while ϕ\phi is defined on the chart’s domain alone: putting the one for the other is part of the approximation, exact when the chart is global, and otherwise in error by the Gaussian’s mass outside the domain.

∎

The replacement is therefore an improper Gaussian in the blanket’s tangent coordinates at the anchors pi=x^ip_i = \hat \point_i, i∈BFi \in B_F:

ℓB(xB)=−12∣A δ(xB)−b∣2−η⊤δ(xB)+c,(13) \logterm_B(\point_B) = -\tfrac12 \bigl\lvert A\, \delta(\point_B) - b \bigr\rvert^2 - \eta\transpose \delta(\point_B) + c , \tag{13}
(13)

with δ\delta the stacked tangent of (9). It is a function of the blanket’s quantities that no normalization need make a density, and a likelihood factor needs none. The anchors are the linearization point, constants of the model, so the factor does not move with the quantities it summarizes, and its value and its derivatives at x^B\hat \point_B are the linearization’s. The constant makes the replacement right in value as well as in shape, which the core’s tests of retirement check (What the tests check).

The replacement is written in this form whatever the rank, so that its shape depends on the structure alone. When the retired terms determine the whole blanket, its value is that of the normal’s Stacked replacement (10), with:

pi=x^i (i∈BF),m=vB∗,W,c=log⁡Z=dE+D2log⁡2π−mT(v∗)−∑ilog⁡∣Rii∣,(14) p_i = \hat \point_i \ (i \in B_F), \qquad m = \tangent_B^*, \qquad W, \qquad c = \log Z = \tfrac{d_E + D}{2} \log 2\pi - m_T(\tangent^*) - \sum_i \log \lvert R_{ii} \rvert , \tag{14}
(14)

where v∗=(vE∗,vB∗)\tangent^* = (\tangent_E^*, \tangent_B^*) is the minimizer of mTm_T, RR the triangular root of its rows, eliminated in any order, and WW the lower-triangular root of what is left on BFB_F after EFE_F is eliminated, brought to a positive diagonal as the note says. A reader that wants the mean and the scale reads them off AA, bb and η\eta by one more factorization, and the core’s replacements in the tests below are compared in value. When the retired terms do not determine the blanket, the replacement keeps what they say about it, and Blanket quantities the rows do not determine says what that buys and what it costs.

Exact for linear-Gaussian terms. If the terms of TE\mathcal T_E are linear-Gaussian, the chart objective is quadratic by Proposition 7, mT=ϕm_T = \phi, nothing is approximated, and the replacement is the integral of Proposition 23, at every point x^\hat \point. The core’s replacements (24) and (25) are two cases: retiring x0\randomPoint_0 and z0\bfz_0, with z0\bfz_0 observed, from the scalar chain gives the Kalman filter’s update and prediction, its evidence log⁡N(a,s2+r2)(z^0)\log \mathcal N(a, s^2 + r^2)(\hat z_0) as log⁡Z\log Z; retiring x0\randomPoint_0 alone, with BF={z0,x1}B_F = \{\bfz_0, \randomPoint_1\}, gives the joint normal with c=0c = 0, since then every term of TE\mathcal T_E is a normalized density of a quantity integrated or kept, and Z=1Z = 1.

Observed blanket quantities. A blanket quantity the query observes is fixed at its value before the integral is approximated, and the replacement is not reached from it: it is the replacement at that value, as an extended Kalman filter’s prediction is the prediction for the controls it was given. That is right for data, such as the example’s IMU reading ζ1\bfzeta_1, and the core accepts a replacement reached from part of the blanket only. A blanket quantity the replacement must stay a function of, such as a parameter a later query may leave free, is put in BFB_F. A discrete blanket quantity is always fixed, since a free one is refused.

Filters. On a chain, retiring the oldest state xk\randomPoint_k with its measurement, while the next state xk+1\randomPoint_{k+1} stays, linearizes the replacement left by the previous retirement, the measurement’s term and the motion’s term, and integrates xk\randomPoint_k out: an update and a prediction in one, in square-root information form. Where it is taken is the caller’s choice of x^\hat \point, and the choice is the filter.

  • At the mode of the retired terms, which puts x^k\hat \point_k at the update’s mode and x^k+1\hat \point_{k+1} at its prediction, the replacement is an iterated extended Kalman filter’s step: the measurement and the motion are both linearized at the updated estimate. Reaching that mode is a Gauss–Newton iteration on the retired terms alone.
  • At the prediction, x^k\hat \point_k the previous replacement’s mean and x^k+1\hat \point_{k+1} its image under the motion, the measurement is linearized where an extended Kalman filter linearizes it. The classical filter then linearizes the motion at the updated estimate instead, a second point for the same quantity, which one linearization of one query cannot take. The predicted mean differs from the classical filter’s at second order in the update’s step, since it is the motion’s first-order expansion about the prediction evaluated at the update; the predicted covariance differs at first order, since it is propagated by the motion’s Jacobian at the prediction rather than at the update.

Several states retired at once give one approximation of the whole, and one after another a sequence of them, which differ as the core’s retirement says they may.

Blanket quantities the rows do not determine#

Proposition 11 asks that the retired terms determine the retired quantities, given the blanket. It asks nothing of the blanket itself, and often they determine only part of it. A landmark seen by bearing from the retired pose alone is the standard example. The bearing fixes the landmark’s direction from that pose, but not its depth along it, so the replacement on the landmark has fewer rows than the landmark has coordinates. It keeps what the retired terms say, the direction, and says nothing about the depth. Read as a function of the landmark, it is constant along the bearing’s ray and Gaussian across it, and no normalization makes it a density. For linear-Gaussian terms it is still the exact integral.

Information accumulates. Replacements over the same quantities add: their rows stack, and one orthogonal factorization reduces them; their linear terms add; and their constants add. Take a linear stand-in for the bearing in the plane: a landmark ℓ∈R2\ell \in \R^2 and poses x1,x2∈R2\point_1, \point_2 \in \R^2, each pose with its own prior, and measurements zk=ak⊤(ℓ−xk)+εkz_k = a_k\transpose (\ell - \point_k) + \varepsilon_k along known unit directions aka_k. Retiring x1\point_1 and z1z_1 leaves one row on ℓ\ell, along a1a_1. Retiring x2\point_2 and z2z_2 leaves a second, along a2a_2. Neither determines ℓ\ell. When a1a_1 and a2a_2 are not parallel, the two together do, and their sum is exactly the replacement that retiring both poses and both measurements at once would give, by (14), since the two sets of retired terms are disjoint. A model can therefore marginalize what it learns about a quantity it cannot yet estimate, keep it at the cost of a few rows, and estimate the quantity once enough has accumulated, losing nothing on the way. Until then, a query that leaves the quantity free, with nothing else to determine it, is refused, naming it, as a quantity the rows do not determine.

Where it is linearized. For linear-Gaussian terms the point does not matter. Otherwise the rows are the retired terms’ Jacobians at x^B\hat \point_B, and along the directions the terms do not determine, nothing in the data says where x^B\hat \point_B should be. For a bearing, the Jacobian with respect to the landmark’s position scales with the inverse of the depth at which it is taken. The replacement is then only as good as the depth guessed for it, and since a retired term is never linearized again, a poor guess is kept. A parametrization in which the undetermined direction enters linearly, such as an inverse depth, reduces this. That is the model’s choice, not the linearization’s.

When there is a linear term. On the Euclidean and the curved types, there is none. Every normal’s log-volume on these types is folded into its rows, and the chart’s log-volume of EFE_F is even, so its gradient at zero is zero. The linear term of mTm_T is therefore zero, and elimination creates none. An earlier replacement among the retired terms has none either, by the same argument, and so adds none.

On a positive type the log-volume ∑ilog⁡xi\sum_i \log \point_i depends on the quantity and not only on its tangent coordinate at the mean, so it is not folded, and a linear term remains. Let a positive quantity x\point be scored by the normal on the positive type with the mean eθ+φe^{\theta + \varphi}, let the Euclidean θ\theta have the prior N(0,1)\mathcal N(0, 1), and retire θ\theta, keeping φ\varphi and x\point. The exact replacement is

ℓB(x,φ)=log⁡∫N(θ; 0,1) 1x N(log⁡x; θ+φ,σ2) dθ=−log⁡x−(log⁡x−φ)22(1+σ2)−12log⁡(2π(1+σ2)). \logterm_B(\point, \varphi) = \log \int \mathcal N(\theta;\, 0, 1)\, \frac{1}{\point}\, \mathcal N(\log \point;\, \theta + \varphi, \sigma^2) \, \dd \theta = -\log \point - \frac{(\log \point - \varphi)^2}{2 (1 + \sigma^2)} - \tfrac12 \log \bigl(2\pi (1 + \sigma^2)\bigr) .

In the logarithmic chart at the anchor, log⁡x=log⁡x^+v\log \point = \log \hat \point + \tangent, it is one squared row in v−φ\tangent - \varphi and the linear term −v-\tangent. The linearization finds exactly this. Its rows over (θ,φ,v)(\theta, \varphi, \tangent) are the prior’s [1   0   0][1 \;\, 0 \;\, 0] and the term’s [−1   −1   1]/σ[-1 \;\, -1 \;\, 1] / \sigma, and its linear term is (0,0,1)(0, 0, 1), the gradient of log⁡x\log \point. Eliminating θ\theta leaves one row on (φ,v)(\varphi, \tangent), along v−φ\tangent - \varphi, and the linear term (0,1)(0, 1), since θ\theta’s own linear term is zero. Here the blanket is not determined and the linear term is not in the row’s span, so the factor carries both. Where the retired terms determine the blanket as well, the same form has the value of a Stacked replacement.

How it meets the roles. In the terms of (1), the factor (13) binds the whitened residual Aδ−bA \delta - b, which has min⁡(m′,D)\min(m', D) components, possibly none. Its remainder ρ=c−η⊤δ\rho = c - \eta\transpose \delta has the constant normalizer cc and the varying part λ=η⊤δ\lambda = \eta\transpose \delta. The linearization reads a term’s linear part through the node bound under the log-volume role, so the factor binds η⊤δ\eta\transpose \delta there, where a positive type leaves a linear term. The core lets a replacement bind roles (the replacement’s bindings), so a later query, or a later retirement, finds the factor’s rows as it finds any other term’s. That node is not the log-volume of any measure. It is the varying part of the remainder, which is all that the linearization’s reading of the role assumes. Whether the role keeps its name, or is named for what it is, is the implementation’s question.

Information roots#

The residual linearization refuses a factor whose scale is free, since its omitted curvature in the scale is as large as what its rows keep. Fisher scoring keeps the scale. It replaces the Hessian by the expected information, the expectation over the scored quantity of the Hessian of its negative log-density, which is positive semidefinite by construction. The normal binds a root CC of it on every term that scores a quantity (the expected information). This entry linearizes with those roots as a second assembly of the same factored problem. It shares no rows with the residual linearization’s assembly, and shares all of the elimination.

Definition 15(The Fisher linearization of a query).

Let a query be as in Definition 3, except that a term tt that scores a quantity may have its scale reached from free quantities, through coordinates θt\theta_t, and then binds the information root (8) with scale block Cθ,tC_{\theta, t}. Its normalizer ntn_t then varies with θt\theta_t, and the scale residual below carries its gradient. For such a term, let JtμJ^\mu_t be the Jacobian of its residual rt=Wt str_t = W_t\, s_t with the scale held fixed, Jtμ=WtDstJ^\mu_t = W_t \D s_t, and let Jtθ=Cθ,tDθtJ^\theta_t = C_{\theta, t} \D \theta_t be its scale block composed with the Jacobian of the scale’s coordinates, both in the charts of the free quantities at x^\hat \point. Let its scale residual utu_t be the vector, indexed as the rows of Cθ,tC_{\theta, t}, with

(ut)(a,a)=(rt)a2−12,(ut)(a,b)=(rt)a(rt)b(a>b). (u_t)_{(a, a)} = \frac{(r_t)_a^2 - 1}{\sqrt 2} , \qquad (u_t)_{(a, b)} = (r_t)_a (r_t)_b \quad (a > b) .

Every other term contributes as in Definition 3, and its scale must be fixed. The query’s Fisher linearization at x^\hat \point is

mF(v)=cF+∑t12∣Jtμv+rt+c^t∣2+∑t free scale12∣Jtθv+ut∣2+η⊤v, m_F(\tangent) = c_F + \sum_t \tfrac12 \bigl\lvert J^\mu_t \tangent + r_t + \hat c_t \bigr\rvert^2 + \sum_{t \text{ free scale}} \tfrac12 \bigl\lvert J^\theta_t \tangent + u_t \bigr\rvert^2 + \eta\transpose \tangent ,

with Jtμ=JtJ^\mu_t = J_t for a term whose scale is fixed, c^t\hat c_t and η\eta as in Definition 3, WtW_t taken at x^\hat \point where the scale is free, and cFc_F chosen so that mF(0)=f(x^)m_F(0) = f(\hat \point).

It is a root of the expected information. The root (8) composed with the Jacobians of the term’s scored quantity, mean and scale coordinates is

Ct[DxDμDθt]=[Wt(Dx−Dμ)Cθ,tDθt], C_t \begin{bmatrix} \D \point \\ \D \mu \\ \D \theta_t \end{bmatrix} = \begin{bmatrix} W_t (\D \point - \D \mu) \\ C_{\theta, t} \D \theta_t \end{bmatrix} ,

since its blocks are ±Wt\pm W_t, the derivatives of st=x⊖μs_t = \point \ominus \mu at a zero residual. On the flat-in-disguise types those derivatives are ±I\pm I everywhere, so the first block row is WtDst=JtμW_t \D s_t = J^\mu_t exactly, and mFm_F’s matrix,

∇2mF=∑tJtμ⊤Jtμ+∑t free scaleJtθ⊤Jtθ,(16) \nabla^2 m_F = \sum_t J^{\mu\top}_t J^\mu_t + \sum_{t \text{ free scale}} J^{\theta\top}_t J^\theta_t , \tag{16}
(16)

is the sum of the terms’ expected information, each an expectation over its own scored quantity with its inputs at their values at x^\hat \point. On a curved type the derivatives of ⊖\ominus at the current residual stand where the root has their values at zero. The two differ at first order in the residual, and in a quadratic form at second order, the accuracy the normal states for the root’s blocks of the quantity and the mean. The mixed blocks, which the root sets to zero, are exact in expectation on the flat-in-disguise types and, on a curved type, of first order for a scale that is neither isotropic nor diagonal, as the normal also states. The residual’s own Jacobian is the better choice of the two derivatives, for the reason that follows.

Its gradient is exact. The gradient of mFm_F at zero is

∇mF(0)=∑tJtμ⊤(rt+c^t)+∑t free scaleJtθ⊤ut+η=g. \nabla m_F(0) = \sum_t J^{\mu\top}_t (r_t + \hat c_t) + \sum_{t \text{ free scale}} J^{\theta\top}_t u_t + \eta = g .

The first sum and η\eta are the gradients of the squares through the quantity and the mean, and of the log-volumes, as in (4). The second is the gradient through the scale. With Ti=L⊤ ∂iΛ LT_i = L\transpose\, \partial_i \Lambda\, L as for the root, z=rtz = r_t and ε=Lz\varepsilon = L z, the negative log-density’s derivative in θi\theta_i is

12ε⊤∂iΛ ε−12tr⁡(Σ ∂iΛ)=12(z⊤Tiz−tr⁡Ti)=∑a(Ti)aa2⋅za2−12+∑a>b(Ti)ab zazb, \tfrac12 \varepsilon\transpose \partial_i \Lambda\, \varepsilon - \tfrac12 \operatorname{tr}(\Sigma\, \partial_i \Lambda) = \tfrac12 \bigl(z\transpose T_i z - \operatorname{tr} T_i\bigr) = \sum_a \frac{(T_i)_{aa}}{\sqrt 2} \cdot \frac{z_a^2 - 1}{\sqrt 2} + \sum_{a > b} (T_i)_{ab}\, z_a z_b ,

which is (Cθ,t⊤ut)i(C_{\theta, t}\transpose u_t)_i. So the scale’s score lies in the row space of its root, and the scale residual carries it, as c^t\hat c_t carries a folded log-volume. Had the first block row used ±Wt\pm W_t on a curved type, the gradient through the quantity and the mean would have missed a term of first order in the residual, and the iteration would have stopped short of the stationary point. With JtμJ^\mu_t, a Fisher scoring step

vF∗=−(∇2mF)−1g(17) \tangent^*_F = -\Bigl(\nabla^2 m_F\Bigr)^{-1} g \tag{17}
(17)

stops only where g=0g = 0, at a stationary point of ff, log-volumes included. It converges there at the linear rate that the difference between the Hessian and the expected information sets.

Where the expected information is exact. For an isotropic scale in its logarithmic chart, u=log⁡σu = \log \sigma, the root’s scale block is −2-\sqrt 2 in each of the d\dimension diagonal rows, and the scale’s information is 2d2 \dimension. The Hessian of the term in uu is 2∣rt∣22 \lvert r_t \rvert^2, which at a stationary point of the scale alone, ∣rt∣2=d\lvert r_t \rvert^2 = \dimension, is 2d2 \dimension too. The case that makes the residual linearization’s rate one, its third refusal in Linearizing a query, has a rate of zero in the scale’s own direction here. The scale residual’s diagonal rows are ((rt)a2−1)/2((r_t)_a^2 - 1) / \sqrt 2, and the step in uu is (∣rt∣2−d)/2d(\lvert r_t \rvert^2 - \dimension) / 2\dimension, the first-order step toward 12log⁡(∣rt∣2/d)\tfrac12 \log (\lvert r_t \rvert^2 / \dimension).

With every scale fixed, it is the residual linearization. No term then has a scale block, every JtμJ^\mu_t is JtJ_t, and mF=mm_F = m, on every type. The two assemblies differ only where a scale is free, which the residual linearization refuses. They are kept separate all the same, since they answer to different readers. The residual linearization is the Gauss–Newton model of ff, whose curvature at a mode is a Laplace approximation’s. The Fisher linearization is the expected information, whose inverse, where the free quantities are parameters rather than scored quantities themselves, is the asymptotic covariance of their maximum-likelihood estimator.

What it gives, and what it does not. The Fisher linearization is eliminated as the residual linearization is. Its factor structure is the same: a term’s variables KtK_t are the free quantities it involves, whether through its quantity, its mean or its scale. So one plan serves both, and its steps, damping and marginals are computed as above. Its marginal covariances are those of the inverse of (16), a free scale’s among them. It provides no evidence and no replacement. Those approximate an integral of the model’s density, whose curvature in a free scale is not the expected information, and the residual linearization, which does provide them, refuses a free scale.

What it refuses. The Fisher linearization refuses, naming the term or the quantity:

  1. a free discrete quantity, as the residual linearization does;
  2. a term whose scale is free and which binds no information root, since nothing then says what the scale’s information is. A likelihood factor binds none, since it scores no quantity, so its scale must be fixed, and it contributes its residual’s rows, as the normal says a reader that needs a positive semidefinite matrix from one should;
  3. a factor that binds no residual, as the residual linearization does.

What the tests check#

  • The linearization agrees with the query, (4): m(0)m(0) with the query’s log-density, ∇m(0)\nabla m(0) with its cotangent pass, and each JtJ_t with finite differences of rtr_t along x^⊕hv\hat \point \oplus h \tangent, on Euclidean, positive and rotation quantities, at both precisions, with only the columns of KtK_t nonzero.
  • It is exact for linear-Gaussian terms, Proposition 7: m(v)=f(x^⊕v)m(\tangent) = f(\hat \point \oplus \tangent) at several v\tangent, at a point that is not the mode, on Euclidean and on positive quantities.
  • The step is Gauss–Newton’s, (6): it agrees with a dense solve of the normal equations on a small, well-conditioned model; on the note’s ill-conditioned example it is accurate where the normal equations fail; iterated on normals of rotations, it converges to the mode of (12), the log-volumes included through η\eta.
  • The elimination is order-independent: the step, the marginal covariances and the log-determinant agree across orders, and with dense computations on small models; the marginal on KK equals the KK block of the inverse of J⊤JJ\transpose J.
  • Damping gives the minimizer of (J⊤J+λD) v=−g(J\transpose J + \lambda D)\, \tangent = -g and the promised decrease (8), and leaves the plan unchanged.
  • The Laplace approximation is centred in the chart: on a log-normal quantity it is centred at the median, with the covariance of the logarithm, and its evidence is exact for a linear-Gaussian model, against quadrature.
  • The replacement is the core’s, (14): retiring from the core’s scalar chain gives (24) and (25), constants included, equal in value to the Stacked replacements, and the retired models pass the core’s checks of retirement; on a linear-Gaussian chain of several states, retiring them one at a time gives the Kalman filter’s means, covariances and evidence; on a nonlinear chain, the replacement at the prediction agrees with an extended Kalman filter in its predicted mean to second order in the update’s step, and in its predicted covariance to first order, and the replacement at the retired terms’ mode with an iterated extended Kalman filter.
  • An improper replacement keeps what it is given, (13): on the planar example of Blanket quantities the rows do not determine, each retirement leaves one row on ℓ\ell, and the sum of the two equals the replacement of retiring both poses at once, constants included, and gives the exact posterior of ℓ\ell when queried; on a nonlinear bearing it agrees with a dense computation of the same linearized integral; on the positive example it is the exact replacement, one row and the linear term (0,1)(0, 1); on Euclidean and rotation quantities its linear term is absent; and its shape is the same for every row of a batch, singular rows included.
  • Batch rows share the plan: a batch of points has one order and one elimination tree, and each row’s step is the step of that row linearized alone.
  • The linear term is exactly zero where no log-volume is bound: on a model of Euclidean normals with fixed scales the step is the least-squares solution, bit for bit independent of the query’s gradient pass.
  • Folded log-volumes are in the right-hand sides: on normals of rotations, η=0\eta = 0 exactly, Jt⊤c^tJ_t\transpose \hat c_t equals the cotangent pass of λt\lambda_t, and iterated steps converge to the same mode as with the log-volume’s gradient carried as a linear term.
  • The Fisher linearization is a root of the expected information, (16): its matrix equals the normal’s closed form on Euclidean and positive quantities, and a Monte Carlo estimate of the expected Hessian; its gradient equals the query’s cotangent pass, a free scale’s included; with every scale fixed it equals the residual linearization row for row; Fisher scoring on normals with free means and an isotropic or a diagonal scale converges to the maximum-likelihood estimate; its marginal covariances equal the corresponding blocks of the inverse expected information; and it shares the residual linearization’s plan.
  • What is refused: a free discrete quantity, a factor without a residual, a factor whose scale is free in the residual linearization, a free scale whose term binds no information root in the Fisher linearization, a quantity the rows do not determine, a retirement whose terms do not determine a retired quantity, and an integral over a quantity whose type has no volume, each naming what it names.

In skoro’s terms#

  • A query is linearized at a point: its free continuous quantities, in the order of a layout, are the variables, each a block of its tangent dimension, and every other quantity is fixed. Each term reached from a free quantity is a factor over its free quantities KtK_t, read off the compilation graph; the others are constants of the query.
  • A factor’s rows are its residual’s Jacobian, JtJ_t, and its right-hand side −(rt+c^t)-(r_t + \hat c_t), from the node it binds under the residual role and, on a curved type, the gradient of its log-volume with respect to that residual. The linear term η\eta is the gradient of the log-volumes that are not folded, those of normals on positive quantities and an improper replacement’s linear part, and is exactly zero where there are none; it is not formed as the query’s gradient less what the rows account for, a difference that rounding would fill. Everything is of first order, computed at the query’s precision, and solved on the host in double precision.
  • The residual linearization is refused for a free discrete quantity, a factor without a residual, and a factor whose bound scale is reached from a free quantity; the Fisher linearization accepts the last when its term binds an information root; an integral, for a quantity whose type declares no volume.
  • Fisher linearization is a second assembly of the same factored problem: a term with a free scale contributes the rows JtμJ^\mu_t of its residual’s Jacobian with the scale held, and the rows JtθJ^\theta_t of its information root’s scale block composed with the Jacobian of the scale’s coordinates, with the scale residual on the right; every other term contributes as above. It is refused for a free scale whose term binds no information root, and gives steps and covariances, not evidence or replacements.
  • Elimination is the note’s, by blocks that are the free quantities, with an order and an elimination tree that depend on the factor structure alone and so serve every row of a batch, and with a refusal for a quantity the rows do not determine.
  • A step is the minimizer, retracted quantity by quantity; damping appends a factor per quantity; a Laplace approximation uses the chart linearization, with the log-volume of the quantities integrated over, and reads its marginals, draws and evidence off the eliminated rows. Its precision, and a replacement’s, is the rows’ alone, without the curvature of the residuals or the log-volumes, and on a curved quantity it is reported with an error of order σ2\sigma^2.
  • A retirement’s replacement is the linearized integral of Proposition 11, computed from the retired terms alone, free in the retired quantities to integrate and in the blanket’s quantities to keep, at a point the caller chooses. It is the improper Gaussian (13) at anchors at that point: min⁡(m′,D)\min(m', D) rows, a right-hand side, a linear term only where a positive type leaves one, and a constant, in one form whatever the rank. When it determines the blanket, its value is the normal’s Stacked replacement’s, with the mean, the whitening and the constant of (14). It binds the residual Aδ−bA \delta - b and, where η≠0\eta \ne 0, the varying part of its remainder under the log-volume role. It is exact for linear-Gaussian terms, where it is the Kalman filter, and otherwise an iterated extended Kalman filter or, at the prediction, an approximation of the extended one. A retirement whose terms do not determine a retired quantity is refused.

Open questions#

None remains. The three questions this document raised are decided: the precision is the rows’ alone, a replacement the rows do not determine is an improper Gaussian, and information roots belong to this entry as a second assembly.

Built on by