-
Notifications
You must be signed in to change notification settings - Fork 88
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
Not handeling negative log evidence #3
Comments
Thanks for testing pymultinest so thoroughly and getting back to me. It will make pymultinest better for everyone. |
Hmm now I see all the files in /chains are generated by MultiNest not pymultinest. I seems like the 1-stats.dat is not fully formed: Global Evidence: -0.443130807308E+01 +/- 0.747079403150E-01 Local Mode PropertiesTotal Modes Found: 1 End of File So is this a bug or a feature in MultiNest |
I would expect it to give you the properties of that found mode. Perhaps MultiNest doesn't exit properly. |
MultiNest seems to exit with: ln(Z): -11.006900 Having thought more about it, is the value that MultiNest print the log evidence or the direct evidence? As a negative direct evidence is clearly nonsensical. But it does print ln(ev) while running, which is negative but that should be ok. Hmm I tried this with version 2.14 of multinest too, and it seems to generate this result too, I have written to author of multinest and asked him if this is to be expected. |
I believe this is an issue outside of pymultinest somehow; The stats.dat file shouldn't end like that. The demo produces a file like this:
I am unsure how I can help here. Regarding the other question, MultiNest works on log evidences, and will not print without the log. so always expect ln(ev). |
I have written to the guy who made MultiNest he said he would look at it. |
I have investigated the issue some more. It seems that multinest by it self, when made into pure compiled code handles, negative loglikelihoods just fine. Even when I hack the eggboxC example into give negative loglikelihoods, so it does not seem to be the C interface eigther. It is something with the interplay between python and MultiNest. I still get the issue with a ubuntu machine and python 2.6. Can you confirm weather or not you get a similar error when solving a problem that ends up having negative log evidence? What version of compilers python and linux are you using? |
Ok I think I figured it out. There is to tolerance parameters in the call to nestRun, one called tol and a another one called Ztol. It is not documented what they do, but apparently form reading the code it seems that modes which as a log evidence larger than Ztol, gets printed out in the output files, (I still have no idea what the parameter tol does) So changeing the code in run.py form: lib.run(c_int(multimodal), c_int(const_efficiency_mode), to: lib.run(c_int(multimodal), c_int(const_efficiency_mode), So it seems that this parameter should be explicitly available to set, so that one can get the statistics out for modes that have small log-evidences. |
Great catch! |
tol determines to which accuracy the evidence should be calculated. If you look at the table of Jeffreys factors for model comparisons, https://en.wikipedia.org/wiki/Bayes_factor#Interpretation you see that a accuracy better than 0.5 in the logarithm of the evidence is not necessary. |
Thank you for investigating and reporting this issue. |
Dear Johannes
It seems that the analyse module break at negative log evidence.
def _read_error_line(self, l):
#print '_read_error_line', l
name, values = l.split(' ', 1)
name = name.strip(': ').strip()
v, error = values.split(" +/- ")
return name, float(v), float(error)
The strip(' ',1) breaks as negative log evidence gives a ' -' not a ' ', I tried a fix along the lines of:
def _read_error_line(self, l):
#print '_read_error_line', l
index = re.search("[-0-9]",l).start()
name = l[0:index]
values = l[index:]
name, values = l.split(':', 1)
name = name.rstrip().lstrip().strip(':')
v, error = values.split(" +/- ")
return name, float(v), float(error)
But it break the code when trying to detect number of modes somewhere in
def get_stats(self):
"""
information about the modes found:
mean, sigma, maximum a posterior in each dimension
"""
lines = file(self.stats_file).readlines()
text = "".join(lines)
parts = text.split("\n\n\n")
del parts[0]
stats = {
'modes':[]
}
# Global Evidence
self._read_error_into_dict(lines[0], stats)
i = 0
for p in parts:
modelines = p.split("\n\n")
mode = {
'index':i
}
i = i + 1
modelines1 = modelines[0].split("\n")
# Strictly local evidence
self._read_error_into_dict(modelines1[1], mode)
self._read_error_into_dict(modelines1[2], mode)
t = self._read_table(modelines[1], title = "Parameters")
mode['mean'] = t[:,1].tolist()
mode['sigma'] = t[:,2].tolist()
mode['maximum'] = self._read_table(modelines[1])[:,1].tolist()
mode['maximum a posterior'] = self._read_table(modelines[1])[:,1].tolist()
stats['modes'].append(mode)
return stats
Do you have a suggestion for a quick fix?
The text was updated successfully, but these errors were encountered: