policy_ref_snip5.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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_snip5
  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<real> >
  15. > dist_type;
  16. // Lower 5% quantile:
  17. double x = quantile(dist_type(20, 0.3), 0.05);
  18. // Upper 95% quantile:
  19. double y = quantile(complement(dist_type(20, 0.3), 0.05));
  20. //] //[/policy_ref_snip5]
  21. #include <iostream>
  22. using std::cout; using std::endl;
  23. int main()
  24. {
  25. cout << "quantile(dist_type(20, 0.3), 0.05) = " << x
  26. << "\nquantile(complement(dist_type(20, 0.3), 0.05) = " << y << endl;
  27. }
  28. /*
  29. Output:
  30. quantile(dist_type(20, 0.3), 0.05) = 27.3898
  31. quantile(complement(dist_type(20, 0.3), 0.05) = 68.1584
  32. */