diff --git a/src/psimpy/inference/bayes_inference.py b/src/psimpy/inference/bayes_inference.py index 99801540e09a458b764cb9f662b89bc537697975..68095ddee374d3438b4a2b91ba4ddf3241ec6721 100644 --- a/src/psimpy/inference/bayes_inference.py +++ b/src/psimpy/inference/bayes_inference.py @@ -9,7 +9,8 @@ from beartype.typing import Callable from beartype import beartype _min_float = 10**(sys.float_info.min_10_exp) - +_max_float = 10**(sys.float_info.max_10_exp) +_max_e = np.log(np.array(_max_float, dtype=np.float128)) class BayesInferenceBase(ABC): @@ -192,6 +193,8 @@ class GridEstimation(BayesInferenceBase): self.ln_pxl(point_i, *self.args_ln_pxl, **self.kwgs_ln_pxl) ln_unnorm_posterior = ln_unnorm_posterior.reshape(xx_matrices[0].shape) + ln_unnorm_posterior = np.where( + ln_unnorm_posterior >= _max_e, _max_e, ln_unnorm_posterior) unnorm_posterior = np.exp(ln_unnorm_posterior) posterior = unnorm_posterior / np.sum(unnorm_posterior) / np.prod(steps)