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.
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 of the product of their types, whose tangent space is the stacked of (1), , and whose step is the product’s retraction (17). Write for the point at which the query is linearized, for a tangent vector there, for the query’s negative log-density (16), and for its chart gradient at (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 at . Computation is batched, and every row of a batch has a point and a linearization of its own.
Residuals and remainders. A term binds a whitened residual when a node 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,
and is its remainder. For the normal’s term (3), , which is constant when the scale is fixed, and , which the normal binds only where it is not identically zero, on positive and curved types. For a retirement’s Gaussian replacement (10), is the normalizer and the constant , and there is no log-volume. For an improper replacement (13), , and where a linear term remains: the varying part of the remainder, which is all (1) asks of . 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 that each term involves (terms). For a query, the term’s variables are its free continuous quantities,
and a term with empty is reached from no free quantity: its log-density is a constant of the query, part of and of nothing else below. The terms with 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 and each quantity of . 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 and then , which measures a landmark from each, as and , moved by an IMU’s model driven by its reading , with the platform’s own motion model of scale as a likelihood factor. Here every term is taken to be a normal, among them as a normal’s likelihood factor over the step , so that every term binds a residual; the core wrote ’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:
- Free quantity
- Factor
- has a block for
Linearizing a query#
Let a query have no free discrete quantity, let its free continuous quantities, in an order, have the stacked tangent , and let every term whose log-density is reached from a free quantity bind a whitened residual , of any number of components, none included, with
constant in the query and 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 for a constant invertible and is a function of alone, and set , the gradient of the log-volume with respect to the residual; otherwise set . With the query’s negative log-density, its linearization at a point is the function of
where
where is the residual at and and are the Jacobian and the gradient in the charts of the free quantities. Its chart linearization is the linearization of , with the log-volume of the chart at of the free quantities: the same rows, with and in place of and .
The linearization agrees with to first order, and its curvature is the Gauss–Newton matrix:
The first holds by the choice of . The second holds because by (1), the normalizers being constant, while the gradient of at is . For a folded term, , so .
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, , 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 alone: on a group whose chart translates the identity’s, and a function of on the sphere with orthonormal bases. On a positive type it is , which depends on the quantity and not only on , and it stays in . 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 is a gradient of the size of ’s own components, and it gains two things. A folded linear term is solved with the residuals, at , rather than at 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 exactly, before and after any elimination.
Why is read off the log-volumes. In exact arithmetic , 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, is exactly zero, while and are each of the size of 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 , 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 times swamps the step for a moderate . Read off the bound log-volumes that are not folded, is exactly zero wherever there are none, and otherwise only as large, and as rounded, as their own gradients. The constant 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 , and no solve amplifies it.
The linearization is the note’s problem (9) with one factor for each term, with the rows , of the dimension of , over the blocks of , and the right-hand side , and the linear term , 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 at , which at a stationary point is the chart Hessian of Proposition 3, is
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 there: it stops only where , at a stationary point of 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
and it is computed as the note computes (7): the part from the right-hand sides, folded log-volumes included, at , and the part from at , as the normal equations would. On a model of normals with fixed scales on the Euclidean and curved types, 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:
- 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);
- 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;
- 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 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 , , so the rows’ curvature in is and the squares’ is , while the normalizer is linear. At the stationary point , 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 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 are nonzero in . The linear term is one cotangent pass of the sum of the bound log-volumes, and none where no term binds one, and needs the query’s log-density and its residuals at . 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).
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 the linearization is exact, for every , and so is the chart linearization.
On a flat-in-disguise type the chart at 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 . An affine residual has exactly, and an affine log-volume is equal to its first-order expansion, so , plus the constant normalizers and terms, is . The log-volume of a flat-in-disguise type is zero or, on a positive factor, (2), affine in , 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 , 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 . The damped minimizer solves , and the decrease of the undamped linearization that it promises is
since and . The ratio of the decrease actually obtained, , to (8) is what a Levenberg–Marquardt method compares with one to adapt ; its schedule, its choice of 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 , eliminating collects the four factors joined to it, , , and , and leaves a conditional of on its separator and one new factor there, with the linear terms of pushed onto it; eliminating then collects and the new factor, with the separator .
- Free quantity
- parent of
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 , 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 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 , where the reference measure has the density of its log-volume, (11):
What is approximated by a Gaussian in is therefore the chart objective , whose linearization is the chart linearization of Definition 3, and not alone. The difference is in two places.
- Its centre. The Gaussian is centred at when is a stationary point of the chart objective, where , rather than of . On the Euclidean types . On a group whose chart translates the identity’s, as the Cayley chart of the rotations does, , and the Cayley chart’s is even in , as the stereographic chart’s of the sphere is, so its gradient at is zero: on these types the centre is a mode of . On a positive type in each coordinate, and the centre is the mode in the logarithmic chart. For a quantity scored by a log-normal of median , it is itself, where is centred, while the mode with respect to Lebesgue measure is , below it. A Gaussian in the tangent coordinates is a Gaussian in the logarithms, and is centred where they are.
- Its constant. is on a positive type and zero on the others the library has: the volume of the reference measure near .
With the chart linearization of rows of full rank, is a constant times a normal density on , and every quantity a Laplace approximation asks for is a computation of the note on its rows:
| asked for | computed by |
|---|---|
| the mean, in the tangent at | the minimizer , zero at the centre |
| the covariance, and its marginal on quantities | partial elimination of the others, Corollary 13, and the triangular root of what is left on : |
| a draw | , with standard normal |
| the evidence | , 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’, . The Hessian of the chart objective at the centre is that and
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 , 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 is of the order of the precisions , so each changes the covariance by a relative amount of the order of the noise’s variance, .
- The chart’s part is positive. On every curved type the library has, the chart’s log-volume is , whose Hessian at zero is . So the chart adds on each curved quantity that is integrated over.
- The terms’ part is negative. Let be the derivative of the term’s tangent coordinate with respect to . A term’s log-volume adds about , against the that its rows keep. This is the replacement of by 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 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 over the noise, against the log-volume’s . This was computed numerically, from 4000 draws at .
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 in every direction when is negative semidefinite, and larger in every direction when 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 . Two examples on the rotations, in the Cayley chart with an isotropic , 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 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:
| rows | rows and log-volumes | full Hessian | ||
|---|---|---|---|---|
The rows are over-confident by about half of the 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: with a prior of fixed mean, and , 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 , per axis, is:
| rows | full Hessian | posterior | |
|---|---|---|---|
Both approximations are over-confident here, and the rows are the closer. They are exact on , where the full Hessian gives against at . 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 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 , so nothing offsets the terms’ log-volumes on the blanket’s . 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 that keeps , shows both. The exact replacement is the logarithm of the marginal density of , whose curvature at the anchor was computed numerically from draws of :
| rows | with (10) | with (10) and the log-determinant | exact | |
|---|---|---|---|---|
These are precisions per axis. The rows are over-confident at the anchor, by at and at . 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 , 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 the variance per axis, against the of the exact marginal at , and against at . A filter that predicts without measuring retires one state after another, and its replacement’s variance grows. Its error grows with it. At , after retirements along the chain, the variance that the replacement gives the newest state, divided by the exact one, is:
| rows | |||||
| with (10) |
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 to at rad and to at 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 rad, 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 , the marginal precision on changes by , not by . Here lifts a tangent vector on to the whole tangent by the conditionals of the eliminated quantities , with the right-hand sides set to zero: with in blocks, . 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 on the curved blocks. That is positive definite whenever every 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 there is no , so the margin is smaller there: the sum is alone.
A retirement’s replacement#
A retirement removes the quantities , fixing those of at given values and integrating those of out of the terms joined to them, and replaces those terms by one likelihood factor over their Markov blanket (22), the integral of Proposition 23. The core computes , and and applies the change; the caller computes . The linearization computes it as follows.
Take the query of the terms alone, whose log-density is their sum: free in and in the continuous quantities of the blanket that the replacement is to depend on, and observing everything else they involve, the quantities of at their given values among them. Linearize it at a point , with the chart’s log-volume of alone, since is integrated over and is not, and eliminate the blocks of by integration, part 2 of Lemma 10, from these factors only. This is the note’s replacement (14): the terms outside stay in the model, and folding them in would count them twice. A quantity of whose type declares no volume has no reference measure to integrate against, and its retirement is refused, naming it, as is a discrete one.
Let a retirement retire the quantities , with given values and continuous, of types with a volume and of total dimension , and let be continuous quantities of its blanket , of total dimension . Let be the linearization at of the query of the terms alone, free in and and observing every other quantity, taken with the chart’s log-volume of alone, and let the columns of its rows for have rank . Then, for every ,
where has rows, with the number of components of the retired residuals less , and , , and are those of (12). Replacing the integrand of the replacement by gives approximately as this right-hand side.
If the rows have rank , the number of their columns, then the right-hand side is , with , and with the mean and the lower-triangular whitening, with a positive diagonal, of the marginal on of the normal density proportional to .
By (11) over , , with the sum of the terms of , is the logarithm of the integral over of , with the chart objective of the query above, at . The approximation replaces by its linearization .
The columns of the rows for have rank , so eliminating the blocks of one at a time, in any order, meets a nonsingular triangular block at each. Part 2 of Lemma 10, applied to each in turn, gives
where the product is over the diagonal entries of the blocks of , is the sum of their constants , and is the sum of the factors left on . This holds for every , and asks nothing of the rows on .
One reduction brings to the form stated. An orthogonal factorization of , with no pivoting and no decision of rank, leaves rows , with the number of rows of , and, when , a residual in the rows below, so that . The linear term is kept as it is, . Collecting the constants,
The number of rows, , and whether is present at all, are fixed by the terms and their types alone: is the number of components of the retired residuals less , and is present only where a log-volume is not folded or a chart’s log-volume of 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 , the matrix of is the Schur complement of a positive definite matrix, so is square and nonsingular, and , if present, lies in its row space and folds into as the note’s linear terms do. The right-hand side is then a Gaussian in with the precision and the mean , which by Corollary 13 are those of the marginal of the normal density proportional to , and integrating it over gives .
The integral of is over the whole of , while 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 , :
with 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 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:
where is the minimizer of , the triangular root of its rows, eliminated in any order, and the lower-triangular root of what is left on after is eliminated, brought to a positive diagonal as the note says. A reader that wants the mean and the scale reads them off , and 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 are linear-Gaussian, the chart objective is quadratic by Proposition 7, , nothing is approximated, and the replacement is the integral of Proposition 23, at every point . The core’s replacements (24) and (25) are two cases: retiring and , with observed, from the scalar chain gives the Kalman filter’s update and prediction, its evidence as ; retiring alone, with , gives the joint normal with , since then every term of is a normalized density of a quantity integrated or kept, and .
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 , 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 . A discrete blanket quantity is always fixed, since a free one is refused.
Filters. On a chain, retiring the oldest state with its measurement, while the next state stays, linearizes the replacement left by the previous retirement, the measurement’s term and the motion’s term, and integrates out: an update and a prediction in one, in square-root information form. Where it is taken is the caller’s choice of , and the choice is the filter.
- At the mode of the retired terms, which puts at the update’s mode and 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, the previous replacement’s mean and 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 and poses , each pose with its own prior, and measurements along known unit directions . Retiring and leaves one row on , along . Retiring and leaves a second, along . Neither determines . When and 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 , and along the directions the terms do not determine, nothing in the data says where 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 is even, so its gradient at zero is zero. The linear term of 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 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 be scored by the normal on the positive type with the mean , let the Euclidean have the prior , and retire , keeping and . The exact replacement is
In the logarithmic chart at the anchor, , it is one
squared row in and the linear term . The linearization finds exactly
this. Its rows over are the prior’s and the
term’s , and its linear term is , the gradient of . Eliminating leaves one row on , along , and the linear term , since ’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 , which has components, possibly none. Its remainder has the constant normalizer and the varying part . The linearization reads a term’s linear part through the node bound under the log-volume role, so the factor binds 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 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.
Let a query be as in Definition 3, except that a term that scores a quantity may have its scale reached from free quantities, through coordinates , and then binds the information root (8) with scale block . Its normalizer then varies with , and the scale residual below carries its gradient. For such a term, let be the Jacobian of its residual with the scale held fixed, , and let be its scale block composed with the Jacobian of the scale’s coordinates, both in the charts of the free quantities at . Let its scale residual be the vector, indexed as the rows of , with
Every other term contributes as in Definition 3, and its scale must be fixed. The query’s Fisher linearization at is
with for a term whose scale is fixed, and as in Definition 3, taken at where the scale is free, and chosen so that .
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
since its blocks are , the derivatives of at a zero residual. On the flat-in-disguise types those derivatives are everywhere, so the first block row is exactly, and ’s matrix,
is the sum of the terms’ expected information, each an expectation over its own scored quantity with its inputs at their values at . On a curved type the derivatives of 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 at zero is
The first sum and 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 as for the root, and , the negative log-density’s derivative in is
which is . So the scale’s score lies in the row space of its root, and the scale residual carries it, as carries a folded log-volume. Had the first block row used 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 , a Fisher scoring step
stops only where , at a stationary point of , 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, , the root’s scale block is in each of the diagonal rows, and the scale’s information is . The Hessian of the term in is , which at a stationary point of the scale alone, , is 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 , and the step in is , the first-order step toward .
With every scale fixed, it is the residual linearization. No term then has a scale block, every is , and , 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 , 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 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:
- a free discrete quantity, as the residual linearization does;
- 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;
- a factor that binds no residual, as the residual linearization does.
What the tests check#
- The linearization agrees with the query, (4): with the query’s log-density, with its cotangent pass, and each with finite differences of along , on Euclidean, positive and rotation quantities, at both precisions, with only the columns of nonzero.
- It is exact for linear-Gaussian terms, Proposition 7: at several , 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 .
- 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 equals the block of the inverse of .
- Damping gives the minimizer of 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
Stackedreplacements, 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 , and the sum of the two equals the replacement of retiring both poses at once, constants included, and gives the exact posterior of 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 ; 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, exactly, equals the cotangent pass of , 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 , read off the compilation graph; the others are constants of the query.
- A factor’s rows are its residual’s Jacobian, , and its right-hand side , 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 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 of its residual’s Jacobian with the scale held, and the rows 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 .
- 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: 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
Stackedreplacement’s, with the mean, the whitening and the constant of (14). It binds the residual and, where , 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
- Examples that run: Mathematics The model the examples share, a trajectory of poses on SE(3) with landmarks, odometry and sightings, generated from its own joint law and queried for the rest; a Levenberg–Marquardt method on its linearization, with its damping, schedule and stopping rule; the calibration of a Laplace approximation that data drawn from the model lets an example check; and a sliding window that retires a pose and the landmarks it alone sees at every tick.
- Linearization and elimination: Implementation Two crates, `skoro-elimination`, which eliminates factored least-squares problems in square-root form on the host, and `skoro-linearize`, which linearizes a query at a batch of points into such problems, by its residuals or by its information roots, and computes a retirement's replacement as an improper Gaussian; with the few additions to the core and the normal that they need.