policy_ref_snip7.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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_snip7
  9. #include <boost/math/distributions/negative_binomial.hpp>
  10. using boost::math::negative_binomial_distribution;
  11. using namespace boost::math::policies;
  12. typedef negative_binomial_distribution<
  13. double,
  14. policy<discrete_quantile<integer_round_inwards> >
  15. > dist_type;
  16. // Lower quantile rounded up:
  17. double x = quantile(dist_type(20, 0.3), 0.05); // 28 rounded up from 27.3898
  18. // Upper quantile rounded down:
  19. double y = quantile(complement(dist_type(20, 0.3), 0.05)); // 68 rounded down from 68.1584
  20. //] //[/policy_ref_snip7]
  21. #include <iostream>
  22. using std::cout; using std::endl;
  23. int main()
  24. {
  25. cout << "using policy<discrete_quantile<integer_round_inwards> > " << endl
  26. << "quantile(dist_type(20, 0.3), 0.05) = " << x << endl
  27. << "quantile(complement(dist_type(20, 0.3), 0.05)) = " << y << endl;
  28. }
  29. /*
  30. Output:
  31. using policy<discrete_quantile<integer_round_inwards> >
  32. quantile(dist_type(20, 0.3), 0.05) = 28
  33. quantile(complement(dist_type(20, 0.3), 0.05)) = 68
  34. */