@@ -1,3 +1,7 @@ | |||
| 1 | + // Copyright John Maddock 2018. | ||
| 2 | + // Use, modification and distribution are subject to the | ||
| 3 | + // Boost Software License, Version 1.0. (See accompanying file | ||
| 4 | + // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
| 1 | 5 | ||
| 2 | 6 | #include <map> | |
| 3 | 7 | #include <boost/config.hpp> | |
@@ -16,6 +16,8 @@ ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |||
| 16 | 16 | ||
| 17 | 17 | Visual Studio is recommended for editing this file | |
| 18 | 18 | because it checks syntax, does layout and provides help on options. | |
| 19 | + | ||
| 20 | + boost-no-inspect | ||
| 19 | 21 | ||
| 20 | 22 | /*============================================================================= | |
| 21 | 23 | Program listings | |
@@ -34,22 +36,15 @@ Program listings | |||
| 34 | 36 | padding: 0.5pc 0.5pc 0.5pc 0.5pc; | |
| 35 | 37 | } | |
| 36 | 38 | ||
| 37 | - .programlisting, | ||
| 38 | - .screen { | ||
| 39 | - font-size: 10pt; | ||
| 40 | - display: block; | ||
| 41 | - /* was margin: 1pc 4% 0pc 4%; | ||
| 42 | - but that led to overflow on some code lines, so reduced and lined up with blockquote indent (see below). */ | ||
| 43 | - margin: 1pc 2% 0pc 2%; | ||
| 44 | - /* https://www.w3schools.com/Css/css_margin.asp margin-top margin-right margin-bottom margin-left. | ||
| 45 | - * auto - the browser calculates the margin | ||
| 46 | - * length - specifies a margin in px, pt, cm, etc. | ||
| 47 | - * % - specifies a margin in % of the width of the containing element | ||
| 48 | - * inherit - specifies that the margin should be inherited from the parent element | ||
| 49 | - | ||
| 50 | - */ | ||
| 51 | - padding: 0.5pc 0.5pc 0.5pc 0.5pc; | ||
| 52 | - } | ||
| 39 | + .programlisting, | ||
| 40 | + .screen | ||
| 41 | + { | ||
| 42 | + font-size: 10pt; | ||
| 43 | + display: block; | ||
| 44 | + /* was margin: 1pc 4% 0pc 4%; */ | ||
| 45 | + margin: 1pc 2% 0pc 2%; | ||
| 46 | + padding: 0.5pc 0.5pc 0.5pc 0.5pc; | ||
| 47 | + } | ||
| 53 | 48 | @media screen | |
| 54 | 49 | { | |
| 55 | 50 | /* Syntax Highlighting */ | |
@@ -146,7 +141,6 @@ span.gray { color: #808080; } /* light gray */ | |||
| 146 | 141 | and a little bigger (* 125%) because the serif font appears smaller than the default sans serif fonts. | |
| 147 | 142 | Used, for example: [role serif_italic This is in serif font and italic]. | |
| 148 | 143 | Used in turn by template for inline expressions to match equations as SVG or PNG images. | |
| 149 | - | ||
| 150 | 144 | */ | |
| 151 | 145 | span.serif_italic { | |
| 152 | 146 | font-family: serif; | |
@@ -155,7 +149,7 @@ span.serif_italic { | |||
| 155 | 149 | font-stretch: expanded; | |
| 156 | 150 | } | |
| 157 | 151 | ||
| 158 | - /* Custom indent of paragraphs to make equations look nicer, 2% to match that indent of code block above. | ||
| 152 | + /* Custom indent of paragraphs to make equations look nicer. | ||
| 159 | 153 | https://www.w3schools.com/tags/tag_blockquote.asp says | |
| 160 | 154 | "Most browsers will display the <blockquote> element with left and right margin 40px values: " | |
| 161 | 155 | */ | |
@@ -16,7 +16,7 @@ | |||
| 16 | 16 | // "BOOST_MATH_OVERFLOW_ERROR_POLICY="errno_on_error"" | |
| 17 | 17 | // so command line shows: | |
| 18 | 18 | // /D "BOOST_MATH_ASSERT_UNDEFINED_POLICY=0" | |
| 19 | - // /D "BOOST_MATH_OVERFLOW_ERROR_POLICY="errno_on_error"" | ||
| 19 | + // /D "BOOST_MATH_OVERFLOW_ERROR_POLICY="errno_on_error"" | ||
| 20 | 20 | ||
| 21 | 21 | #include "stdafx.h" | |
| 22 | 22 | ||
@@ -92,7 +92,7 @@ any_distribution::any_distribution(int t, double arg1, double arg2, double arg3) | |||
| 92 | 92 | break; | |
| 93 | 93 | case 17: | |
| 94 | 94 | this->reset(new concrete_distribution<boost::math::negative_binomial_distribution<> >(boost::math::negative_binomial_distribution<>(arg1, arg2))); | |
| 95 | - break; | ||
| 95 | + break; | ||
| 96 | 96 | case 18: | |
| 97 | 97 | this->reset(new concrete_distribution<boost::math::non_central_beta_distribution<> >(boost::math::non_central_beta_distribution<>(arg1, arg2, arg3))); | |
| 98 | 98 | break; | |
@@ -133,10 +133,10 @@ any_distribution::any_distribution(int t, double arg1, double arg2, double arg3) | |||
| 133 | 133 | this->reset(new concrete_distribution<boost::math::weibull>(boost::math::weibull(arg1, arg2))); | |
| 134 | 134 | break; | |
| 135 | 135 | ||
| 136 | - | ||
| 136 | + | ||
| 137 | 137 | default: | |
| 138 | 138 | // TODO Need some proper error handling here? | |
| 139 | - assert(0); | ||
| 139 | + BOOST_ASSERT(0); | ||
| 140 | 140 | } | |
| 141 | 141 | TRANSLATE_EXCEPTIONS_END | |
| 142 | 142 | } // any_distribution constructor. | |
@@ -156,8 +156,8 @@ struct distribution_info | |||
| 156 | 156 | double third_default; // 0 if there isn't a third argument. | |
| 157 | 157 | }; | |
| 158 | 158 | ||
| 159 | - distribution_info distributions[] = | ||
| 160 | - { // distribution name, parameter name(s) and default(s) | ||
| 159 | + distribution_info distributions[] = | ||
| 160 | + { // distribution name, parameter name(s) and default(s) | ||
| 161 | 161 | // Order must match any_distribution constructor above! | |
| 162 | 162 | // Null string "" and zero default for un-used arguments. | |
| 163 | 163 | { "Bernoulli", "Probability", "", "",0.5, 0, 0}, // case 0 | |
@@ -18,6 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | 19 | #include <iostream> | |
| 20 | 20 | #include <exception> | |
| 21 | + #include <boost/assert.hpp> | ||
| 21 | 22 | ||
| 22 | 23 | int main() | |
| 23 | 24 | { | |
@@ -62,8 +63,8 @@ int main() | |||
| 62 | 63 | using boost::math::arcsine_distribution; | |
| 63 | 64 | ||
| 64 | 65 | arcsine_distribution<> as(2, 5); // Cconstructs a double arcsine distribution. | |
| 65 | - assert(as.x_min() == 2.); // as.x_min() returns 2. | ||
| 66 | - assert(as.x_max() == 5.); // as.x_max() returns 5. | ||
| 66 | + BOOST_ASSERT(as.x_min() == 2.); // as.x_min() returns 2. | ||
| 67 | + BOOST_ASSERT(as.x_max() == 5.); // as.x_max() returns 5. | ||
| 67 | 68 | //] [/arcsine_snip_8] | |
| 68 | 69 | } | |
| 69 | 70 | return 0; | |
@@ -1,4 +1,3 @@ | |||
| 1 | - | ||
| 2 | 1 | // Use, modification and distribution are subject to the | |
| 3 | 2 | // Boost Software License, Version 1.0. | |
| 4 | 3 | // (See accompanying file LICENSE_1_0.txt | |
@@ -52,16 +51,16 @@ int main() | |||
| 52 | 51 | /*`Using `typedef cpp_dec_float_50` hides the complexity of multiprecision, | |
| 53 | 52 | allows us to define variables with 50 decimal digit precision just like built-in `double`. | |
| 54 | 53 | */ | |
| 55 | - using boost::multiprecision::cpp_dec_float_50; | ||
| 54 | + using boost::multiprecision::cpp_dec_float_50; | ||
| 56 | 55 | ||
| 57 | - cpp_dec_float_50 seventh = cpp_dec_float_50(1) / 7; // 1 / 7 | ||
| 56 | + cpp_dec_float_50 seventh = cpp_dec_float_50(1) / 7; // 1 / 7 | ||
| 58 | 57 | ||
| 59 | 58 | /*`By default, output would only show the standard 6 decimal digits, | |
| 60 | 59 | so set precision to show all 50 significant digits, including any trailing zeros. | |
| 61 | 60 | */ | |
| 62 | - std::cout.precision(std::numeric_limits<cpp_dec_float_50>::digits10); | ||
| 63 | - std::cout << std::showpoint << std::endl; // Append any trailing zeros. | ||
| 64 | - std::cout << seventh << std::endl; | ||
| 61 | + std::cout.precision(std::numeric_limits<cpp_dec_float_50>::digits10); | ||
| 62 | + std::cout << std::showpoint << std::endl; // Append any trailing zeros. | ||
| 63 | + std::cout << seventh << std::endl; | ||
| 65 | 64 | /*`which outputs: | |
| 66 | 65 | ||
| 67 | 66 | 0.14285714285714285714285714285714285714285714285714 | |
@@ -160,12 +160,12 @@ Finally, print two tables of probability for the /exactly/ and /at least/ a numb | |||
| 160 | 160 | /*` | |
| 161 | 161 | The last (0 to 10 heads) must, of course, be 100% probability. | |
| 162 | 162 | */ | |
| 163 | - double probability = 0.3; | ||
| 164 | - double q = quantile(flip, probability); | ||
| 165 | - std::cout << "Quantile (flip, " << probability << ") = " << q << std::endl; // Quantile (flip, 0.3) = 3 | ||
| 166 | - probability = 0.6; | ||
| 167 | - q = quantile(flip, probability); | ||
| 168 | - std::cout << "Quantile (flip, " << probability << ") = " << q << std::endl; // Quantile (flip, 0.6) = 5 | ||
| 163 | + double probability = 0.3; | ||
| 164 | + double q = quantile(flip, probability); | ||
| 165 | + std::cout << "Quantile (flip, " << probability << ") = " << q << std::endl; // Quantile (flip, 0.3) = 3 | ||
| 166 | + probability = 0.6; | ||
| 167 | + q = quantile(flip, probability); | ||
| 168 | + std::cout << "Quantile (flip, " << probability << ") = " << q << std::endl; // Quantile (flip, 0.6) = 5 | ||
| 169 | 169 | } | |
| 170 | 170 | catch(const std::exception& e) | |
| 171 | 171 | { | |
@@ -58,7 +58,7 @@ using std::numeric_limits; | |||
| 58 | 58 | ||
| 59 | 59 | // http://en.wikipedia.org/wiki/Brent%27s_method Brent's method | |
| 60 | 60 | ||
| 61 | - // An example of a function for which we want to find a minimum. | ||
| 61 | + // An example of a function for which we want to find a minimum. | ||
| 62 | 62 | double f(double x) | |
| 63 | 63 | { | |
| 64 | 64 | return (x + 3) * (x - 1) * (x - 1); | |
@@ -68,7 +68,7 @@ double f(double x) | |||
| 68 | 68 | struct funcdouble | |
| 69 | 69 | { | |
| 70 | 70 | double operator()(double const& x) | |
| 71 | - { | ||
| 71 | + { | ||
| 72 | 72 | return (x + 3) * (x - 1) * (x - 1); // (x + 3)(x - 1)^2 | |
| 73 | 73 | } | |
| 74 | 74 | }; | |
@@ -79,7 +79,7 @@ struct func | |||
| 79 | 79 | { | |
| 80 | 80 | template <class T> | |
| 81 | 81 | T operator()(T const& x) | |
| 82 | - { | ||
| 82 | + { | ||
| 83 | 83 | return (x + 3) * (x - 1) * (x - 1); // (x + 3)(x - 1)^2 | |
| 84 | 84 | } | |
| 85 | 85 | }; | |
@@ -96,7 +96,7 @@ is_close_to(FPT left, FPT right, FPT tolerance) | |||
| 96 | 96 | //[brent_minimise_close | |
| 97 | 97 | ||
| 98 | 98 | //! Compare if value got is close to expected, | |
| 99 | - //! checking first if expected is very small | ||
| 99 | + //! checking first if expected is very small | ||
| 100 | 100 | //! (to avoid divide by tiny or zero during comparison) | |
| 101 | 101 | //! before comparing expect with value got. | |
| 102 | 102 | ||
@@ -136,7 +136,7 @@ void show_minima() | |||
| 136 | 136 | std::cout << "\n\nFor type: " << typeid(T).name() | |
| 137 | 137 | << ",\n epsilon = " << std::numeric_limits<T>::epsilon() | |
| 138 | 138 | // << ", precision of " << bits << " bits" | |
| 139 | - << ",\n the maximum theoretical precision from Brent's minimization is " | ||
| 139 | + << ",\n the maximum theoretical precision from Brent's minimization is " | ||
| 140 | 140 | << sqrt(std::numeric_limits<T>::epsilon()) | |
| 141 | 141 | << "\n Displaying to std::numeric_limits<T>::digits10 " << prec << ", significant decimal digits." | |
| 142 | 142 | << std::endl; | |
@@ -165,7 +165,7 @@ void show_minima() | |||
| 165 | 165 | } | |
| 166 | 166 | // Check that result is that expected (compared to theoretical uncertainty). | |
| 167 | 167 | T uncertainty = sqrt(std::numeric_limits<T>::epsilon()); | |
| 168 | - std::cout << std::boolalpha << "x == 1 (compared to uncertainty " << uncertainty << ") is " | ||
| 168 | + std::cout << std::boolalpha << "x == 1 (compared to uncertainty " << uncertainty << ") is " | ||
| 169 | 169 | << is_close(static_cast<T>(1), r.first, uncertainty) << std::endl; | |
| 170 | 170 | std::cout << std::boolalpha << "f(x) == (0 compared to uncertainty " << uncertainty << ") is " | |
| 171 | 171 | << is_close(static_cast<T>(0), r.second, uncertainty) << std::endl; | |
@@ -194,7 +194,7 @@ int main() | |||
| 194 | 194 | ||
| 195 | 195 | // Tip - using | |
| 196 | 196 | // std::cout.precision(std::numeric_limits<T>::digits10); | |
| 197 | - // during debugging is wise because it warns | ||
| 197 | + // during debugging is wise because it warns | ||
| 198 | 198 | // if construction of multiprecision involves conversion from double | |
| 199 | 199 | // by finding random or zero digits after 17th decimal digit. | |
| 200 | 200 | ||
@@ -224,9 +224,9 @@ int main() | |||
| 224 | 224 | using boost::math::fpc::is_small; | |
| 225 | 225 | ||
| 226 | 226 | std::cout << "x = " << r.first << ", f(x) = " << r.second << std::endl; | |
| 227 | - std::cout << std::boolalpha << "x == 1 (compared to uncertainty " | ||
| 227 | + std::cout << std::boolalpha << "x == 1 (compared to uncertainty " | ||
| 228 | 228 | << uncertainty << ") is " << is_close(1., r.first, uncertainty) << std::endl; // true | |
| 229 | - std::cout << std::boolalpha << "f(x) == 0 (compared to uncertainty " | ||
| 229 | + std::cout << std::boolalpha << "f(x) == 0 (compared to uncertainty " | ||
| 230 | 230 | << uncertainty << ") is " << is_close(0., r.second, uncertainty) << std::endl; // true | |
| 231 | 231 | //] [/brent_minimise_double_1a] | |
| 232 | 232 | ||
@@ -248,11 +248,11 @@ int main() | |||
| 248 | 248 | std::streamsize prec = static_cast<int>(2 + sqrt((double)bits)); // Number of significant decimal digits. | |
| 249 | 249 | std::streamsize precision_3 = std::cout.precision(prec); // Save and set new precision. | |
| 250 | 250 | std::cout << "Showing " << bits << " bits " | |
| 251 | - "precision with " << prec | ||
| 251 | + "precision with " << prec | ||
| 252 | 252 | << " decimal digits from tolerance " << sqrt(std::numeric_limits<double>::epsilon()) | |
| 253 | 253 | << std::endl; | |
| 254 | 254 | ||
| 255 | - std::cout << "x at minimum = " << r.first | ||
| 255 | + std::cout << "x at minimum = " << r.first | ||
| 256 | 256 | << ", f(" << r.first << ") = " << r.second | |
| 257 | 257 | << " after " << it << " iterations. " << std::endl; | |
| 258 | 258 | std::cout.precision(precision_3); // Restore. | |
@@ -362,7 +362,7 @@ int main() | |||
| 362 | 362 | typedef boost::multiprecision::number<boost::multiprecision::cpp_bin_float<50>, | |
| 363 | 363 | boost::multiprecision::et_off> | |
| 364 | 364 | cpp_bin_float_50_et_off; | |
| 365 | - | ||
| 365 | + | ||
| 366 | 366 | typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<50>, | |
| 367 | 367 | boost::multiprecision::et_on> // et_on is default so is same as cpp_dec_float_50. | |
| 368 | 368 | cpp_dec_float_50_et_on; | |
@@ -382,7 +382,7 @@ int main() | |||
| 382 | 382 | std::cout << "Bracketing " << bracket_min << " to " << bracket_max << std::endl; | |
| 383 | 383 | const boost::uintmax_t maxit = 20; | |
| 384 | 384 | boost::uintmax_t it = maxit; // Will be updated with actual iteration count. | |
| 385 | - std::pair<cpp_bin_float_50, cpp_bin_float_50> r | ||
| 385 | + std::pair<cpp_bin_float_50, cpp_bin_float_50> r | ||
| 386 | 386 | = brent_find_minima(func(), bracket_min, bracket_max, bits, it); | |
| 387 | 387 | ||
| 388 | 388 | std::cout << "x at minimum = " << r.first << ",\n f(" << r.first << ") = " << r.second | |
@@ -406,7 +406,7 @@ x == 1 (compared to uncertainty 7.311312755e-26) is true | |||
| 406 | 406 | f(x) == (0 compared to uncertainty 7.311312755e-26) is true | |
| 407 | 407 | -4 1.3333333333333333333333333333333333333333333333333 | |
| 408 | 408 | x at minimum = 0.99999999999999999999999999998813903221565569205253, | |
| 409 | - f(0.99999999999999999999999999998813903221565569205253) = | ||
| 409 | + f(0.99999999999999999999999999998813903221565569205253) = | ||
| 410 | 410 | 5.6273022712501408640665300316078046703496236636624e-58 | |
| 411 | 411 | 14 iterations | |
| 412 | 412 | //] [/brent_minimise_mp_output_1] | |
@@ -556,21 +556,21 @@ f(x) == 0 (compared to uncertainty 1.49012e-08) is true | |||
| 556 | 556 | ||
| 557 | 557 | Type double with limited iterations. | |
| 558 | 558 | Precision bits = 53 | |
| 559 | - x at minimum = 1.00000, f(1.00000) = 5.04853e-18 after 10 iterations. | ||
| 559 | + x at minimum = 1.00000, f(1.00000) = 5.04853e-18 after 10 iterations. | ||
| 560 | 560 | Showing 53 bits precision with 9 decimal digits from tolerance 1.49011612e-08 | |
| 561 | - x at minimum = 1.00000000, f(1.00000000) = 5.04852568e-18 after 10 iterations. | ||
| 561 | + x at minimum = 1.00000000, f(1.00000000) = 5.04852568e-18 after 10 iterations. | ||
| 562 | 562 | ||
| 563 | 563 | Type double with limited iterations and half double bits. | |
| 564 | 564 | Showing 26 bits precision with 7 decimal digits from tolerance 0.000172633 | |
| 565 | 565 | x at minimum = 1.000000, f(1.000000) = 5.048526e-18 | |
| 566 | - 10 iterations. | ||
| 566 | + 10 iterations. | ||
| 567 | 567 | ||
| 568 | 568 | Type double with limited iterations and quarter double bits. | |
| 569 | 569 | Showing 13 bits precision with 5 decimal digits from tolerance 0.0156250 | |
| 570 | - x at minimum = 0.99998, f(0.99998) = 2.0070e-09, after 7 iterations. | ||
| 570 | + x at minimum = 0.99998, f(0.99998) = 2.0070e-09, after 7 iterations. | ||
| 571 | 571 | ||
| 572 | 572 | Type long double with limited iterations and all long double bits. | |
| 573 | - x at minimum = 1.00000000112345, f(1.00000000112345) = 5.04852568272458e-18, after 10 iterations. | ||
| 573 | + x at minimum = 1.00000000112345, f(1.00000000112345) = 5.04852568272458e-18, after 10 iterations. | ||
| 574 | 574 | ||
| 575 | 575 | ||
| 576 | 576 | For type: float, | |
@@ -603,7 +603,7 @@ x == 1 (compared to uncertainty 1.490116e-08) is true | |||
| 603 | 603 | f(x) == (0 compared to uncertainty 1.490116e-08) is true | |
| 604 | 604 | Bracketing -4.0000000000000000000000000000000000000000000000000 to 1.3333333333333333333333333333333333333333333333333 | |
| 605 | 605 | x at minimum = 0.99999999999999999999999999998813903221565569205253, | |
| 606 | - f(0.99999999999999999999999999998813903221565569205253) = 5.6273022712501408640665300316078046703496236636624e-58, after 14 iterations. | ||
| 606 | + f(0.99999999999999999999999999998813903221565569205253) = 5.6273022712501408640665300316078046703496236636624e-58, after 14 iterations. | ||
| 607 | 607 | ||
| 608 | 608 | ||
| 609 | 609 | For type: class boost::multiprecision::number<class boost::multiprecision::backends::cpp_bin_float<50,10,void,int,0,0>,1>, | |
@@ -616,7 +616,7 @@ x == 1 (compared to uncertainty 7.3113127550e-26) is true | |||
| 616 | 616 | f(x) == (0 compared to uncertainty 7.3113127550e-26) is true | |
| 617 | 617 | -4.0000000000000000000000000000000000000000000000000 1.3333333333333333333333333333333333333333333333333 | |
| 618 | 618 | x at minimum = 0.99999999999999999999999999998813903221565569205253, f(0.99999999999999999999999999998813903221565569205253) = 5.6273022712501408640665300316078046703496236636624e-58 | |
| 619 | - 14 iterations. | ||
| 619 | + 14 iterations. | ||
| 620 | 620 | ||
| 621 | 621 | ||
| 622 | 622 | For type: class boost::multiprecision::number<class boost::multiprecision::backends::cpp_bin_float<50,10,void,int,0,0>,1>, | |
@@ -727,4 +727,4 @@ met 84 bits precision, after 14 iterations. | |||
| 727 | 727 | x == 1 (compared to uncertainty 7.3113127550e-26) is true | |
| 728 | 728 | f(x) == (0 compared to uncertainty 7.3113127550e-26) is true | |
| 729 | 729 | ||
| 730 | - */ | ||
| 730 | + */ | ||
@@ -116,7 +116,7 @@ and a success fraction 0.25, 25% or 1 in 4, is constructed like this: | |||
| 116 | 116 | negative_binomial mydist11(5, 0.4); // Using provided typedef of type double, and int and double arguments. | |
| 117 | 117 | /*` | |
| 118 | 118 | This is probably the most common usage. | |
| 119 | - Other combination are possible too: | ||
| 119 | + Other combination are possible too: | ||
| 120 | 120 | */ | |
| 121 | 121 | negative_binomial mydist12(5., 0.4F); // Double and float arguments. | |
| 122 | 122 | negative_binomial mydist13(5, 1); // Both arguments integer. | |
@@ -177,7 +177,7 @@ and a success fraction 0.25, 25% or 1 in 4, is constructed like this: | |||
| 177 | 177 | ||
| 178 | 178 | // Explicit long double precision: | |
| 179 | 179 | negative_binomial_distribution<long double> mydist7(8., 0.25); | |
| 180 | - | ||
| 180 | + | ||
| 181 | 181 | /*` | |
| 182 | 182 | And you can use your own template RealType, | |
| 183 | 183 | for example, `boost::math::cpp_bin_float_50` (an arbitrary 50 decimal digits precision type), | |
@@ -189,8 +189,8 @@ and a success fraction 0.25, 25% or 1 in 4, is constructed like this: | |||
| 189 | 189 | // `integer` arguments are promoted to your RealType exactly, but | |
| 190 | 190 | // `double` argument are converted to RealType, | |
| 191 | 191 | // most likely losing precision! | |
| 192 | - | ||
| 193 | - // So DON'T be tempted to write the 'obvious': | ||
| 192 | + | ||
| 193 | + // So DON'T be tempted to write the 'obvious': | ||
| 194 | 194 | negative_binomial_distribution<cpp_bin_float_50> mydist20(8, 0.23456789012345678901234567890); | |
| 195 | 195 | // to avoid truncation of second parameter to `0.2345678901234567` and loss of precision. | |
| 196 | 196 | ||
@@ -199,7 +199,7 @@ and a success fraction 0.25, 25% or 1 in 4, is constructed like this: | |||
| 199 | 199 | ||
| 200 | 200 | // Ensure that all potentially significant digits are shown. | |
| 201 | 201 | std::cout.precision(std::numeric_limits<cpp_bin_float_50>::digits10); | |
| 202 | - // | ||
| 202 | + // | ||
| 203 | 203 | cpp_bin_float_50 x("1.23456789012345678901234567890"); | |
| 204 | 204 | std::cout << pdf(mydist8, x) << std::endl; | |
| 205 | 205 | /*` showing 0.00012630010495970320103876754721976419438231705359935 | |
0 commit comments