]> https://gitweb.dealii.org/ - code-gallery.git/commitdiff
Make it clear that some files contain *log* probabilities.
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 16 Mar 2023 18:19:36 +0000 (12:19 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 16 Mar 2023 18:19:36 +0000 (12:19 -0600)
MCMC-Laplace/Python/forward_solver.py
MCMC-Laplace/Readme.md

index b815e2a320c3ae79ed63d08ada1fb666d498c4a5..a49d3e4b2f346385f96d4429858a8bd2d8c02999 100644 (file)
@@ -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())
index 8a5afd7301dae5143a3bb50a59002700c478bcd0..485d419eb18efe2d49168ac0dd61c42a23d0af4d 100644 (file)
@@ -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;
     }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.