From: Wolfgang Bangerth Date: Thu, 16 Jan 2020 21:22:34 +0000 (-0700) Subject: Increase the precision of the output. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c7db8f5a4a28d1ac51f3518c9d28856c8cb5c62;p=code-gallery.git Increase the precision of the output. --- diff --git a/MCMC-Laplace/mcmc-laplace.cc b/MCMC-Laplace/mcmc-laplace.cc index 483ea24..a390ceb 100644 --- a/MCMC-Laplace/mcmc-laplace.cc +++ b/MCMC-Laplace/mcmc-laplace.cc @@ -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); }