• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
7 // Note that this file contains quickbook mark-up as well as code
8 // and comments, don't change any of the special comment mark-ups!
9 
10 //[policy_ref_snip8
11 
12 #include <boost/math/distributions/negative_binomial.hpp>
13 using boost::math::negative_binomial_distribution;
14 
15 using namespace boost::math::policies;
16 
17 typedef negative_binomial_distribution<
18       double,
19       policy<discrete_quantile<integer_round_nearest> >
20    > dist_type;
21 
22 // Lower quantile rounded (down) to nearest:
23 double x = quantile(dist_type(20, 0.3), 0.05); // 27
24 // Upper quantile rounded (down) to nearest:
25 double y = quantile(complement(dist_type(20, 0.3), 0.05)); // 68
26 
27 //] //[/policy_ref_snip8]
28 
29 #include <iostream>
30 using std::cout; using std::endl;
31 
main()32 int main()
33 {
34    cout << "using policy<discrete_quantile<integer_round_nearest> " << endl
35      << "quantile(dist_type(20, 0.3), 0.05) = " << x << endl
36      << "quantile(complement(dist_type(20, 0.3), 0.05)) " << y << endl;
37 }
38 
39 /*
40 
41 Output:
42 
43    using policy<discrete_quantile<integer_round_nearest>
44   quantile(dist_type(20, 0.3), 0.05) = 27
45   quantile(complement(dist_type(20, 0.3), 0.05)) 68
46 
47 */
48