From: Wolfgang Bangerth Date: Thu, 16 Mar 2023 18:19:36 +0000 (-0600) Subject: Make it clear that some files contain *log* probabilities. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99fe287d113080a7630921656089b04c017c6e0b;p=code-gallery.git Make it clear that some files contain *log* probabilities. --- diff --git a/MCMC-Laplace/Python/forward_solver.py b/MCMC-Laplace/Python/forward_solver.py index b815e2a..a49d3e4 100644 --- a/MCMC-Laplace/Python/forward_solver.py +++ b/MCMC-Laplace/Python/forward_solver.py @@ -239,8 +239,8 @@ def verify_against_stored_tests() : # Then also read the reference output generated by the C++ program: f_output_z = open ("../testing/output.{}.z.txt".format(i), 'r') - f_output_likelihood = open ("../testing/output.{}.likelihood.txt".format(i), 'r') - f_output_prior = open ("../testing/output.{}.prior.txt".format(i), 'r') + f_output_likelihood = open ("../testing/output.{}.loglikelihood.txt".format(i), 'r') + f_output_prior = open ("../testing/output.{}.logprior.txt".format(i), 'r') reference_z = np.fromfile(f_output_z, count=13**2, sep=" ") reference_log_likelihood = float(f_output_likelihood.read()) diff --git a/MCMC-Laplace/Readme.md b/MCMC-Laplace/Readme.md index 8a5afd7..485d419 100644 --- a/MCMC-Laplace/Readme.md +++ b/MCMC-Laplace/Readme.md @@ -250,15 +250,17 @@ contains a vector of coefficients (_theta_) for which the corresponding `testing/output.X.z.txt` contains the corresponding output at the evaluation points (the _z_ vector that corresponds to the _theta_ vector, as described in the paper linked to at the very top of this page). Furthermore, the -`testing/output.X.likelihood.txt` file contains the corresponding likelihood +`testing/output.X.loglikelihood.txt` file contains the corresponding log likelihood value for this _theta_ vector that can be computed from the _z_ vector, and -the `testing/output.X.prior.txt` file contains the prior associated with +the `testing/output.X.logprior.txt` file contains the log prior associated with this _theta_ vector. The values in these last two files are not normalized, and so care must be taken when comparing these values between implementations: An implementation (or a patched version of this program) may compute a different -value, but the ratio of the values between different inputs must be the +value, but the difference of the values between different inputs must be the same -- in other words, the outputs must be like the ones stored in these -files *up to a constant* for an implementation to be correct. +files *up to an additive constant* for an implementation to be correct. (It is +the *ratio* of probabilities that matters, but because the files contain logarithms, +it is the *difference* of log probabilities). The ten inputs are chosen as follows: @@ -400,11 +402,11 @@ int main() // ...and then also evaluate prior and likelihood for these // theta vectors: - std::ofstream test_output_likelihood ("output." + std::to_string(test) + ".likelihood.txt"); + std::ofstream test_output_likelihood ("output." + std::to_string(test) + ".loglikelihood.txt"); test_output_likelihood.precision(12); test_output_likelihood << log_likelihood.log_likelihood(z) << std::endl; - std::ofstream test_output_prior ("output." + std::to_string(test) + ".prior.txt"); + std::ofstream test_output_prior ("output." + std::to_string(test) + ".logprior.txt"); test_output_prior.precision(12); test_output_prior << log_prior.log_prior(theta) << std::endl; }