]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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_snip6 | |
11 | ||
12 | #include <boost/math/distributions/negative_binomial.hpp> | |
13 | using boost::math::negative_binomial; | |
14 | ||
15 | // Use the default rounding policy integer_round_outwards. | |
16 | // Lower quantile rounded down: | |
17 | double x = quantile(negative_binomial(20, 0.3), 0.05); // rounded up 27 from 27.3898 | |
18 | // Upper quantile rounded up: | |
19 | double y = quantile(complement(negative_binomial(20, 0.3), 0.05)); // rounded down to 69 from 68.1584 | |
20 | ||
21 | //] //[/policy_ref_snip6] | |
22 | ||
23 | #include <iostream> | |
24 | using std::cout; using std::endl; | |
25 | ||
26 | int main() | |
27 | { | |
28 | cout << "quantile(negative_binomial(20, 0.3), 0.05) = "<< x <<endl | |
29 | << "quantile(complement(negative_binomial(20, 0.3), 0.05)) = " << y << endl; | |
30 | } | |
31 | ||
32 | /* | |
33 | Output: | |
34 | ||
35 | quantile(negative_binomial(20, 0.3), 0.05) = 27 | |
36 | quantile(complement(negative_binomial(20, 0.3), 0.05)) = 69 | |
37 | */ | |
38 |