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.
The problem#
skoro’s claim is that a model is built once and then answers every question asked of it: it generates data, it is estimated, its uncertainty is summarized, and parts of it are retired as they stop mattering, without the structure of the problem being written a second time for each method (the charter’s first position). The pieces that back the claim exist: the core builds, generates and queries models, the normal and the rigid motions give them their terms and their states, and linearization and elimination give steps, marginals and replacements. What does not exist is a program, outside the tests, that puts them together on a problem a reader would recognize. This entry works out two such programs, which run as examples of the library:
- A pose graph, estimated in a batch. A robot drives a closed circuit and returns near its start. It measures its own motion by odometry and the positions of landmarks relative to itself. The example finds the mode of the trajectory and the landmarks given every measurement, by a Levenberg–Marquardt method, and the Laplace approximation’s marginals there.
- A sliding window. A robot drives an open path. At each tick it adds the new pose and its measurements, solves the window, and retires the oldest pose together with the landmarks no other pose of the window sees, keeping what they said as a replacement. This is a fixed-lag smoother, and its newest pose’s marginal is a filter’s.
Both draw the truth and the measurements from the model itself, so that what an estimate should be is known, and they check it: that the estimate is a stationary point, and, in the batch, that its uncertainty is calibrated in the sense of Calibration.
What has to be worked out is what the linearization entry left to the methods that use it: the damping, the schedule and the stopping rule of a Levenberg–Marquardt method (Damping ends there), the order of a sliding window’s retirements and the point at which each is linearized, and what a calibration check can and cannot show. The library’s code for each, and whether the method is the library’s or the example’s, is the implementation’s question.
Setting#
Poses and landmarks. A pose is a point of the rigid motions , stored as a unit quaternion and a position and retracted by the left-translated chart of the rotations’ entry: turns by the stereographic chart of and moves it by along its own axes. The chart is global, so the normal is defined on it, and is its inverse (the retraction note). A pose has dimension . A landmark is a point . Composition , the inverse , the relative motion , the action on a point and its inverse are the maps of that entry’s table, each a smooth map whose chart derivatives the core computes.
The scenario. A scenario is a set of constants: a nominal trajectory of poses, the nominal positions of the landmarks, and the sightings , the pairs for which the robot measures landmark from pose . The sightings are chosen from the nominal trajectory, as the pairs within a sensor’s range of each other, , and never from the drawn truth. They are the structure of the model, and the structure is fixed before anything random is drawn: random structure lives one level up (position 2). The commands are the nominal motions between ticks. Write for the first tick at which landmark is sighted.
Scales. Every scale is a constant covariance: for the first pose, for the motion between ticks, for odometry, for a landmark about its nominal position, and for a sighting. None is estimated, so every term’s normalizer is a constant and the residual assembly applies.
The model#
The joint law of the poses , the landmarks , the odometry and the sightings is built forward, each a normal given what it depends on:
The poses and the odometry are normals on , the landmarks and the sightings normals on . Read through the chart, the motion is the commanded one followed by a random motion in the commanded pose’s frame, with on , and the odometry is the true relative motion followed by an error in its own frame. A sighting is the landmark’s position in the robot’s frame, with an error, as a range sensor that returns points would give it.
Each line is a term of the model. Writing for the negative log-density of a query that observes the odometry and the sightings, at the values and , and leaves the poses and the landmarks free, (3) gives
with the whitened residuals of (3), each the whitening of its term applied to the scored quantity less its mean in the mean’s chart: for the first pose, and likewise , , for the odometry and for a sighting, with and so on; and the log-volumes of the terms on , which the linearization folds into the right-hand sides. Every term is a normal with a fixed scale, so every term binds a residual and no linear term arises: each step of the method below is a least-squares solution.
Every direction is determined. The first pose has a prior, every later pose a motion term from its predecessor, and every landmark a prior, so the rows of the linearization have full rank at every point, whatever the sightings. No elimination of this model refuses a block, and the gauge freedom of a pose graph built from relative measurements alone, a rigid motion of the whole map, is fixed by . A landmark’s prior is broad, large against what a sighting says, so the estimate rests on the sightings wherever there are any.
Generating the truth. A draw from (1) with nothing observed is a truth and its measurements together: and , which the estimate is compared with, and and , which the query observes. A batch of rows is independent draws, each its own dataset, with one structure, so that one schedule of elimination serves every row (batch rows share the plan). Since the truth is drawn from the model, the model is right by construction, and what the examples check is the method, not the modelling.
A Levenberg–Marquardt method#
The method runs on each row of the batch separately, with its own point, damping and state, and shares with the other rows only the passes that linearize them all at once.
The start. The poses start at dead reckoning on the odometry and the landmarks at their first sighting:
Each is the location of a term of (1) solved for the quantity it scores, with the other quantities at their starts. Dead reckoning drifts, by a random walk of the odometry’s errors, so the start is worst at the end of the circuit, where the sightings of landmarks first seen near its beginning close the loop.
The damping. A step minimizes the linearization at plus , the rows of (15). The diagonal is Marquardt’s, the squared norms of the columns of the stacked rows ,
so that the damping does not depend on the units of the coordinates: a pose’s rotation in radians and a landmark’s position in metres are damped alike, and rescaling a coordinate rescales its column and its damping together. The floor keeps positive, which the note requires; in this model every column meets a prior or a motion term, so the floor never binds. is recomputed at every linearization.
The gain ratio. The step promises the decrease (8) of the undamped linearization, , and obtains . Their ratio
is one where the linearization is exact, and falls as it stops being trustworthy over the step’s length. Here is the query’s own negative log-density, log-volumes included, evaluated by one pass of the query’s program at the trial point; the linearization’s constant is not needed.
The schedule. The schedule is Nielsen’s, with and :
An accepted step with near one divides by three, one near zero keeps it, and a rejected step multiplies it by a factor that doubles with each rejection in a row. The update is continuous in , which avoids the oscillation between two values of that a rule with thresholds shows. With of (4), is dimensionless, and is a small multiple of the curvature along each coordinate, so that a start near the mode takes nearly a Gauss–Newton step.
The stopping rule. The method stops on a row when a step promises less than a tolerance, , measured in nats like itself, whether or not the step is accepted: the step is taken if its gain is positive, and the row stops either way. It refuses to call a row converged when has grown past or the iterations past a bound. The promise is the right measure: it is invariant to the coordinates of the chart, and near the mode, where is small, it approaches the Gauss–Newton decrement , the decrease of that a full Gauss–Newton step would still give. A gradient’s norm would depend on the units of the coordinates, and a step’s on the chart.
The tolerance is limited by the precision at which is evaluated. The obtained decrease in (5) is a difference of two values of , each with an error of about at a unit roundoff , while is computed from the rows themselves. For the ratio to mean anything, must stay well above , and so must . With of the order of the number of residual components, a few thousand here, double precision allows , and single precision nothing below about . The examples run in double precision.
This is why the rule does not wait for an acceptance. Once is of the order of , the obtained decrease is rounding and the gain has a random sign; a step that promises nothing has the gain . A rule that stopped only on an accepted step would meet such steps just after convergence, since Gauss–Newton contracts fast on this model and the step after one promising slightly more than promises far less. Each rejection multiplies by and doubles , so a run of some ten of them, about one chance in a thousand, would carry past and report a converged row as one that failed. Stopping on the promise alone forms no gain from rounding, and a row is never failed for having converged.
What is checked at the end. The stopping rule bounds the damped step, not the undamped one. The damped promise is at least , which bounds the Gauss–Newton decrement when is small and not when it is large, as it may be at a stop that followed rejections. So convergence is checked apart from the rule: at the final point, with , one elimination gives the Gauss–Newton step and its decrement , which must be at most a small multiple of . That is the statement that the point is stationary for , since the rows have full rank and exactly where ((6)).
The Laplace approximation and its marginals#
At the mode , , the Laplace approximation replaces the posterior by the law of , with normal of mean zero and precision from the chart linearization. On the stereographic chart’s log-volume is even, so its gradient at zero vanishes and the approximation is centred at the mode itself. Its marginal on one quantity , a pose or a landmark, is a normal in the chart at with a whitening , which elimination gives without forming the covariance (Corollary 13). The covariance omits the residuals’ curvature and the log-volumes’, with a relative error of the order of the noise’s variance (what the covariance leaves out).
The truth lies in the approximation’s credible ellipsoid of level for when its normalized error
is at most , the -quantile of the chi-squared law with as many degrees of freedom as has dimensions. Under the approximation, has exactly that law, so the ellipsoid holds probability .
Calibration#
The truth of a generated dataset is a draw from the posterior given its measurements, because the two are drawn together from the joint law. A credible set that holds the posterior’s probability therefore contains the truth with probability , over datasets drawn from the model, and an approximation of the posterior can be checked by how often its credible sets contain the truth.
Let be drawn from a joint law whose conditional law of given is the kernel , and for each let be a set with , chosen so that is measurable. Then . If , , are independent draws from the joint law, the indicators are independent Bernoulli variables of mean .
Conditioning on , almost surely, by the definition of the kernel as a regular conditional law and the measurability of the set, and taking the expectation gives . Independent pairs give independent indicators, each of mean by the first part.
∎The Laplace ellipsoid of (7) holds the exact posterior’s probability rather than , with the approximation’s error on that set, so over datasets it contains the truth with probability . The check estimates that probability and compares it with .
The expected error. The Laplace approximation is not exact here, so is not zero, and a check against alone would pass or fail according to how many datasets it is given: with enough of them, any error at all is resolved. What the error should be is known to its order. The approximation’s precision omits the residuals’ curvature and the log-volumes’, each of a relative size of the order of the noise’s variance in the curved coordinates (what the covariance leaves out); on the rotations the log-volume’s part is (the normal on these types), with the rotational standard deviation. Write for that order, with the largest rotational standard deviation of the posterior marginals. If the exact posterior’s covariance is the approximation’s times , then is times a chi-squared variable, and the ellipsoid holds
with the chi-squared density. At the slope is for and for , so the expected error is within for a pose and for a landmark. An error that is not a multiple of the covariance lies between the extremes of its eigenvalues, and is bounded the same way.
The check. Take . In row of a batch of datasets, let be the fraction of the row’s poses whose normalized error is at most . By Proposition 8 and linearity of expectation, , with the mean error over the row’s poses, whether or not the poses’ errors are dependent within a row, which they are. The rows are independent, so the mean of the has a standard error estimated by , with and the sample standard deviation of the : the floor is the resolution of one , and keeps the tolerance from collapsing when every row happens to give the same fraction. The example passes when
and likewise for the landmarks, with , in place of , and .
The two parts of the tolerance answer different things. The first is sampling: with , enough for the normal approximation to the mean of independent rows, an approximation that erred by exactly would fail with probability about . The second is the approximation’s own expected error, which is known only to its order. So that the verdict does not hinge on that order’s constant, the scenario’s scales are chosen to make it small against the first: rad gives and , a tenth or less of the sampling part when the rows’ fractions spread by a few hundredths, as fractions over a hundred correlated poses do. The check then tests the method, not the approximation. It cannot resolve a calibration error below its tolerance, and says nothing about one; it does resolve the errors a mistake would make, such as a covariance off by a tenth, which by (9) moves the coverage by . The tolerance is fixed by these figures before the example runs, not tuned to its result, and the seed makes each run of the example the same run.
Two other things are reported rather than checked: each row’s iterations, , and the decrement per step, and the start’s normalized errors beside the mode’s, which show what the sightings that close the loop recover.
A sliding window#
A window is the part of the model that a robot keeps while it drives an open path: the last poses, the landmarks they see, and replacements for what came before. The truth and the measurements are drawn, as in the batch, from (1) over the whole path; the window is a second model, built tick by tick, that observes them as they arrive.
The scenario. The path is open, and each landmark’s sightings are an interval of ticks: if and are in then so is every in between. A landmark that has left the robot’s view then never returns to it, so it can be retired as soon as no pose of the window sees it. A path that returns to where it has been would sight retired landmarks again, and closing that loop needs the batch.
A tick. At tick :
- Append. Add with its motion term from and its odometry term, the landmarks first sighted at with their priors, and the sightings , all with the observed values. Start and each new landmark at its sighting, as in (3); every other quantity starts at the window’s previous mode.
- Solve. Run the method of the previous section on the window’s query, observing its measurements and free in its poses and landmarks. From the previous mode only the new quantities are far from the new one, so few iterations are needed.
- Report. Record the mode of and its Laplace marginal: the window’s estimate of the filtering law of given the measurements up to tick .
- Retire. If the window holds more than poses, retire the oldest, with , together with every landmark that no other pose of the window sees, and with the measurements taken from : the odometry and the sightings . In the terms of the core’s retirement, the pose and the landmarks are , integrated out, and the measurements are , fixed at their observed values, which the retirement is given. Every term joined to them is replaced: the motion and odometry terms between and , the sightings from , the retired landmarks’ priors, and the replacement left by the previous retirement, which was joined to . What replaces them is one factor over their Markov blanket (22): the next pose and the landmarks joined to the retired terms that a pose of the window still sees. No measurement is in the blanket, since each is scored by one term and retires with it.
- Retired quantity
- Blanket quantity
- Other free quantity
- Factor
- has a block for
The replacement is computed as the linearization entry computes it: the query of the retired terms alone, free in the retired quantities and the blanket, linearized at a point and integrated over the retired quantities, which leaves the improper Gaussian (13) in the blanket’s tangent coordinates at that point. The retired terms determine the blanket: through its motion term from , and each landmark of the blanket through a sighting from a retired pose, which has three components. So the replacement is a proper Gaussian, as in a filter, and the retired quantities are determined in turn, by the previous replacement (or, at the first retirement, its prior) and each retired landmark by its prior and its sightings.
The motion term scores , which stays, and the retirement removes it all the same: it is joined to , and the replacement stands in for it. The window model is then left with no term that generates , which the core allows, a blanket quantity left unscored taking a proposal if the model is to generate it. The window never generates: its truth comes from the model of the whole path, and the window only queries.
The point of linearization. Each replacement is linearized once, at the window’s mode just computed in step 2, restricted to the retired quantities and the blanket. That mode uses every measurement so far, including those of the later poses, which a linearization at the mode of the retired terms alone, an iterated extended Kalman filter’s point, would ignore. The anchors of the replacement are then constants: later solves move the blanket away from them, and the factor goes on scoring it in the chart at its anchors.
What the window computes. For linear-Gaussian terms the replacement is exact (Proposition 7), each window’s posterior is the marginal of the batch posterior on the window’s quantities given the measurements so far, and the newest pose’s marginal is the Kalman filter’s. On two approximations enter. Each replacement is the linearization of an integral at a point that later moves, with an error that grows with how far the blanket moves from its anchors, against the scale on which the maps curve. And the information each replacement carries about the directions the measurements do not determine, the absolute position and heading of the whole trajectory, which only holds, is computed at its anchors, while the terms still in the window are relinearized at moving points. The exact posterior’s uncertainty in those directions grows along the path as a random walk; a replacement linearized at different points from its neighbours can claim more information there than the measurements give, which makes the window overconfident. First-estimate linearization of every term joined to a replacement is the usual remedy and costs accuracy elsewhere; this entry linearizes at the window’s mode and measures what that gives.
What is reported, and what is checked. Two figures are reported. The first is the calibration of the filtering marginals: in row , is the fraction of the ticks whose newest pose lies in its Laplace ellipsoid of level , and the report gives beside with the sampling part of (10) and the Laplace part , so that a reader sees how far outside the batch’s tolerance the window falls, if it does. The second is the gap between the window and the batch at the last tick, where both estimate the last pose from every measurement: the batch’s mode on the same path and data, and the window’s , compared in the batch marginal’s whitening,
reported row by row and as its mean over the rows. It is zero for linear-Gaussian terms, and otherwise says how far, in the batch’s standard deviations, the window’s approximations moved the estimate. What is checked is only what the mathematics guarantees of every tick: that its solve stopped at a stationary point of the window’s query, by the undamped decrement of A Levenberg–Marquardt method.
In skoro’s terms#
The quantities. The poses and the odometry are quantities of the rigid motions’ type, the landmarks and the sightings of . Each is scored by one normal term, with its mean a composite of the motions’ maps of quantities and constants. The nominal poses and landmarks, the commands, and every scale are constants of the model; the sightings are the shape of the program that builds it, a loop over constant pairs.
Generation and queries. The truth is one generation of the model with nothing observed, of rows from one key. The estimate is a density query of the same model observing the odometry and the sightings at the generated values, row by row, and free in the poses and the landmarks; the truth’s poses and landmarks are kept on the host for the check. Nothing about the model is written twice: the generation, the query, the linearization and the replacements all read the same terms.
Derivatives. Every derivative is of the query’s terms, with respect to the free poses and landmarks, in their charts: the Jacobians of the whitened residuals by one tangent pass of the linearization, and at a trial point by a pass of value alone. Nothing is differentiated with respect to a constant, and nothing to second order.
The window. The window is a second model built tick by tick by appending, which observes the generated measurements as they arrive. Each retirement removes a pose and some landmarks, with the measurements taken from the pose, given to it at their observed values row by row, and the terms joined to them, from that model, and adds the replacement the linearization computes; the query of the next tick reads the replacement as it reads any term, through its bound residual. The batch on the same path, used for the gap at the last tick, is a query of the generating model itself.
Precision and the host. The passes run on the query’s target in double precision; every elimination runs on the host, as the linearization entry has it. The method’s state, the point, and of each row, is on the host between iterations, and only the point goes back to the target.
Open questions#
None remains. One model and two scenarios, the closed circuit for the batch and the open path for the window; Marquardt’s damping with Nielsen’s schedule; a stopping rule on the promised decrease in nats, with stationarity checked apart from it; the batch’s calibration checked by (10), at a tolerance fixed by the statistics and the approximation’s expected error; each replacement linearized at the window’s mode; and the window’s calibration and its gap (11) reported, with only its stationarity checked.
Revisions#
2026-11-09: the stopping rule. The rule stopped a row only on an accepted step that promised . The implementation showed that this fails rows that have converged: with in the thousands, the step after one promising just over promises little more than the rounding of , its gain (5) has a random sign (or is for a step promising nothing), and a run of rejections carries past . The rule becomes: a row stops when a step promises , whether or not it is accepted, the step being taken if it is, with stationarity still checked apart from it by the undamped decrement. A Levenberg–Marquardt method now states the rule, says why it does not wait for an acceptance, and says why the check of stationarity at the end remains: the damped promise bounds the Gauss–Newton decrement only when is small.
Built on by
- Examples that run: Implementation Two examples of the umbrella crate, a pose graph estimated in a batch and a sliding window over an open path, sharing one model builder, with the pieces they need added to the library where a user would need them too; a Levenberg–Marquardt method in skoro-linearize, the inverse retraction of a layout and the observation of generated values in the core, and two maps of the rigid motions on the host.