]> https://gitweb.dealii.org/ - code-gallery.git/commitdiff
Increase the precision of the output.
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 16 Jan 2020 21:22:34 +0000 (14:22 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 16 Jan 2020 22:03:17 +0000 (15:03 -0700)
MCMC-Laplace/mcmc-laplace.cc

index 483ea248b156669cc3c1ee908ae206436243bb01..a390ceb471cbf45fda0d878cf3db533e9f04857c 100644 (file)
@@ -586,6 +586,13 @@ namespace ProposalGenerator
 // formula for accepting a sample slightly more awkward, but if you
 // take exponentials on both sides of the comparison, the formula
 // should become obvious again.
+//
+// Finally, we note that the output is generated with 7 digits of
+// accuracy. (The C++ default is 6 digits.) We do this because,
+// as shown in the paper, we can determine the mean value of the
+// probability distribution we are sampling here to at least six
+// digits of accuracy, and do not want to be limited by the precision
+// of the output.
 namespace Sampler
 {
   class MetropolisHastings
@@ -634,6 +641,8 @@ namespace Sampler
     , accepted_sample_number(0)
   {
     output_file.open("samples-" + dataset_name + ".txt");
+    output_file.precision(7);
+
     random_number_generator.seed(random_seed);
   }
 

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.