Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing normalization factor in likelihood #406

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions enterprise/signals/signal_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ def __call__(self, xs, phiinv_method="cliques"):
# the np.sum here is needed because each pulsar returns a 2-tuple
loglike += -0.5 * np.sum([ell for ell in self.pta.get_rNr_logdet(params)])

# Add factors of log(2pi) for the likelihood normalization
ntot = sum(sc._residuals.size for sc in self.pta._signalcollections)
loglike -= 0.5 * ntot * np.log(2 * np.pi)

# get extra prior/likelihoods
loglike += sum(self.pta.get_logsignalprior(params))

Expand Down
1 change: 1 addition & 0 deletions tests/test_likelihood.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ def compute_like(self, npsrs=1, inc_corr=False, inc_kernel=False, cholesky_spars
TNrs.append(np.dot(Ts[ct].T, sl.cho_solve(cfs[ct], psr.residuals)))
TNTs.append(np.dot(Ts[ct].T, sl.cho_solve(cfs[ct], Ts[ct])))
loglike += -0.5 * (np.dot(psr.residuals, sl.cho_solve(cfs[ct], psr.residuals)) + logdets[ct])
loglike += -0.5 * len(psr.residuals) * np.log(2 * np.pi)

TNr = np.concatenate(TNrs)
phi = sl.block_diag(*phis)
Expand Down
Loading