Repository navigation
Description
Before building a windowed latent modifier, establish what the existing latent-modifier machinery can already express and confirm that a windowed effect is genuinely out of reach.
There is existing machinery for composing and modifying a latent process, so the investigation is to pin down exactly what a latent modifier can currently do and where applying an effect only within a declared index window is not yet expressible.
A satisfactory answer either shows the effect is already reachable by composing existing modifiers (no new type needed), or identifies the specific gap that a new windowed modifier would fill and confirms it fits the documented type structure.
Rationale
Check what already exists before building.
The design reasoning below is plausible but rests on that check: the role supertypes are documented as the only type structure, and a process owns its parameter path internally, so a component that wrapped a process and reached into its parameters would break both invariants.
A latent modifier looks like the natural home, since modifiers are latent models themselves.
If the check finds a real gap, the feature is a windowed modifier in the latent-model family: it wraps a latent process and applies an effect to its path only within a declared index window.
Because latent modifiers wrap into latent models, several stack by ordinary nesting, their combined effect is the documented composition of the wrapped effects, and they appear as named branches in the model tree printout with no extra machinery.
The effect slot should get the same treatment other modifiers give theirs, so it accepts a constant multiplier, a callable, or a latent process for an uncertain effect size.
A scenario comparison then becomes a change of modifier stack around the same process rather than a rebuild of the latent path.
Value / effort
Value high · Effort medium · Verdict investigation first (confirm the gap before building).
Illustrative example
using ComposableTuringIDModels, Distributions
# Existing latent modifiers wrap an inner latent model and return a latent
# model, so they nest by ordinary composition. TransformLatentModel applies
# an effect to the WHOLE path:
inner = RandomWalk(Normal(0, 0.1), HalfNormal(0.05))
whole = TransformLatentModel(inner, x -> x .+ 0.5) # shifts every index
# Investigation question: can an effect confined to an index window
# (say indices 10:20) be expressed by composing existing modifiers, or is
# there no modifier that reads the index and gates the effect?
# --- Desired usage if the check finds a real gap ---
# A windowed modifier in the same family, effect applied only within a
# declared window, with the effect slot accepting a constant, a callable,
# or a latent process (mirroring how other modifiers treat their effect):
# windowed = WindowedLatentModel(inner; window = 10:20, effect = 2.0)
# # effect as constant multiplier inside the window, identity outside
# windowed = WindowedLatentModel(inner; window = 10:20, effect = x -> x .+ 1)
# # effect as a callable
# windowed = WindowedLatentModel(inner; window = 10:20,
# effect = Intercept(Normal(0, 1)))
# # effect size as an uncertain latent process
# Stacking two windows should nest like any other modifier:
# stacked = WindowedLatentModel(
# WindowedLatentModel(inner; window = 1:5, effect = 1.5);
# window = 10:20, effect = 2.0)
# rand(as_turing_model(stacked, 30))Part of #165.
This issue was opened by a bot. Please ping @seabbs for any questions.
Activity
seabbs-bot commentedon Sep 2, 2026
Verdict: already reachable. No new type needed.
A windowed effect is
TransformLatentModelreading the index andCombineLatentModelssumming the result onto the base path. Seven routes weretried in the REPL against
main(Julia 1.12, DynamicPPL 0.42.9, Turing 0.46.1)and all seven work, including the uncertain-effect and stacking cases the issue
listed as the desired usage.
Setup
1. Fixed effect, additive — a single transform
The closure indexes the path it is handed, so it never needs the series length.
This covers both
effect = 2.0andeffect = x -> x .+ 1from the issue.2. Uncertain effect size — a gated process, summed
The gated process contributes exactly zero outside the window, so the composed
path is the base path there. This covers
effect = Intercept(Normal(0, 1)).3. Stacking two windows
Windows stack by adding members, not by nesting, and each keeps its own name:
Deltas against the same seed:
[1.553 ×5, 0.0 ×14, 1.954 ×11, 0.0 ×10].4. The parameter-slot seam
A latent process and a parameter prior share one role, so the same gated
process drops straight into a per-step parameter slot. An
ARmore stronglydamped over the window and constant outside it:
5. Multiplicative uncertain effect
CombineLatentModelssums, so a multiplicative effect on a positive path isthe same composition in log space:
Ratio to the same-seed base path:
[1.0, 1.0, 2.183, 2.183, 2.183, 1.0]atindices
[1, 19, 20, 25, 30, 31].For a path that may be negative,
Stratifyat shape(1, n)withcombine = *and aReplicated gated effect multiplies two paths directly,then
vecflattens it. Verified: same ratios, no log space.6.
ConcatLatentModels— works, but is the worse routeThe user's steer was a concat-style helper.
ConcatLatentModelsalreadyexists and does reach the effect, with a window-aware
dimension_adaptor:But it breaks whenever the window touches an edge, because that needs a
zero-length segment:
The masking route in 2 handles
win = 1:10with no change at all. So concat isnot the right primitive here.
7. Third-party route, if the effect should only exist inside the window
In routes 2 to 6 the effect process runs over the full length and is then
masked. To generate it over the window only, a six-line user-defined broadcast
rule already plugs into the existing extension point:
Recommendation
Close as already reachable. No
WindowedLatentModel, and no newconcatenation helper.
The composition satisfies every property the issue wanted from a modifier: it
stacks by ordinary composition, its combined effect is the documented
composition of the parts, the effect slot takes a constant, a callable or a
latent process, and a scenario comparison is a change of members around the
same base process. It also stays inside the documented role structure, since
nothing reaches into another process's parameters.
Two ergonomic costs are real but do not justify a type. The window lives in an
anonymous closure, so it is invisible in the model tree:
And the gating expression is repeated at every call site.
If either becomes a nuisance, the smallest fix is a helper function beside
broadcast_dayofweekandbroadcast_weeklyinsrc/latent_models/manipulators/broadcast/helpers.jl, returning route 7'scomposition. It adds no supertype and no new composition semantics, and it
generates the effect over the window rather than over the whole series. Names
worth considering:
broadcast_window,in_window,on_window.broadcast_windowis the better one — it names the family it belongs to andsits alphabetically with its siblings, whereas
in_windowreads like apredicate. That is a separate, optional ergonomics change, not this issue.
A side finding:
RandomWalk's positional constructor does not callpath_prioronϵ_t, while the keyword constructor does. SoRandomWalk(Normal(0, 0.1), HalfNormal(0.05))— the form in this issue'sexample — silently gives a scalar increment and a length-2 path at
n = 40.Filed as #344.
Docs and a regression test for the composition are in #345.
This was opened by a bot. Please ping @seabbs for any questions.
docs(latent): show a windowed effect built from existing modifiers
feat(latent): add broadcast_window for an effect confined to a window