policy_ref_snip8.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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_snip8
  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_nearest> >
  15. > dist_type;
  16. // Lower quantile rounded (down) to nearest:
  17. double x = quantile(dist_type(20, 0.3), 0.05); // 27
  18. // Upper quantile rounded (down) to nearest:
  19. double y = quantile(complement(dist_type(20, 0.3), 0.05)); // 68
  20. //] //[/policy_ref_snip8]
  21. #include <iostream>
  22. using std::cout; using std::endl;
  23. int main()
  24. {
  25. cout << "using policy<discrete_quantile<integer_round_nearest> " << 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_nearest>
  32. quantile(dist_type(20, 0.3), 0.05) = 27
  33. quantile(complement(dist_type(20, 0.3), 0.05)) 68
  34. */