From f58fe3ec3bb59b202b75b07bd1624bc3c3766cfc Mon Sep 17 00:00:00 2001 From: rydak81 <71617808+rydak81@users.noreply.github.com> Date: Mon, 15 Sep 2025 17:46:08 -0400 Subject: [PATCH] Clamp true state update before sqrt --- Copy_of_EKF_Est_Sim_334.ipynb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Copy_of_EKF_Est_Sim_334.ipynb b/Copy_of_EKF_Est_Sim_334.ipynb index a935f71..c9e337f 100644 --- a/Copy_of_EKF_Est_Sim_334.ipynb +++ b/Copy_of_EKF_Est_Sim_334.ipynb @@ -77,7 +77,8 @@ " w = np.linalg.cholesky([[SigmaW]]).T @ np.random.randn(1)\n", " v = np.linalg.cholesky([[SigmaV]]).T @ np.random.randn(1)\n", " ztrue = xtrue.item()**3 + v.item() # Convert to scalar\n", - " xtrue = np.sqrt(5 + xtrue.item()) + w.item() # Convert to scalar\n", + " safe_val = max(-5, xtrue.item())\n", + " xtrue = np.sqrt(5 + safe_val) + w.item() # Convert to scalar\n", "\n", " # KF Step 3: Estimate system output\n", " Chat = 3 * xhat**2\n",