Mathematics
The mathematics the core rests on, from quantities, their charts and their products, through operations and their derivatives of first and second order composed over programs, to queries, terms, importance weights, random keys and retirement.
The problem#
The core is the part of skoro that every later entry builds on: the quantities a model is made of, the operations that relate them, the derivatives of those operations, the log-density a model defines, and the changes a model goes through as it is built, branched and retired. It ships no distribution, but it must be exactly right about what a distribution, an estimator or a sampler will ask of it, because each of those will trust it without checking.
This document works out that mathematics, at the level of precision the implementation needs. Most of it is standard, and the standard parts are in the math notes it depends on: retractions, automatic differentiation over frames, derivatives in tangent charts and product manifolds. What is particular to skoro, and what this document settles, is how those pieces meet the charter: which quantities are differentiated and when, what order of derivative a computation needs from each step, what selection and discrete quantities do to derivatives, what a query does to a model’s density, how random keys make draws reproducible, and what retiring a quantity means.
Setting#
A model is a set of quantities and a set of terms. Each quantity takes values in its type: a manifold of dimension with a retraction, or a countable set. Each term is a real-valued function of some of the quantities, its log-density, and the model’s log-density is their sum (the measure theory underneath is in the appendix),
For a manifold-valued quantity, and are its retraction and inverse retraction (5), and derivatives are read in tangent charts (2). A quantity’s dimension is that of its tangent space; its storage size is the number of reals that represent a point, which may be larger (a rotation has dimension and is stored as or numbers). Every flat vector of derivative coordinates in this document is indexed by dimension, never by storage.
Computation is batched: a model is evaluated at points at once, one per row of a batch. Rows never interact: an evaluation at points is independent evaluations, and every derivative below is per row. Batching is therefore absent from the mathematics, and only the implementation needs to keep it straight.
A model is two graphs over the same objects, and the rest of this document uses both. Each answers different questions, and neither is ever called simply “the graph”. The running example is a vehicle whose positions are the quantities and then , which measures a landmark once from each position, as and . Its second position is drawn from , the motion model of an inertial measurement unit (IMU), driven by the unit’s reading between the two positions. The reading is a parameter that nothing scores: it has no distribution and no prior, and a query for the positions observes it. The IMU’s model knows nothing of the platform’s own physics, how far it can plausibly move in one step, say, and that knowledge enters as a likelihood factor : a second motion model, over positions the first one already scores, whose scale is a parameter with an improper prior, the score . The example thus has a parameter with a score and one without, and shows a likelihood factor adding information about quantities already in the model, as any number of further factors could.
The probabilistic graph#
The probabilistic graph records what depends on what in distribution. Its nodes are the model’s quantities and its terms. It has an edge from each quantity a term is conditioned on to the term, and an edge from each term to the quantity it scores, if any.
- It is bipartite: every edge joins a quantity and a term.
- Each quantity is scored by at most one term: the term of the distribution it was drawn from. A quantity scored by no term is a parameter: it has no seed distribution, and an improper prior on it is a score, a likelihood factor conditioned on it (parameters). A term that scores nothing is a likelihood factor over the quantities it is conditioned on: in Bayesian terms, the likelihood of data that is not a quantity of the model, such as the measurements a retirement conditioned on. A term that scores an observed quantity is a likelihood too, but only in the queries that observe it; a likelihood factor is one in every query.
- It is acyclic, because a term is conditioned only on quantities that existed before the quantity it scores. A topological order of it is therefore an ancestral order, in which each quantity comes after everything its distribution is conditioned on.
- Its edges are read off the compilation graph below rather than declared: a term is conditioned on the quantities among the roots its log-density is reached from, other than the one it scores.
- Quantity
- Parameter
- Term scoring a quantity
- Likelihood factor
- conditions a term
- scores a quantity
The compilation graph#
The compilation graph records how values are computed. Its nodes are the model’s values: its quantities, its constants, and its mapped values, the outputs of operations, among which are the terms’ log-densities. It has an edge from each input of an operation to the operation’s output, so a node with incoming edges is a mapped value, computed from the nodes those edges come from.
- It is acyclic, because a model is built forward: an operation is added only after its inputs.
- Its roots, the nodes with no incoming edge and so no ancestor, are the quantities and the constants. They are the inputs of the map that the model computes, and every mapped value is a function of the roots it is reached from.
- A quantity is a root even when it was drawn from a distribution whose parameters are mapped values. That dependence belongs to the probabilistic graph above, not to this one, which is why no derivative ever flows through a sampler.
- Quantity
- Parameter
- Constant
- Mapped value
- A term's log-density
- input of an operation
Evaluating a model compiles a program from the compilation graph: the subgraph of the nodes from which a requested target is reached, its operations taken in a topological order. That subgraph is the program’s computation graph, and its roots are the roots of the compilation graph that the targets reach.
Quantities#
Euclidean quantities. The core’s flat types are the real line , vectors and matrices , with and . A matrix is flattened column by column into for its tangent coordinates, so its dimension equals its storage size. The dimensions , are fixed for each quantity when it is created, and every operation checks them then.
Positive quantities. Scales, rates and variances live on the positive orthant , where , with the retraction of the example in retractions, elementwise:
A tangent coordinate is a relative change, and a point is stored as its values, so its dimension equals its storage size. The positive orthant is not flat in the sense of the notes, since is not addition, but it is flat in disguise: , so the logarithm is one chart of the whole space in which every retraction is a translation. Three things follow. The retraction is defined for every and never leaves the space. The identities and both hold exactly. And the chart Hessian equals the Hessian of the pull-back everywhere, not only at stationary points: in Proposition 3, , whose derivative does not move, so the correction vanishes. What is not trivial is reading a positive quantity as a real number, through the inclusion : its derivative in charts is , which moves with the point.
Embedded types. The curved types that later entries add, a sphere for one, are most simply written as submanifolds of a coordinate space, each point stored as the vector of it is. The charter has each such type added by a crate of its own, built only on the core’s public interface (position 12), and a type that needs no kernel of its own is the one easiest to keep working as burn changes (position 11).
To every algorithm, a type is its retraction and its inverse. They make its tangent charts, and so its derivatives, its gradients and Hessians, and the steps an estimator takes. A later type must therefore choose them as its own geometry suggests, whatever form they take, and the core cannot fix one form for all types. Both are arithmetic on storage: the retraction maps a stored point and a tangent vector to a stored point, , and its inverse maps two stored points to a tangent vector, . Each is an operation on Euclidean values, which the type writes as a composite, or as a fused operation where the primitives cannot compose it (Operations in feature crates). What the type cannot write so is the boundary between itself and its storage: the inclusion , which reads a point as the vector that stores it; the retraction as an operation whose output is a point of the type rather than a vector; and, for a type that declares one, the projection , which maps a vector near the type onto it. Each changes type, so none is an operation on Euclidean values, and the derivatives of each are read in the type’s charts. The core therefore provides them once, for every embedded type: a type declared by its storage size , its dimension , its retraction and its inverse , and, optionally, a projection , again an operation on Euclidean values.
Let be a submanifold of dimension , and and smooth maps on open sets and , such that for every :
- , , whenever , and has rank ;
- for every in a neighbourhood of ;
and, optionally, a smooth map on an open set containing , with for every .
Then is a retraction on , where it is defined, with identified with by the basis , and for near . Write , the derivative of in its second argument on the diagonal. In these charts the inclusion has the derivative maps
and the retraction, as a map with , has the partial derivatives
and the second-order maps
where and are the velocities of and , and are the velocities of and in , , every is taken at , and is its derivative along . When is given, the projection , , has, with and for a velocity of , the derivative maps
where is the derivative of along .
Fix . The map takes a neighbourhood of into and to , so its derivative at maps into , and onto it, since its rank is . In the coordinates that the basis gives , which depend smoothly on because is smooth, that derivative is the identity, so is a retraction. By the inverse function theorem, is a diffeomorphism from a neighbourhood of onto a neighbourhood of in , and is a left inverse of it there, hence its inverse: .
The derivatives follow from (11). For the inclusion, has the derivative at . For the retraction, the chart at its output reads a point as , so its partial derivatives are those of and at , which are (5) by the chain rule. Both hold at every point of the domain, with the output there.
For the second order, Operations defines as the derivative of along the curves and , the output following as . The factors of are , and , each smooth on an open set of a coordinate space ( and are defined for near ), so the derivative of each along a curve depends only on the curve’s velocity in : for , for , and for , by the chain rule. The product rule then gives (4) and (6).
For the projection, the chart at reads as . The curve lies in , so its velocity is tangent there, and the derivative at is . The input of is flat, so is the derivative of at , which is (7) by the product rule, since has the velocity .
∎Every factor in (4), (5), (6) and (7) is a pass over , or , at points the forward pass computes, with a cotangent at the output of and one at the output of :
| factor | pass |
|---|---|
| , | tangent and cotangent passes over at , at its second input |
| a Hessian pass over at , with velocity at its first input and cotangent , read at its second | |
| and its transpose, | tangent, cotangent and Hessian passes over at , with velocities |
| , | tangent and cotangent passes over at , at its second input |
| a Hessian pass over at , with velocity at both inputs and cotangent , read at its second | |
| , , | tangent, cotangent and Hessian passes over at , with velocity and cotangent |
The Hessian pass over seeds both inputs because moves with both arguments of . So the core’s boundary operations are generic over embedded types: they assemble their derivative maps from passes over the type’s own operations, rather than from derivatives written by hand, and the order of each is the most those passes admit under Definition 11. The inclusion has order two when admits a Hessian pass, the retraction when and both do, and the projection when and both do; each has order one when the same operations admit first-order passes. Since is itself a derivative of , a second-order map of the inclusion or the retraction needs the second derivatives of : a type whose quantities are to have Hessians declares a retraction of order two.
Smooth as computed. The passes in the table are taken at two places in particular: over at , and over on the diagonal . Every evaluation of a boundary operation’s derivatives goes through them. Proposition 3 asks and to be smooth there, and they are, but the operations that compute them must also compute them smoothly there, which is a stronger requirement. A retraction from an exponential map, such as on the rotations, is smooth at , yet its textbook formula divides by , and the coefficients of its derivatives, and the like, divide too: computed as written, each is at , and so is every derivative taken there. A logarithm written with over does the same on the diagonal. So a type’s and must be smooth as computed at and on the diagonal, to the order the type claims. A formula with a removable singularity there switches, below a cutoff in , to a truncation of its Taylor series in , and the switch can be written in one of two places.
- Inside a fused operation’s kernels, element by element: each kernel compares with the cutoff and evaluates either the series or the closed form, never both. This is how the archive’s rotations computed their exponential and logarithm, with the tangent, cotangent and second-order maps of each, and it is the way for a type that is to be fast or precise. The type’s and are then composites around the fused exponential and logarithm, and , or fused operations themselves. Either way, the boundary operations’ passes reach the kernels’ own derivative maps, which take the series at the singularity.
- In a composite, by a discretization of and selection between the two formulas. A composite evaluates both formulas on every row, and the closed form still divides by zero on the rows where the series is selected. Selection pulls a zero cotangent back into it there, but the closed form’s own partial derivatives are there, and zero times them is undefined, which reaches ’s cotangent through the sum of its uses. So the closed form’s input must be guarded as well, by a second selection that gives it a harmless value, say, on the rows where it is not selected.
Either way, the series keeps at least the terms through for a type of order two, so that the derivatives taken at the singularity are exact, and in practice more: it must be accurate across the whole region below the cutoff, and the closed form above it, where its cancellation grows as shrinks. The archive’s exponential kept the terms through , with the cutoff at in single precision and in double. Where to switch and how many terms to keep is a matter of rounding on both sides of the cutoff, and the type’s entry’s to settle. A fused kernel’s branch is tested like the rest of it, against its composite or against finite differences, on both sides of the cutoff and at both precisions. The acceptance test’s retraction and its inverse are rational, with no such singularity.
The inverse retraction needs no boundary operation of its own, since its output is a tangent vector. It is the composite
and its derivatives are its parts’. A point of an embedded type that a model computes, rather than creates as a quantity or a constant, comes from one of the two boundary operations whose output is a point. The retraction gives it from a base point the model has, or a constant one, and a tangent vector computed in Euclidean terms, and is defined where the base point’s chart is. The projection gives it from storage computed in Euclidean terms, and is defined wherever is.
The projection is what makes a map into an embedded type as easy to write as a map into . A map between embedded types is written in storage, as an operation on the inputs’ inclusions whose values lie on , or near it, and projected:
Its derivatives in charts are then its parts’, by the chain rule: those of the inclusions, those of , which are Euclidean, and (7). The projection also returns to a value that rounding has carried off it. The composition of two rotations, for one, is the product of their matrices, projected. Without a projection, a map into a type is a retraction from a base point, valid in that point’s chart alone, or a fused operation with its derivatives in charts written by hand and checked against finite differences of (11). The projection is optional because not every type has one that the primitives compose: the projection of a matrix onto the rotations needs a singular value decomposition, so the rotations’ entry will write it as a fused operation, with a composite where one can be written.
A type often writes its retraction with a tangent basis and a projection , smooth near , onto it and the identity on it, as , which meets the conditions of Proposition 3 because is the identity on , and whose is then that same ; such a type declares that as its projection too. The core does not impose that form. The retraction of the acceptance test is not of it, and a type whose geometry suggests another retraction declares that one, and its derivatives follow all the same. The conditions are asked only of , which may be the part of a manifold that the type’s retraction covers smoothly: no basis is smooth on the whole sphere, for one, so the acceptance test’s is the sphere without a point. Where a type’s points may stray outside it, and what then happens, is that type’s entry’s question, not the core’s.
The positive orthant meets the conditions too, as an open subset of with , and , and its is . The core keeps it as a type of its own all the same, with its operations written in its logarithmic chart, where they are linear.
Discrete quantities. The core’s discrete types are the finite sets , with , and the integers . A discrete quantity has no tangent space, no retraction and no dimension, and it is never a coordinate of a derivative. Its values are written . A density over a discrete quantity is a probability mass, a density with respect to the counting measure.
Products. A product of continuous types is a continuous type: a quantity of type is one point , stored as its factors’ storage concatenated, with the stacked tangent space (1) and the factor-wise retraction of Proposition 2. The core has products of continuous types only. A quantity with a continuous part and a discrete part is two quantities, as the charter has it, and a joint density over several discrete quantities needs no product, since a term may be conditioned on any number of quantities.
A product’s factors may be of any continuous type, including products, and of dimensions known only at run time. That is what makes a product the natural type of a marginal over a Markov blanket, whose members are only known when a quantity is retired (Retirement).
Operations#
An operation is a smooth map
from continuous inputs and discrete inputs to an output , smooth in the continuous inputs for each value of the discrete ones. In the compilation graph it is a mapped node with an incoming edge from each input. Its partial derivatives are taken in tangent charts, and it may provide four maps, each over a frame of directions (automatic differentiation over frames):
| map | given | returns |
|---|---|---|
| forward | the inputs | |
| tangent | a frame per continuous input | |
| cotangent | a frame at the output | per continuous input |
| second order | velocities , and one cotangent | per input |
The second-order map takes a velocity frame of several columns, one Hessian direction each, and a single cotangent column. Its definition in charts is the one under which a forward-over-reverse pass computes the chart Hessian (2), by Proposition 4.
Discrete inputs carry no derivatives, and a discrete output carries none either. A map that turns a discrete input into a continuous output (an embedding, such as an integer read as a real) has no partial derivative in it. A map that turns a continuous input into a discrete output (a discretization, such as the indicator ) passes no cotangent back. For a step function that is the true derivative everywhere but at its steps, and the core makes no attempt to do better: a model that needs a derivative across a discretization needs a relaxation, which is a modelling choice, not the core’s.
Two gates#
A pass runs over a program’s computation graph, whose roots include the quantities it differentiates with respect to. Within a pass, an operation’s continuous inputs differ in two ways that the implementation must keep apart:
- an input is differentiable if it is reached from a root the pass differentiates with respect to, which decides whether cotangents (, and in a Hessian pass ) are pulled back into it along the backpropagation graph;
- an input carries a velocity if it is reached from a root seeded with a velocity in this pass, which decides whether its velocity enters .
The second implies the first, and not conversely: a Hessian pass is often seeded at one quantity while all of them are differentiated. An operation’s is absent whenever is not needed, and a missing velocity counts as zero.
Order#
Every operation states its order : if it provides only the forward map, if it also provides the tangent and cotangent maps, if it also provides the second-order map. Most primitives have order . An operation that runs burn’s automatic differentiation inside, such as a neural network, has order ; one whose derivative does not exist or was not written has order . What a pass needs of a step depends on where the step sits in the program’s computation graph.
Fix a pass over a program: the roots it differentiates with respect to, the roots seeded with velocities (for a Hessian pass), and the targets . A step with map is on the pass when, in the program’s computation graph, its output is continuous and reaches a target in , and one of its continuous inputs is reached from a root in . The order the pass requires of step is
The pass is admissible when for every step .
A pass that is not admissible is refused before it runs, naming a step with . This refines the charter’s “least order over the program’s steps” in two ways that matter in practice. A step that no differentiated root reaches, or that reaches no target, needs nothing, so a model may contain a first-order neural network and still be differentiated twice with respect to quantities that do not feed it. And a step that only pulls back cotangents in a Hessian pass, because no seeded velocity reaches it, needs only first order: its terms are zero by (4).
Selection#
Selection chooses one of several continuous values by a discrete index:
All the and are of one type. For each the map is a projection, so its derivatives in charts are as simple as derivatives get: since , the chart at is the chart at , and
The cotangent at goes to the selected value and nowhere else, and the index receives nothing. Mixtures, switching models and data association are built on selection: a mixture whose component is a discrete quantity reads that component’s parameters through selection, and a measurement associated by a discrete quantity selects the target it came from. The derivative with respect to the values, at a fixed index, is exactly what a gradient-based algorithm conditioned on the discrete quantities needs.
The primitives#
The core ships all of the primitive operations below, with the derivative maps they carry; those on Euclidean quantities first. In the table, is the elementwise product, the velocity of an input in a Hessian pass (or its tangent, in the tangent map), and the cotangent at the output. Each frame is handled column by column, so one column is shown.
| operation | tangent | cotangent per input | second order per input |
|---|---|---|---|
| , | |||
| (elementwise) | |||
| (elementwise) | |||
| (elementwise) | |||
| (elementwise) | |||
| (elementwise) | (13) | ||
| slice, concatenate, transpose | the same map | its adjoint | |
| select | (12) | to the selected value |
The trigonometric rows are there because the retraction that a curved type’s geometry suggests is often built from sines and cosines, and its inverse from an inverse tangent: with them, such a retraction is a composite, whose derivatives follow from the table, rather than a fused operation whose derivatives are written by hand, with no composite to fall back on while an upgrade of burn breaks its kernels. is the angle of the point , defined where is positive. Its derivatives, with the second order read off the first by differentiating and , are
squares, products and quotients taken elementwise. They hold off the half-line , , where the angle jumps by ; there the map is a discretization in the sense of Operations, and a composite that must cross it, as an inverse retraction near a half turn may, switches formulas by selection.
The operations on positive quantities read their tangents and cotangents in the charts (2), that is, in logarithmic coordinates, where all but the inclusion are linear. Here and are positive, is Euclidean, and the products, quotients and powers are elementwise.
| operation | from, to | tangent | cotangent per input | second order per input |
|---|---|---|---|---|
| as a real | ||||
The exponential and logarithm here are not the rows of the first table: those map to , read in the flat charts, where their derivatives are and ; these change type, and in the charts of the positive side their derivatives are identities. Both are kept, because a model may want either. The retraction (2) is the composite of the second and fourth rows, and its inverse of the third and a Euclidean subtraction, so every derivative of both, of either order, is an identity or zero.
Beside the rows of both tables, every embedded type has the two boundary operations of Embedded types, its inclusion and its retraction , and a third, its projection , when it declares one. Their derivative maps (4), (5), (6) and (7) are assembled from passes over the type’s own operations rather than written in a table.
Every row is checked the same way: the tangent map is the derivative of the forward map, the cotangent map its transpose, and the second-order map the derivative of the cotangent map along the velocities, holding fixed. The bilinear operations (, , ) and are the only ones whose second-order maps mix inputs: the pull-back into one input involves the other, so the other’s velocity appears. The linear ones have none. The discrete operations the core needs (integer arithmetic and comparison) and the embedding of an integer as a real carry no derivatives, by the conventions of Operations.
Programs, composites and passes#
A model is evaluated by compiling a program from the compilation graph, as in The compilation graph. Four passes run over a compiled program: the forward pass, the tangent pass (2) along the edges of its computation graph, the cotangent pass (3) along the edges of its backpropagation graph, and the Hessian pass (4), which runs both. Derivatives are collected at the program’s roots only, which are the leaves of its backpropagation graph, and Queries says which roots those are.
A composite operation is a named subgraph of the compilation graph, such as the retraction of a product, or (in later entries) a distribution’s log-density: a set of operations with designated inputs and one output, stored under one name. Its derivative maps are defined as the composition of its parts’, so expanding a composite into its parts at compilation changes no value that any pass computes, and its order is that of its parts under Definition 11. A hand-written fused form of a composite, introduced for speed or for numerical care, is a different operation with the same mathematics, and it is correct only if every pass over it agrees with every pass over the composite, to within rounding. Feature crates write such operations too, as Operations in feature crates says.
The product retraction is the composite the charter’s acceptance test is about.
Let a product’s retraction be built as the composite of slicing the point and the tangent into blocks, applying each factor’s retraction to its blocks, and concatenating the results. Then every pass over a program containing it (values, tangent frames, cotangent frames, and Hessian products) computes the same values as the factor-wise computation, block by block.
Slicing and concatenation are linear, so their tangent maps are themselves, their cotangent maps are their adjoints (scattering into a zero block and gathering a block), and their second-order maps are zero. In the tangent pass, slicing hands each factor’s retraction exactly its blocks of the frames, and concatenation stacks what they return. In the cotangent and Hessian passes, the concatenation’s adjoint hands each factor exactly its blocks of and , the factors pull them back, and the slicing’s adjoint places each result in its own block, adding only zeros. By (4), with the linear steps’ zero, the product’s is the factors’ s, stacked. So every pass computes the block-diagonal assembly of the factors’ passes, which is the derivative structure of (3).
∎The proof introduces no arithmetic beyond additions of zero, so a test may hold the agreement to a tolerance of a few units in the last place.
Operations in feature crates#
Every operation in a model is of one of three kinds, and the kind decides where it may be written.
- Primitives are the core’s alone: the operations of The primitives, with derivative maps and kernels written by hand, and the boundary operations of embedded types, whose derivative maps are assembled from passes over each type’s retraction and its inverse.
- Composites may be written anywhere, in a feature crate as in the core. They are built from other operations, their derivative maps are those of their parts by the chain rule, and they touch no tensor.
- Fused operations may be written anywhere too. A fused operation provides its forward, tangent, cotangent and second-order maps itself, as a primitive does, computed by kernels of its own over the core’s public tensor layer, and it states its order like any operation.
A fused operation is what a feature crate writes when a composite is too slow, or loses precision where the feature needs it: a bespoke kernel for the exponential of , say, or for its logarithm near angle . It owes three things.
- A reference. It names the composite it fuses, when one can be written, and every pass over it agrees with every pass over that composite, to within rounding, at both precisions. When none can, its derivative maps are checked against finite differences of (11), at both precisions, as a primitive’s are.
- Every backend. It runs on every backend skoro supports, or runs the composite it fuses on the backends its kernels do not cover.
- A name. It is registered under a name, as every operation is, so that a serialized model names it and a model read without the crate that defines it is refused, naming the operation, rather than misread.
This is what keeps the core stable as feature crates arrive. The core’s primitives are the operations every feature shares (arithmetic, exponentials and logarithms, trigonometric functions, products of matrices, slicing and selection), and no feature’s needs, however particular, add to them: what composes is a composite, and what must be faster or more careful than its composite is a fused operation in the feature’s own crate. The core changes for a feature only when the feature needs something its public interface cannot express, such as the boundary operations of embedded types, and such a change is general: it is made once, for every later feature of the kind. The cost of a fused operation falls on its own crate, whose kernels are written against the tensor layer and may need changes when burn does. A composite bounds that cost. It is a correct operation with the same mathematics, so while a fused operation’s kernels are broken by an upgrade, its feature can use the composite in its place, slower but right, and the upgrade does not wait on the feature. That is why a fused operation should have a composite whenever one can be written, and why numerical care is first sought in the composite itself, where it can often be had: a logarithm of can switch formulas near angle by a discretization of the angle and selection, whose derivatives are exact away from the switch, provided the formula not selected is guarded as Embedded types describes.
The mathematics here assumes the tensor layer is public: the tensor shapes skoro uses (batched points, tangent frames, integer values) and the operations on them that kernels need. What it exposes, and how, is the implementation’s to settle.
The acceptance test#
The charter accepts its position on products on one condition: that the retraction of a runtime product, and its first and second derivatives, agree with the factor-wise computation. On the core’s own types that is a weak test at second order. In the charts of every one of them a retraction is a translation, so every second-order map along it is zero, and the second derivatives under test are zeros on both sides. The test is therefore run on a product that includes a curved factor, and composed with a function whose second derivative does not vanish.
A sphere outside the core. The test’s curved factor is the unit sphere , of dimension and storage size , declared as an embedded type. The test is written as a later entry’s crate would be written, outside the core and with nothing but its public interface, so that it also shows a curved type being added with no derivative written by hand. The sphere is not a type of the core. skoro means to support it, but in an entry of its own, which settles what this test can leave aside: a basis for the whole sphere, the choice of retraction, and the sphere’s reference measure. When that entry adds it, the acceptance test runs on that sphere instead, and this one is removed.
The tangent plane at is . No basis of it is smooth on the whole sphere (a smooth field of tangent bases on would give a nowhere-vanishing tangent vector field, which the hairy ball theorem rules out), so the test’s basis is smooth on , the sphere without its south pole, and the tests stay inside it:
Its columns are orthogonal to and orthonormal on the sphere, as expanding with shows: the first column’s product with , for one, is . The test’s retraction is the inverse of the stereographic projection from , in coordinates scaled so that its derivative at is , and needs no projection: with ,
The retraction stays on the sphere because and give , and its derivative in at is , since is quadratic. For the inverse, the same identities give and , so and . The retraction is defined for every and reaches every point but , where its inverse is undefined. It is not of the form for the normalizing projection, which would go in the direction of rather than of , so the test exercises a retraction that the core knows only as an operation. The sphere also declares that normalizing projection, , defined where and is not a positive multiple of the south pole, which plays no part in its retraction. Each of , and is a composite of the core’s Euclidean primitives. The reciprocals are exponentials of logarithms, , , and , each logarithm taken of a number positive on the domain; the rest is products, sums, slicing and concatenation.
Unlike the core’s types, the sphere is curved: its tangent charts do not commute, the correction term of Proposition 3 is not zero away from stationary points, and the second-order maps of its boundary operations are not zero, since its basis turns as the point moves.
What it compares. The test builds a runtime product of two Euclidean factors, a real line, a positive factor and the sphere, and a nonlinear scalar function on it that reads the positive factor and the sphere as real numbers, through their inclusions. It checks, at points of :
- that every pass over the product’s retraction, values, tangent frames, cotangent frames and Hessian products, agrees with the factor-wise computation, block by block, as Proposition 14 says it must;
- that the chart gradient and the chart Hessian products of through the product’s retraction, computed by the passes, agree with the factor-wise assembly of (3), and with finite differences of their definitions (1) and (2);
- that on the sphere’s block, away from a stationary point, the chart Hessian differs from the Hessian of the pull-back by the correction term, and on every other block it does not.
The sphere’s boundary operations are checked the same way first, (4), (5), (6) and (7) against finite differences of (11), and its against the retraction it must invert, so that a failure of the acceptance test points at the product rather than at the type. The two ways into the type are checked against each other as well: the retraction, and the projection of the retraction computed in storage, , a map into the sphere written as (9) says, agree in value and in every derivative map, though one is a boundary operation and the other a composite through the projection.
Queries#
The charter puts conditioning in the query: the model holds the joint density (1), and each question asked of it says which quantities are fixed. A query partitions the quantities its targets reach in the compilation graph twice over, into observed and free, and into continuous and discrete:
- the observed quantities, continuous and discrete , fixed at values the query gives: what the query conditions on;
- the free quantities, continuous and discrete : the variables of the query, whose values are the point at which it is evaluated.
The query’s log-density is then a function of the free values,
which is, up to an additive constant, the log-density of the conditional distribution of the free quantities given the observed ones, with respect to Lebesgue measure on the continuous free quantities and counting measure on the discrete ones. One model answers many queries: with the measurements observed it is a posterior; with nothing observed, a prior to simulate from; with the states observed, a likelihood of measurements. A switching model’s mode, or the association of a measurement with the landmark it came from, is observed when it is known and free when it is not. Parameters are quantities like any other here: a query for the example’s positions observes the IMU reading along with the measurements, and either observes the scale or leaves it free, to be estimated with the positions.
Roots. The roots of a query’s program, the roots of its computation graph, are the quantities and constants its targets reach. Of these, the free continuous quantities are the ones every pass differentiates with respect to, in their tangent charts; the observed quantities, the free discrete ones and the constants are inputs no pass differentiates. A quantity’s value is an input of the query even when the quantity was drawn from a distribution whose parameters depend on other quantities, since it is a root of the compilation graph: counts ’s appearances in the terms, never its role in generating its children.
Folding. A mapped value whose inputs are all fixed is itself fixed, and need not be computed on every evaluation: it can be computed once and put in place of the subgraph that computes it, as a new root. Nothing a pass computes changes, since no derivative flows into a fixed value. A value is fixed at one of two levels, and is folded at that level.
- In the model. A value reached only from constants is the same in every query, snapshot and branch, so it is folded once, when it is added to the compilation graph, and the model keeps the result, in double precision on the host like every value it stores. A query casts it to its own precision like any other constant. Conditioning in the query does not prevent this: a constant is not a quantity, so no query can observe or free it.
- In a compiled query. A value reached from observed quantities, continuous or discrete, and from constants, is fixed only for the queries that observe those quantities, so it is folded when such a query is compiled, and reused by every evaluation of the compiled program.
A value reached from a free quantity is not folded. The difference shows in a Gaussian term written with a covariance factor , whose log-density reads its inverse and the logarithms of its diagonal (a later entry decides how the Gaussian takes its covariance). If is a constant, both are folded once in the model; if it is an observed quantity, once per compiled query; if it is free, they are computed on every evaluation, together with their derivatives with respect to .
Selection by an observed index folds further than its value. Since is , an observed makes the selection the chosen input itself, and the compiled program takes that input in its place. The inputs not chosen, and every value that reaches the program’s targets only through them, drop out of the program: a mixture with its component observed computes that component alone.
Discrete quantities in a query. Observing a discrete quantity and leaving it free give the same density at the same values, since (16) is the same sum either way. What differs is the distribution the query targets. An observed is conditioned on: the target is the distribution of the free quantities given its value, which every evaluation holds. A free is part of the target: an algorithm evaluates the density at values of it chooses (the current state of a Markov chain, or a drawn particle) and must sum or sample over them to answer for the target. Derivatives stop at discrete quantities, so the gradient of (16) at given values of is the gradient of the conditional density of given those values, not of the target. A gradient cannot sum or sample out , so a gradient-based algorithm refuses a query with a free discrete quantity (charter, position 7), rather than silently condition on the values it was given. Observing the discrete quantities is how a model that has them is given to such an algorithm.
Flattened coordinates. An estimator works with vectors, not with quantities. Ordered as the estimator chooses, the free continuous quantities are one point of the product manifold , a tangent of which is a vector , , stacked by (1). An estimator’s step is that product’s retraction,
and a Jacobian, gradient or Hessian over is the block matrix of (3). So the layout an estimator uses and a product quantity type are the same mathematical object, and the core should build them from one construction.
Terms and the importance weight#
A term is a node of the probabilistic graph. Its log-density is a node of the compilation graph, computed from the quantities it is reached from there. Following the charter, a term records the quantity it scores, , if any, and the quantities it is conditioned on, , so that reads as . The quantities a term involves, , its neighbours in the probabilistic graph, determine every structural question the core answers: which terms touch a quantity, what a quantity’s Markov blanket is, and what retiring it disturbs. They are only right if they contain every quantity depends on, so the core reads off the compilation graph, as the quantities among the roots is reached from, rather than trusting a declaration; is then without . In the example, is reached from , and (and two constants, which are not quantities), and the term scores nothing, so it is conditioned on all three: it is the likelihood factor . The motion term’s is reached from , and , and scores , so it is conditioned on and : it is the density of .
The generative reading. A distribution may provide a sampler for the quantity it scores, which draws given , with a log-density of its own; an exact sampler has (charter, position 9).
A parameter has no distribution, and so no sampler; the core supplies a proposal for it instead. A proposal is a conditional density attached to the parameter in the model, with respect to the parameter’s base measure and conditioned on quantities that existed before the parameter, from which the parameter is drawn when it is generated. It is not a term: it contributes nothing to , and enters only the weights below. Ancestral order places each parameter after its , as it places a scored quantity after the quantities its term is conditioned on. A parameter without a proposal is legal, as a distribution without a sampler is.
A query generates its free quantities, continuous and discrete, ancestrally: each scored quantity from the sampler of the term that scores it, and each parameter from its proposal, in a topological order of the probabilistic graph. In this section, stands for all of them, included, for all the observed quantities, included, and for the parameters among the free ones. Generation is possible exactly when every free quantity is scored by a term with a sampler or is a parameter with a proposal; it is refused otherwise, naming a quantity that is neither. The importance weight of a generated point is
which is the charter’s (1), with the observed quantities’ terms, the likelihood factors and the parameters’ scores, the likelihoods of this query, contributing alone, each term whose sampler is exact cancelling, and each free parameter contributing its proposal. An optimizer generates nothing, and needs a starting value for each free parameter instead: the query gives one, or it is drawn from the parameter’s proposal.
Let a query leave the quantities free and fix , each of them continuous or discrete, with the product of the free quantities’ base measures, and suppose that every free quantity is either scored by exactly one term, whose sampler has density , or is a parameter with a proposal of density ; that every one of these densities is positive wherever the query’s density is; and that each pair of densities is with respect to the same base measure. If is drawn ancestrally, then for every with ,
When the model has no parameters, the right side is times the marginal density of at . In general it is whenever is finite and positive, with the query’s target normalized, which a score of a parameter may prevent.
Ancestral generation draws with density with respect to the product of the base measures, since each free quantity is drawn given quantities drawn or fixed before it. Then wherever , which covers the set where by the positivity condition, and . When is finite and positive, is a probability measure, and the integral is .
∎Two conditions in the statement are the core’s to check or to state. The base measures must match. In the core, a continuous quantity’s density is with respect to Lebesgue measure on the space its values lie in, or the open subset of it, and a discrete quantity’s with respect to counting measure, so this holds as long as every distribution keeps to that convention. The one place it is easy to break is a density written in the logarithmic chart of a positive quantity, such as a log-normal written as a normal in . If is the density of with respect to Lebesgue measure on , the density of with respect to Lebesgue measure on carries the Jacobian of the chart,
Densities on manifolds without such a chart will need a base measure of their own when the first of them arrives. Positivity is the distribution’s responsibility, and the core cannot check it.
Random keys#
Every draw comes from a key (charter, position 10). Mathematically a key is an element of a finite set , with two deterministic maps: , and , which folds in one address segment from the set of names and integers. The key of the quantity at address in a run with key is
and its sampler turns into the uniform variates it consumes. Because depends on and alone, a quantity’s draw does not depend on the order in which the model was built, on what was retired before it, or on which branch holds it, and a namespace’s keys share the prefix of folds that the namespace’s own address determines.
The independence of draws rests on an idealization: that and behave as a pseudorandom function, so that distinct addresses yield keys
indistinguishable from independent uniform ones. Two things the core must ensure for that to mean
anything. Distinct addresses must give distinct inputs: each segment’s encoding must be injective
and tagged by its kind, so that the name "3" and the integer differ, and folding segment by
segment, rather than hashing a concatenated string, rules out collisions such as ab/c against a/bc. And each batch row of a run must have its own run key, split from the run’s, so that rows
are independent.
Because the uniform variates are drawn on the host from the key and then converted to the precision a query computes in, one key gives the same draws at single and double precision, up to the rounding of the conversion.
Retirement#
Retiring is the one change that shrinks a model: a set of quantities is removed, and what they said about the rest is kept. The quantities are named by their addresses: a retirement is given a collection of addresses, and retires the quantities at those addresses. A namespace is one way of writing such a collection, the addresses that have its own address as a proper prefix, and is the natural one when a tick leaves a sliding window; but the mathematics below asks nothing of ’s addresses, and the collection need not be a namespace. A tick’s sub-model may create a quantity that should outlive the tick, such as a landmark first seen in it, which is then left out of the tick’s collection. A fixed-lag smoother may retire a tick’s states but keep its measurements for a later query to observe. And several ticks may be retired together, which, once the replacement is approximated, is not the same as retiring them one after another (below).
Retirement is read on the probabilistic graph. Let be the quantities to retire, the terms joined to any of them (), and
their Markov blanket: the other quantities joined to those terms. In the example, retiring the first tick, , touches the terms , , and , and its blanket is : both parameters join it, because the motion model and the likelihood factor they condition are among the terms replaced. The score of is not touched, and stays.
Retirement must condition as well as marginalize. The quantities retired with a tick are often its measurements as well as its states, and integrating the measurements out of the joint would discard exactly the information a sliding window keeps them for. So the quantities of split into those fixed at given values, (usually the measurements, with the values the estimator observed), and those integrated out, . Since conditioning belongs to the query, the values of are given to the retirement itself, and once retired they become part of the model: what remains is the joint of the remaining quantities given those values. Only a quantity of can be given a value: one outside stays in the model, where a query observes it.
Let be the quantities to retire, of which are fixed at given values and are integrated out, let be the terms joined to a quantity of in the probabilistic graph, and let be the other quantities joined to those terms. Replace the terms by the single term
Then, as a function of every quantity outside , the new model’s density equals the old model’s density with integrated out and fixed at its values.
Split (1) into the terms of , which involve only and , and the rest, which involve no quantity of . Fixing and integrating over , the second group comes out of the integral as a constant factor, by Tonelli’s theorem for the non-negative integrand, and what remains of the first group is .
∎The replacement must be computed from the terms alone. Computing the marginal of the whole model on instead would fold in the terms outside , which the model still holds, and count them twice. The integral defining rarely has a closed form. It has one for linear-Gaussian terms, where retiring the oldest state of a chain is the update-and-predict step of a Kalman filter; otherwise it is approximated, by a Laplace approximation at the current estimate in the archive’s sliding windows. Either way, computing it needs the distributions and the linear algebra of later entries, which the core does not have.
Retiring together and one after another. Proposition 23 holds for any , so retiring and then a disjoint can be compared with retiring at once. With exact replacements they agree: the first replacement is a term of the model when the second retirement reads it, and integrating over and then over is integrating over both, by Tonelli’s theorem. With approximate replacements they do not, in general. A Laplace approximation of the second retirement is taken of a density that already contains the approximation of the first, and the result differs from the Laplace approximation of the joint integral, as marginalizing in steps differs from marginalizing at once. The difference vanishes when the two retirements share no term, . Then no quantity of lies in the blanket of , since a term joined to it would be in both sets; the first replacement is not reached from ; and the joint integral is the product of the two. Retiring a collection at once is then the choice of the caller who wants one approximation of the whole, rather than a sequence of approximations.
What the core does. The core retires; it does not compute the replacement. A retirement is given a collection of addresses and the values of , and goes in three steps.
- The core reads , the quantities at the given addresses, and ; it refuses an address at which there is no quantity, and a value given for a quantity outside . It reads off the probabilistic graph, and by (22). It hands these to the caller with the values of : the terms with their log-densities in the compilation graph, and the blanket’s quantities with their types.
- The caller builds the replacement , a likelihood factor added to the compilation graph as any term’s log-density is, from the quantities of and constants: exactly the integral of Proposition 23, or an approximation of it, as the caller chooses. When it is one density over the blanket’s tangent coordinates jointly, its natural type is the product of the blanket’s types. The caller may also give a proposal for each blanket quantity the retirement leaves unscored (below).
- The core checks the replacement and applies the change. It refuses a replacement reached from a quantity outside , read off the compilation graph as every term’s is: one reached from a quantity of would be removed with it, and one reached from a quantity outside the blanket would add a dependence the retired terms did not have. Otherwise it removes , the terms and the mapped values reached from , and adds , in one change: no reader of the model sees it partly retired.
An empty collection is not an error, since a window that no tick has yet left retires nothing: , and are empty, the integral of Proposition 23 is over a single point and equals , and the core makes no change.
The core cannot check that the replacement is the integral it stands for, or how good an approximation of it is; that is the caller’s to answer for. When it is exact, every query of the new model has the density of the corresponding query of the old one, with integrated out and fixed, by Proposition 23.
Two consequences for the rest of the model:
- Mapped values. Retirement removes the quantities , the terms , and exactly the mapped values reached from in the compilation graph; every other node stays, whatever its address. The given addresses select and nothing else. Removal is safe because every node reached from is a mapped value reached from or the log-density of a term in : a term whose log-density is reached from a quantity of has that quantity among . In the example, the step of the compilation graph above is reached from , and goes with it, as does every value between it and . A mapped value reached from that a user holds as a target is removed with the rest, and is no longer available after the retirement.
- Blanket quantities may become parameters. A blanket quantity whose scoring term was in ( in the example, whose motion model was conditioned on ) is scored by no term afterwards, and so, by the definition in The probabilistic graph, it is a parameter. That changes nothing a query computes. Proposition 23 holds at every value of it; the replacement is conditioned on it, as a score is conditioned on a parameter with an improper prior; and a query leaves it free or observes it as before. Its uncertainty is a matter of the query’s target, not of the quantity’s kind, and is what it was. In the measure theory of parameters and improper priors, the new model is a family indexed by it, and is its score: for linear-Gaussian terms, the Kalman filter’s predicted density of times a constant, a proper prior written as a score. What changes is generation, as for every parameter: the quantity is drawn from a proposal when it has one, which the caller may give with the replacement, and generation is refused for it otherwise. With the Kalman prediction as its proposal, and the proposal’s log-density cancel in the weight (18) up to a constant, so the draw is as good as an exact sampler’s. The core never writes a replacement in generative form, as a term scoring a blanket quantity with a sampler: a proposal gives generation all it needs.
Testing retirement. The core’s tests exercise retirement on a model whose replacement is known in closed form. A private normal distribution with constant variance, written in the tests as a composite like the sphere of the acceptance test, builds a scalar chain
with constants , , and . Retiring with observed at touches the terms of , and , and its blanket is . Completing the square in gives the update , and integrating the motion against it gives the prediction, so that
with the normal density of mean and variance at . The tests check:
that , and are as above, and that exactly the nodes the rule for mapped values names are removed;
that a replacement reached from , or from a quantity outside the blanket, is refused, and leaves the model as it was;
that with (24) as the replacement, the new model’s log-density and the derivatives of a query free in agree, constants included, with the old model’s with integrated out by quadrature and fixed at , as Proposition 23 says they must;
that generation is refused for without a proposal, and that with the proposal every generated point has the same weight, the evidence ;
that a collection holding part of a tick is retired by the same rule. Retiring alone, with nothing observed, touches the same three terms, and its blanket is , both of which become parameters. The integral is the joint normal density of and ,
(25)and with it as the replacement, a query that observes at and is free in has the log-density and derivatives of the model retired by (24), constants included: conditioning the joint normal on gives . Conditioning in the retirement and conditioning in the query agree, as they must.
In skoro’s terms#
- Quantities are Euclidean (real, vector, matrix), positive (, with the retraction (2)), and discrete (categorical, boolean, integer), and products of continuous quantities. Later entries add curved types as embedded types, each declared by its retraction and that retraction’s inverse, written as operations on storage, in whatever form the type’s geometry suggests and smooth as computed at the identity of its charts, and optionally by a projection onto it. The core provides their boundary operations, the inclusion, the retraction and the projection, whose derivatives follow by Proposition 3 from passes over the declared operations. A map into an embedded type is written in storage and projected, (9). Dimensions are fixed when a quantity is created, and every derivative coordinate is indexed by tangent dimension.
- The compilation graph holds values and operations, and programs are compiled from it; the probabilistic graph holds quantities and terms, and is read off the compilation graph and each term’s scored quantity.
- Operations are maps (10) with up to four derivative maps over frames, each with an order. The core’s primitives are those of The primitives and the boundary operations of embedded types; every other operation, the product’s retraction included, is a composite of them or a fused operation, which a feature crate may write over the core’s tensor layer, tested against the composite it fuses.
- Folding replaces a value reached only from fixed inputs with a root: in the model when they are constants, in a compiled query when they include observed quantities.
- Passes are the forward, tangent, cotangent and Hessian passes over a compiled program, differentiating with respect to a query’s free continuous quantities in their charts, refused before running when not admissible by Definition 11.
- The density is the sum of terms (1). A query fixes the observed quantities, continuous and discrete, and its density (16) is a function of the free ones, differentiated in the continuous ones alone. Generation is ancestral, from the samplers of scored quantities and the proposals the core supplies for parameters, and its weight is (18).
- Random keys are derived from addresses by (21).
- Retirement removes the quantities at a given collection of addresses, of which a namespace is one example, conditioning on the given values of and integrating out , and replaces the terms with one likelihood factor over the blanket (22). The core computes , and , checks the replacement and applies the change; the caller computes the replacement. A blanket quantity left unscored becomes a parameter, generated from a proposal the caller may give.
Appendix: the probability space of a model#
A skoro model is a model built forward in the sense of models built forward, for the measure theorist, and every object in this document has a place in that note’s measure theory.
- Quantities are the coordinates. Each quantity lives in a space with a reference measure: Lebesgue measure on and and on the open subset , counting measure on and on , and product measures on products. The probability space can be taken to be the product of the quantities’ spaces, with the quantities as its coordinates, and the probabilistic graph’s ancestral order as the order in which they were built.
- Terms are conditional densities. A term that scores a quantity has, as its , that quantity’s conditional density given those it is conditioned on, so (1) is the logarithm of the joint density of Proposition 5. A likelihood factor is the change of measure of Proposition 10.
- Mapped values are functions of the quantities, and by Lemma 7 they are all the random variables a model can express. Each is determined by the quantities it is computed from, so it is generated with them and weighed through them, and needs no term of its own.
- A query conditions by dividing densities. Its log-density (16) is that of the regular conditional distribution of Proposition 9, up to an additive constant, which is why a query may drop it.
- Every number an algorithm estimates is an integral against the joint density, by Corollary 8: an expectation, a marginal, the evidence. Generation draws from the conditional densities in the order the model was built, which is Ionescu-Tulcea’s construction, and importance weighting (18) estimates such an integral from those draws.
- Retirement integrates and conditions. Proposition 23 integrates the retired free quantities out of the terms that touch them and conditions on the retired observed ones, which is the same marginalization and the same division of densities, carried out once and kept.
An embedded type, such as the acceptance test’s sphere, has no reference measure in this sense, since it is not an open subset of a coordinate space; the sphere carries no density in the core’s tests. Manifold-valued quantities beyond the positive orthant will need reference measures of their own (surface measure on a sphere, Haar measure on the rotations) when they arrive.
Open questions#
None remain.
Revisions#
2026-10-14. Reopened because an embedded type’s retraction was fixed as , so a type could not declare a retraction of another form, such as on the rotations. An embedded type is now declared by its retraction and its inverse alone, written as operations on storage in any form, and the core’s boundary operations are the inclusion and the retraction itself, whose derivative maps Proposition 3 assembles from passes over and . The tangent basis is now the derivative of the retraction, and need no longer be orthonormal, since the inverse retraction supplies the derivative of the chart at the output. The acceptance test’s sphere now uses a retraction that is not a projection. The elementwise sine, cosine and two-argument inverse tangent were added to the primitives, so that retractions built from them can be composites. An optional projection and optional closed forms of and were considered during the reopening and left out: the projection has no use in the core and can be added later without changing a declared type, and the closed forms are derivatives written by hand, a second path to every boundary factor, whose only benefit is speed no measurement has yet asked for. What they would have avoided, the removable singularity of an exponential map’s formula at , is ruled out by a requirement instead: a type’s and must be smooth as computed there.
2026-10-15. Reopened because a map into an embedded type, written by a feature crate, can reach the type only through the retraction from a base point it already has, valid in that point’s chart alone, while the natural way to write most such maps is in storage. The projection from storage onto the type, left out at the previous reopening, is restored as an optional declaration , with its boundary operation , whose derivative maps (7) the core assembles from passes over and . A map into an embedded type is now written in storage and projected, (9), with its derivatives in charts following by the chain rule. The acceptance test’s sphere declares the normalizing projection, and the test checks that its two ways into the type, the retraction and the projection of the retraction computed in storage, agree.
2026-10-29. Reopened because a retirement was given a namespace, and so could remove only the quantities under one address prefix, where it should be given any collection of addresses: the quantities to retire need not share a prefix, and a namespace becomes one way among others of naming them. A retirement is now given a collection of addresses and retires the quantities at them; a namespace is the collection of the addresses under it. Nothing in Proposition 23, the blanket or the rule for mapped values depended on sharing a prefix, so they are unchanged. Three things were added. The core refuses an address at which there is no quantity and a value given for a quantity outside , and an empty collection changes nothing. Retiring two collections one after another is compared with retiring their union at once: the two agree when the replacements are exact or the retirements share no term, and differ in general when the replacements are approximated, which is a reason to allow collections of any shape. And a fifth test retires alone, which is part of a tick rather than all of it, with the joint normal replacement (25), and checks that observing in the query then agrees with observing it in the retirement.
Built on by
- Observed quaternions of arbitrary sign on outside data: Mathematics A unit quaternion names a rotation twice, and the stereographic chart of the unit quaternions tells the two names apart, so that a measurement given with the wrong sign is misread; the rotations, the rigid motions and the extended poses become the groups themselves, stored as quaternions up to sign under the Cayley chart, which cannot tell the signs apart, and the core learns to declare a type stored up to a finite group.
- Free the constants a retirement leaves with no consumer: Mathematics Which nodes of the compilation graph a retirement leaves needed by nothing, why removing them changes no query, and why reference counting finds exactly those nodes, since the graph is acyclic.
- 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: 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.
- Improper Gaussian replacements: Mathematics The improper Gaussian factor, a sum of squared affine rows of any number, a linear term and a constant in the stacked tangent of a retirement's blanket at constant anchors, which keeps what retired terms say about blanket quantities they do not determine, adds across retirements, and is the normal's Stacked replacement when it is of full rank.
- Improper Gaussian replacements: Implementation The improper Gaussian factor as `Stacked::improper` in skoro-normal, a builder of its rows, right-hand side, linear part and constant over a stacked tangent, which gives a retirement's replacement or a likelihood factor with its residual and its linear part bound, and the core's support, through every pass, for the values of no entries that a factor of no rows needs.
- Rotations and rigid motions: Mathematics The rotations as unit quaternions with the stereographic chart, global and full with a declared volume so that they carry the normal, the rigid motions SE(3) and SE₂(3) as their semidirect products with the left-translated chart, and the usual maps of all three, each a composite of the core's operations.
- Normal distributions: Mathematics skoro's one normal distribution, the law of a point moved by normal noise through its chart, defined on every space whose chart is global and whose volume is known, so that flat, positive and curved quantities alike, measurements among them, are drawn and scored exactly; with its scale, its sampler, its properties, its expected information, its roles, and its use as a likelihood factor.
- Reference measures and chart volumes of spaces: Mathematics Every continuous type of the core gets a reference measure and the log-volume of its retraction's chart, Lebesgue measure with log-volumes and on the core's own types, the measure the retraction normalizes on an embedded type that declares its chart's domain and log-volume, and sums over products; a type that declares none has no densities.
- The core: Implementation Three crates (skoro-tensor, skoro-core and skoro) in which a model is built inside a writer's scope from typed quantities and operations, read as two graphs, compiled per query for a device and a precision, and differentiated to second order in tangent charts.