-
Notifications
You must be signed in to change notification settings - Fork 127
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
[PolyChord] use ppf for pc_prior instead of prior bounds #104
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,7 +180,7 @@ def initialize(self): | |
locs = bounds[:, 0] | ||
scales = bounds[:, 1] - bounds[:, 0] | ||
# This function re-scales the parameters AND puts them in the right order | ||
self.pc_prior = lambda x: (locs + np.array(x)[self.ordering] * scales).tolist() | ||
self.pc_prior = lambda x: [self.model.prior.pdf[i].ppf(xi) for i, xi in enumerate(np.array(x)[self.ordering])] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
# We will need the volume of the prior domain, since PolyChord divides by it | ||
self.logvolume = np.log(np.prod(scales)) | ||
# Prepare callback function | ||
|
@@ -250,7 +250,7 @@ def logpost(params_values): | |
loglikes = np.full(self.n_likes, np.nan) | ||
derived = list(derived) + list(logpriors) + list(loglikes) | ||
return ( | ||
max(logposterior + self.logvolume, self.pc_settings.logzero), | ||
max(loglikes.sum(), self.pc_settings.logzero), | ||
derived) | ||
|
||
sync_processes() | ||
|
@@ -278,7 +278,7 @@ def dump_paramnames(self, prefix): | |
for p in self.model.prior: | ||
f_paramnames.write("%s*\t%s\n" % ( | ||
"logprior" + _separator + p, | ||
r"\pi_\mathrm{" + p.replace("_", r"\ ") + r"}")) | ||
r"\log\pi_\mathrm{" + p.replace("_", r"\ ") + r"}")) | ||
Comment on lines
279
to
+281
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be good to add this change to #233. |
||
for p in self.model.likelihood: | ||
f_paramnames.write("%s*\t%s\n" % ( | ||
"loglike" + _separator + p, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might remain some possible cleaning up to do, e.g. I expect that
self.logvolume
won't be needed anymore, right? Consequently alsoscales
andlocs
can be removed. Maybe we don't even needbounds
here anymore? Meaning we could even get rid of all lines from 170 to 181.Or is there a different reason that PolyChord priors need to be bounded that isn't obvious to me? @williamjameshandley, maybe you can confirm whether by using the
.ppf
we indeed don't need to specify prior bounds anymore?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Certainly most other interfaces to PolyChord don't put in these bounds, so if it is necessary it might be cobaya specific. These changes all look good to me, so it's up to @JesusTorrado to approve/comment on this.