Skip to content

Internal Documentation ​

Documentation for ComposableTuringIDModels's internal interface.

Contents ​

Index ​

Internal API ​

ComposableTuringIDModels.ARStep Type

Autoregressive step for use with accumulate_scan.

source
ComposableTuringIDModels.AbstractAccumulationStep Type

Abstract supertype for accumulation step structs used with accumulate_scan.

A concrete AbstractAccumulationStep is a callable (step)(state, ϵ) returning the next state. It is backend-agnostic: it contains no Turing/DynamicPPL machinery and is reused unchanged across model components (RandomWalk, AR, MA, LatentDelay).

source
ComposableTuringIDModels.AbstractBroadcastRule Type

Abstract supertype for broadcast rules used by BroadcastLatentModel. A rule defines broadcast_n (how long an inner series to generate) and broadcast_rule (how to expand it to length n).

source
ComposableTuringIDModels.AbstractConstantRenewalStep Type

Abstract supertype for renewal accumulation steps (constant generation interval, with or without susceptible depletion).

source
ComposableTuringIDModels.AbstractIDMethod Type

Abstract supertype for inference / generative-modelling methods.

source
ComposableTuringIDModels.AbstractIDSamplingMethod Type

Abstract supertype for sampling-based methods (e.g. NUTS).

source
ComposableTuringIDModels.AbstractRenewalModifier Type

Abstract supertype for renewal modifiers composed onto a RenewalStep.

The type covers two shapes. A scan modifier is called by the scan itself: it transforms the proposed new incidence and carries its own substate. It implements

  • modifier_init_state(mod) — the modifier's initial substate.

  • apply_modifier(mod, incidence, substate) — return (new_incidence, new_substate).

A prior-carrying modifier instead needs parameters sampled before the scan — a per-time importation rate, say — which the scan cannot draw, because a scan step is a plain deterministic function. It implements the other part of the interface:

  • as_turing_model(mod, n) — a DynamicPPL.Model returning the modifier used in the scan. The default method samples nothing and returns mod unchanged, so a purely deterministic modifier (e.g. SusceptibleDepletion(1000.0)) is a scan modifier and implements nothing extra. A prior-carrying modifier implements this method, draws its slots through as_turing_submodel, and returns a resolved scan modifier holding the drawn values — e.g. ImportedCases resolves to an ImportedRate and implements no scan interface of its own.

RenewalStep resolves its whole modifier tuple through this one seam (see its as_turing_model method), so a sampling modifier needs no special handling anywhere in the renewal model. A prior-carrying modifier reaching the scan means the step was built by hand and never resolved, so the scan interface errors with that message rather than a bare MethodError.

Each modifier's sampled variables are prefixed by its position in the modifier tuple, modifier_<i>, so two modifiers of the same kind cannot collide on a variable name — in Renewal(gen_int, SusceptibleDepletion(N), ImportedCases(Normal())) the importation rate is modifier_2.import_rates. Inserting or reordering a modifier therefore renames the variables of every modifier after it.

source
ComposableTuringIDModels.ConstantRenewalStep Type

Renewal step with a constant generation interval (stored reversed).

source
ComposableTuringIDModels.ImportedRate Type

A resolved ImportedCases: the drawn importation rate, ready to scan.

This is what ImportedCases returns from its pre-scan as_turing_model seam — the prior has been sampled and transformed, so the scan sees a plain deterministic modifier. Its substate is the step counter, so step adds read with _at (a constant rate stays a scalar).

Fields

  • rate: the positive importation rate, constant or one value per time.
source
ComposableTuringIDModels.LDStep Type

LatentDelay step for use with accumulate_scan.

source
ComposableTuringIDModels.MAStep Type

Moving-average step for use with accumulate_scan.

source
ComposableTuringIDModels.PriorLike Type

The types accepted in a prior / process slot: a raw Distribution, a vector of Distributions, or an AbstractPriorModel (a latent process used as a prior). Bounding a widened slot to PriorLike keeps the fail-fast role guard — a wrong-role component (an observation or infection model) is rejected at construction — while accepting a bare distribution alongside a process.

source
ComposableTuringIDModels.RWStep Type

Random walk step for use with accumulate_scan.

source
ComposableTuringIDModels.SafeIntValued Type

A value-support tag for real-valued count distributions whose eltype must stay integer-typed inside a Turing model even when rand is called.

source
ComposableTuringIDModels.TVARStep Type

Order-1 AR step for use with accumulate_scan.

The damping coefficient is read per step via _at, so the same step serves both a constant coefficient (a scalar ρ, drawn from a Distribution prior) and a time-varying coefficient path (a vector ρ, drawn from a process prior):

Each element of the driving sequence is a (t, ϵ_t) pair; the state is the scalar previous value and the default get_state prepends the seed . A scalar ρ stays scalar (no per-step allocation), matching the efficiency of a constant AR(1).

source
ComposableTuringIDModels.TimeVaryingLDStep Type

Time-varying LatentDelay step for use with accumulate_scan.

The time-invariant LDStep holds one reversed delay kernel and applies it at every step. TimeVaryingLDStep instead reads a fresh reversed kernel from the scan input at each step, so the delay can vary with time:

with rev_pmf_t supplied through the driving tuple input = (ϵ, rev_pmf_t). The window slides exactly as in LDStep (drop the oldest entry, append ϵ), so all kernels must share the same length d (a constant convolution window). When every kernel is identical this reduces exactly to LDStep.

source
ComposableTuringIDModels._at Function

Read a possibly-time-varying parameter at step t.

A scalar (a constant parameter, drawn from a Distribution prior through the single as_turing_submodel seam) is returned unchanged at every step; a vector (a per-step path, drawn from a process prior) is indexed at t. A component's recursion writes _at(ρ, t) * … so the same code serves a constant and a time-varying parameter — the scalar branch is zero-cost (no per-step allocation).

source
ComposableTuringIDModels.hsgp_basis Function

Build the Hilbert-space GP basis for n evenly spaced inputs.

Returns (Φ, sqrt_λ) where Φ is the   matrix of eigenfunctions evaluated at the standardised inputs and sqrt_λ is the length-m vector of . The integer indices   are standardised to zero mean and unit standard deviation, so the length scale is scale-free: the half-range   approaches as grows rather than scaling like  , and the GP is approximated on   with  . Standardising keeps a fixed prior (and a fixed m) meaningful across series lengths: is measured in standard deviations of the inputs, not raw time steps. Both outputs depend only on n, m and c — none of the sampled parameters — so HilbertSpaceGP calls this once per model construction rather than from inside the @model body; see HilbertSpaceGP for what that leaves when the GP is composed inside another model. Requires n > 1 so the standard deviation (and hence ) is positive; n = 1 would give    and a basis of NaN.

source
ComposableTuringIDModels.neg_MGF Function

Negative moment generating function of a discrete generation interval w at rate r: .

Arguments

  • r: the exponential growth rate.

  • w: the discrete generation interval weights.

Examples

@example
using ComposableTuringIDModels
ComposableTuringIDModels.neg_MGF(0.1, [0.2, 0.3, 0.5])
source
ComposableTuringIDModels.remake_ode_problem Function

Rebuild an ODEProcess's ODEProblem with freshly sampled state u0 and parameters p.

This is the single seam through which ODEProcess re-instantiates its problem on every sample. The default applies the plain-vector remake(prob; u0, p) that the hand-coded SIRParams / SEIRParams problems expect.

Parameter models whose problem stores parameters differently — e.g. a ModelingToolkit/Catalyst-built problem carrying a structured MTKParameters object plus an initialization system — specialise this on their own type to inject the remake form they need. The Catalyst extension uses the plain-vector build_initializeprob = false path to bypass the init system (and stay reverse-mode differentiable). Dispatching on the parameter model keeps ODEProcess itself backend-agnostic.

Arguments

  • params: the ODE parameter model (the ODEProcess's params field).

  • prob: the template ODEProblem to rebuild.

  • u0: the sampled initial state vector.

  • p: the sampled parameter vector.

source
ComposableTuringIDModels.renewal_foi Function

Force of infection for a constant-generation-interval renewal step: the reproduction number times the convolution of the recent incidence window with the (reversed) generation interval,

This is the raw new-incidence term before any modifier (e.g. susceptible depletion) is applied. It is shared by the internal ConstantRenewalStep core and the composable RenewalStep so the two cannot drift.

source