Internal Documentation
Documentation for ComposableTuringIDModels's internal interface.
Contents
Index
ComposableTuringIDModels.ARStepComposableTuringIDModels.AbstractAccumulationStepComposableTuringIDModels.AbstractBroadcastRuleComposableTuringIDModels.AbstractConstantRenewalStepComposableTuringIDModels.AbstractIDMethodComposableTuringIDModels.AbstractIDSamplingMethodComposableTuringIDModels.AbstractRenewalModifierComposableTuringIDModels.ConstantRenewalStepComposableTuringIDModels.ImportedRateComposableTuringIDModels.LDStepComposableTuringIDModels.MAStepComposableTuringIDModels.PriorLikeComposableTuringIDModels.RWStepComposableTuringIDModels.SafeIntValuedComposableTuringIDModels.TVARStepComposableTuringIDModels.TimeVaryingLDStepComposableTuringIDModels._atComposableTuringIDModels.hsgp_basisComposableTuringIDModels.neg_MGFComposableTuringIDModels.remake_ode_problemComposableTuringIDModels.renewal_foi
Internal API
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).
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).
ComposableTuringIDModels.AbstractConstantRenewalStep Type
Abstract supertype for renewal accumulation steps (constant generation interval, with or without susceptible depletion).
sourceComposableTuringIDModels.AbstractIDMethod Type
Abstract supertype for inference / generative-modelling methods.
sourceComposableTuringIDModels.AbstractIDSamplingMethod Type
Abstract supertype for sampling-based methods (e.g. NUTS).
sourceComposableTuringIDModels.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)— aDynamicPPL.Modelreturning the modifier used in the scan. The default method samples nothing and returnsmodunchanged, 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 throughas_turing_submodel, and returns a resolved scan modifier holding the drawn values — e.g.ImportedCasesresolves to anImportedRateand 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.
ComposableTuringIDModels.ConstantRenewalStep Type
Renewal step with a constant generation interval (stored reversed).
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 _at (a constant rate stays a scalar).
Fields
rate: the positive importation rate, constant or one value per time.
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.
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.
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 get_state prepends the seed ρ stays scalar (no per-step allocation), matching the efficiency of a constant AR(1).
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.
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).
ComposableTuringIDModels.hsgp_basis Function
Build the Hilbert-space GP basis for n evenly spaced inputs.
Returns (Φ, sqrt_λ) where Φ is the sqrt_λ is the length-m vector of m) meaningful across series lengths: 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 n = 1 would give NaN.
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
using ComposableTuringIDModels
ComposableTuringIDModels.neg_MGF(0.1, [0.2, 0.3, 0.5])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 (theODEProcess'sparamsfield).prob: the templateODEProblemto rebuild.u0: the sampled initial state vector.p: the sampled parameter vector.
ComposableTuringIDModels.renewal_foi Function
Force of infection for a constant-generation-interval renewal step: the reproduction number
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.