1 // Copyright John Maddock 2007. 2 // Copyright Paul A. Bristow 2010 3 // Use, modification and distribution are subject to the 4 // Boost Software License, Version 1.0. (See accompanying file 5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 7 // Note that this file contains quickbook mark-up as well as code 8 // and comments, don't change any of the special comment mark-ups! 9 10 #include <iostream> 11 using std::cout; using std::endl; 12 13 // Setting (approximate) precision 25 bits in a single function call using make_policy. 14 15 //[policy_ref_snip11 16 17 #include <boost/math/distributions/normal.hpp> 18 using boost::math::normal_distribution; 19 20 using namespace boost::math::policies; 21 22 const int bits = 25; // approximate precision. 23 24 double q = quantile( 25 normal_distribution<double, policy<digits2<bits> > >(), 26 0.05); // 5% quantile. 27 28 //] //[/policy_ref_snip11] 29 main()30int main() 31 { 32 std::streamsize p = 2 + (bits * 30103UL) / 100000UL; 33 // Approximate number of significant decimal digits for 25 bits. 34 cout.precision(p); 35 cout << bits << " binary bits is approximately equivalent to " << p << " decimal digits " << endl; 36 cout << "quantile(normal_distribution<double, policy<digits2<25> > >(), 0.05 = " 37 << q << endl; // -1.64485 38 } 39 40 /* 41 Output: 42 25 binary bits is approximately equivalent to 9 decimal digits 43 quantile(normal_distribution<double, policy<digits2<25> > >(), 0.05 = -1.64485363 44 */ 45 46