Skip to content

Commit 4546a96

Browse files
TobiBuCopilot
andauthored
Update rubix/inference/posterior_predictive.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent cba9b4a commit 4546a96

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

rubix/inference/posterior_predictive.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,11 @@ def compute_residual_products(
147147
abs_residual = jnp.abs(residual)
148148

149149
if inv_variance is not None:
150-
chi2 = residual**2 * inv_variance
150+
chi2 = residual**2 * inv_variance.astype(residual.dtype)
151151
elif sigma is not None:
152-
chi2 = residual**2 / jnp.maximum(sigma**2, jnp.asarray(1e-12, sigma.dtype))
152+
eps_arr = jnp.asarray(1e-12, dtype=residual.dtype)
153+
sigma_safe = jnp.maximum(sigma.astype(residual.dtype), eps_arr)
154+
chi2 = residual**2 / (sigma_safe**2)
153155
else:
154156
chi2 = residual**2
155157

0 commit comments

Comments
 (0)