Skip to content

Commit

Permalink
Fixed edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
williyamshoe committed Apr 24, 2024
1 parent 2c81f91 commit 74a3b0f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions hierarc/Likelihood/hierarchy_likelihood.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,13 @@ def __init__(
else:
self._draw_kappa = False

kappa_pdf_indices_trunc = kappa_pdf > 0
self._kappa_pdf_trunc = np.array([i for i, j in zip(kappa_pdf, kappa_pdf_indices_trunc)])
self._kappa_bin_edges_trunc = np.array([i for i, j in zip(kappa_bin_edges, kappa_pdf_indices_trunc)])
if kappa_pdf is not None:
kappa_pdf_indices_trunc = kappa_pdf > 0
self._kappa_pdf_trunc = np.array([i for i, j in zip(kappa_pdf, kappa_pdf_indices_trunc)])
self._kappa_bin_edges_trunc = np.array([i for i, j in zip(kappa_bin_edges, kappa_pdf_indices_trunc)])
else:
self._kappa_pdf_trunc = None
self._kappa_bin_edges_trunc = None

self._lambda_scaling_property = lambda_scaling_property
self._lambda_scaling_property_beta = lambda_scaling_property_beta
Expand Down Expand Up @@ -305,7 +309,7 @@ def log_likelihood_single(
self._gamma_in_prior_mean - scaling_param_array[-1]
) ** 2 / (2 * self._gamma_in_prior_std**2) + np.log(self._gamma_in_prior_std * (2 * np.pi)**0.5)

if self._kappa_marginalize_pdf is True:
if self._kappa_marginalize_pdf is True and self._kappa_pdf_trunc is not None:
lnlikelihood += np.log(np.interp(kappa_ext, self._kappa_bin_edges_trunc, self._kappa_pdf_trunc))

return np.nan_to_num(lnlikelihood)
Expand Down

0 comments on commit 74a3b0f

Please sign in to comment.