From 3572d1344fbcfbadc42e4619830424d94c091621 Mon Sep 17 00:00:00 2001 From: Iahn Cajigas Date: Sat, 21 Mar 2026 23:28:30 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20match=20example05=20fig06=20to=20MATLAB?= =?UTF-8?q?=20=E2=80=94=20plot=20only=20means,=20no=20individual=20traces?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MATLAB example05_decoding_ppaf_pphf.m plots only mean decoded traces (thick solid lines) for the hybrid filter summary figure. The Python version was incorrectly plotting all 20 individual simulation traces as thin dashed lines underneath the means (matching HybridFilterExample.m, a different demo). Remove the individual trace loop to match example05.m. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../paper/example05_decoding_ppaf_pphf.py | 30 ++----------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/examples/paper/example05_decoding_ppaf_pphf.py b/examples/paper/example05_decoding_ppaf_pphf.py index 2602e04..9b6cfe9 100644 --- a/examples/paper/example05_decoding_ppaf_pphf.py +++ b/examples/paper/example05_decoding_ppaf_pphf.py @@ -735,8 +735,8 @@ def _plot_part_c(result): fig5.tight_layout() - # ── Figure 6: 4×3 decode — matches MATLAB HybridFilterExample.m ── - # MATLAB overlays *individual* dashed traces first, then thick means on top. + # ── Figure 6: 4×3 decode — matches MATLAB example05_decoding_ppaf_pphf.m ── + # MATLAB example05 plots ONLY means (thick solid lines), no individual traces. fig6 = plt.figure(figsize=(14, 9)) S_estAll = result["S_estAll"] # (n_sims, T) @@ -745,7 +745,6 @@ def _plot_part_c(result): MU_estNTAll = result["MU_estNTAll"] X_estAll = result["X_estAll"] # (6, T, n_sims) X_estNTAll = result["X_estNTAll"] - n_sims = result["n_sims"] # Pre-create all subplots ax_s = fig6.add_subplot(4, 3, (1, 4)) @@ -756,30 +755,7 @@ def _plot_part_c(result): ax_xv = fig6.add_subplot(4, 3, 11) ax_yv = fig6.add_subplot(4, 3, 12) - # --- Individual traces (thin dashed, matching MATLAB loop) --- - for n in range(n_sims): - # State traces - ax_s.plot(time, S_estAll[n, :], "b-.", linewidth=0.5) - ax_s.plot(time, S_estNTAll[n, :], "g-.", linewidth=0.5) - # Movement probability - ax_p.plot(time, MU_estAll[n, 1, :], "b-.", linewidth=0.5) - ax_p.plot(time, MU_estNTAll[n, 1, :], "g-.", linewidth=0.5) - # 2D path - ax_2d.plot(100 * X_estAll[0, :, n], 100 * X_estAll[1, :, n], "b-.", - linewidth=0.5) - ax_2d.plot(100 * X_estNTAll[0, :, n], 100 * X_estNTAll[1, :, n], "g-.", - linewidth=0.5) - # Position/velocity traces - ax_xp.plot(time, 100 * X_estAll[0, :, n], "b-.", linewidth=0.5) - ax_xp.plot(time, 100 * X_estNTAll[0, :, n], "g-.", linewidth=0.5) - ax_yp.plot(time, 100 * X_estAll[1, :, n], "b-.", linewidth=0.5) - ax_yp.plot(time, 100 * X_estNTAll[1, :, n], "g-.", linewidth=0.5) - ax_xv.plot(time, 100 * X_estAll[2, :, n], "b-.", linewidth=0.5) - ax_xv.plot(time, 100 * X_estNTAll[2, :, n], "g-.", linewidth=0.5) - ax_yv.plot(time, 100 * X_estAll[3, :, n], "b-.", linewidth=0.5) - ax_yv.plot(time, 100 * X_estNTAll[3, :, n], "g-.", linewidth=0.5) - - # --- Mean traces (thick solid, on top) --- + # --- Mean traces (thick solid — MATLAB plots only means, no individual) --- mS_est = np.mean(S_estAll, axis=0) mS_estNT = np.mean(S_estNTAll, axis=0) mMU_est = np.mean(MU_estAll, axis=0)