Skip to content

plot_model_cartoon: reduce each posterior draw to one θ vector (correctness follow-up to #1124) #1125

Description

@AlexanderFengler

Deliberately excluded from the visual redesign (#1124) and its PR; grouped here because the fixes are entangled.

For regression/hierarchical models, each draw's geometry currently derives from different trials of the simulator metadata: metadata[\"boundary\"] is the last trial's (a scratch buffer in ssm-simulators), while metadata[\"trajectory\"]/t/z are trial 0's. The uncertainty bands added in #1124 are per-element honest, but the boundary ribbon and drift cone describe different trials. Intercept-only models are unaffected.

Scope:

  • θ-reduction: one θ vector per (chain, draw) — per-draw trial-mean by default, plus an obs= parameter to select a specific trial. Single-row no-noise simulator calls remove the mixed-trial problem by construction (and cut per-draw no-noise cost by ~n_trials).
  • Deterministic reference geometry: the "mean" cartoon currently simulates one random unseeded trial of the trial-wise posterior-mean matrix (plot_func_model / plot_func_model_n) — replace with the same reduction. Also makes the histogram baseline stable across calls.
  • Seeded RNG end-to-end: one np.random.default_rng(random_state) instead of the np.random.seed + global randint pattern; documented draw order so histograms, geometry, and trajectories are jointly reproducible.
  • max_t/t_s ownership: max_t is never passed to the simulator (defaults to 20 s → ~75% of every boundary polyline is outside the axes); t_s is also assigned in multiple branches. Compute once, pass everywhere.
  • Trajectory θ-sourcing: trajectories draw θ from theta_mean whenever it exists, so they carry no posterior uncertainty even in samples mode; the fallback samples chain/draw/obs independently, composing θ vectors that exist in no draw.

The statistical caveat to document with the fix: geometry is nonlinear in θ, so the plug-in curve at the reduced mean is not the mean of the per-draw geometries and need not sit mid-band.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions