policy_ref_snip6.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. // Note that this file contains quickbook mark-up as well as code
  7. // and comments, don't change any of the special comment mark-ups!
  8. //[policy_ref_snip6
  9. #include <boost/math/distributions/negative_binomial.hpp>
  10. using boost::math::negative_binomial;
  11. // Use the default rounding policy integer_round_outwards.
  12. // Lower quantile rounded down:
  13. double x = quantile(negative_binomial(20, 0.3), 0.05); // rounded up 27 from 27.3898
  14. // Upper quantile rounded up:
  15. double y = quantile(complement(negative_binomial(20, 0.3), 0.05)); // rounded down to 69 from 68.1584
  16. //] //[/policy_ref_snip6]
  17. #include <iostream>
  18. using std::cout; using std::endl;
  19. int main()
  20. {
  21. cout << "quantile(negative_binomial(20, 0.3), 0.05) = "<< x <<endl
  22. << "quantile(complement(negative_binomial(20, 0.3), 0.05)) = " << y << endl;
  23. }
  24. /*
  25. Output:
  26. quantile(negative_binomial(20, 0.3), 0.05) = 27
  27. quantile(complement(negative_binomial(20, 0.3), 0.05)) = 69
  28. */