Skip to content

API overview ​

Each part of the package has a short section here, with a link to the page that covers it in full. One small model shows how the parts fit together.

Some public names are not exported, so using ComposableRecurrences does not bring them in. They are written here without the package prefix, and using ComposableRecurrences: Depletion, Floor, Recent loads them. Internal names, such as ComposableRecurrences.State, keep the prefix. The neural network package Lux also exports a Recurrence, so with both loaded write ComposableRecurrences.Recurrence.

How the parts fit together ​

Recurrence computes each value from its own past values, and Convolution weights the past values of an input series. Each is built from a kernel, and a recurrence also from a coupling, which mixes the strata, and modifiers, which change each step's value. A shape sets how these coefficients vary across strata and time, and an executor sets where a call's loops run.

How kernels, couplings, modifiers, shapes, operators, calls and executors fit together

A worked example ​

The example uses gi, pop, K, seed and R from the model of Three towns, step by step. They are a generation interval, each town's population, a gravity coupling, the seed infections and the reproduction number.

julia
using ComposableRecurrences
using ComposableRecurrences: Depletion
renewal = Recurrence(
    gi; coupling = K, modifiers = (Depletion(PerStratum(pop)),)
)
infections = renewal(R; history = seed)
delay = Convolution([0.0, 0.1, 0.25, 0.3, 0.2, 0.1, 0.05])
reports = delay(infections; gain = 0.4, history = seed)
size(reports)
(3, 75)

Each part of this model has its own section below.

  • gi is the kernel of the recurrence, and the vector of delays the kernel of the convolution.

  • K is the coupling, a matrix of weights between the three towns.

  • Depletion(PerStratum(pop)) is a modifier, and PerStratum is a shape: one population per town.

  • renewal(R; history = seed) and delay(infections; ...) are calls, each returning a towns × days matrix.

A step ​

Both operators compute one step at a time; A step gives the equations.

Operators ​

Building an operator lists each operator's keywords.

Calls ​

Calls lists every call form, with what each returns.

Shapes ​

Slots and shapes says which wrapper each coefficient takes, and Data shapes gives the shapes of the gain and add.

Delay distributions ​

Delay distributions as kernels shows how a distribution becomes a kernel.

Couplings ​

Where the coupling acts lists the coupling types and where a per-stratum coefficient belongs.

Modifiers ​

Built-in modifiers lists each modifier, and Order says why their order matters.

Depletion forms ​

Depletion forms lists how a pool can give up a step's demand.

Time-series processes ​

Time-series processes writes random walks, autoregressions and moving averages as operators.

Executors ​

Executors says how to choose where loops run, and Adjoints and backends how gradients are computed.

Writing your own ​

Writing new types shows how to add a coupling, modifier or depletion form.