]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/example/arcsine_example.cpp
3 // Copyright John Maddock 2014.
4 // Copyright Paul A. Bristow 2014.
6 // Use, modification and distribution are subject to the
7 // Boost Software License, Version 1.0.
8 // (See accompanying file LICENSE_1_0.txt
9 // or copy at http://www.boost.org/LICENSE_1_0.txt)
11 // Example for the arcsine Distribution.
13 // Note: Contains Quickbook snippets in comments.
16 #include <boost/math/distributions/arcsine.hpp> // For arcsine_distribution.
21 #include <boost/assert.hpp>
25 std::cout
<< "Examples of Arcsine distribution." << std::endl
;
26 std::cout
.precision(3); // Avoid uninformative decimal digits.
28 using boost::math::arcsine
;
30 arcsine as
; // Construct a default `double` standard [0, 1] arcsine distribution.
33 std::cout
<< pdf(as
, 1. / 2) << std::endl
; // 0.637
34 // pdf has a minimum at x = 0.5
38 std::cout
<< pdf(as
, 1. / 4) << std::endl
; // 0.735
43 std::cout
<< cdf(as
, 0.05) << std::endl
; // 0.144
47 std::cout
<< 2 * cdf(as
, 1 - 0.975) << std::endl
; // 0.202
52 std::cout
<< 2 * cdf(complement(as
, 0.975)) << std::endl
; // 0.202
56 std::cout
<< quantile(as
, 1 - 0.2 / 2) << std::endl
; // 0.976
58 std::cout
<< quantile(complement(as
, 0.2 / 2)) << std::endl
; // 0.976
63 using boost::math::arcsine_distribution
;
65 arcsine_distribution
<> as(2, 5); // Cconstructs a double arcsine distribution.
66 BOOST_ASSERT(as
.x_min() == 2.); // as.x_min() returns 2.
67 BOOST_ASSERT(as
.x_max() == 5.); // as.x_max() returns 5.
77 Example of Arcsine distribution