1 // Copyright Evan Miller 2020
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 #include <boost/math/tools/ulps_plot.hpp>
8 #include <boost/core/demangle.hpp>
9 #include <boost/math/distributions/kolmogorov_smirnov.hpp>
11 using boost::math::tools::ulps_plot
;
14 using PreciseReal
= long double;
15 using CoarseReal
= float;
17 boost::math::kolmogorov_smirnov_distribution
<CoarseReal
> dist_coarse(10);
18 auto pdf_coarse
= [&, dist_coarse
](CoarseReal x
) {
19 return boost::math::pdf(dist_coarse
, x
);
21 boost::math::kolmogorov_smirnov_distribution
<PreciseReal
> dist_precise(10);
22 auto pdf_precise
= [&, dist_precise
](PreciseReal x
) {
23 return boost::math::pdf(dist_precise
, x
);
28 PreciseReal clip
= 100;
30 std::string filename1
= "kolmogorov_smirnov_pdf_" + boost::core::demangle(typeid(CoarseReal
).name()) + ".svg";
31 auto plot1
= ulps_plot
<decltype(pdf_precise
), PreciseReal
, CoarseReal
>(pdf_precise
, 0.0, 1.0, samples
);
32 plot1
.clip(clip
).width(width
);
33 std::string title1
= "Kolmogorov-Smirnov PDF (N=10) ULP plot at " + boost::core::demangle(typeid(CoarseReal
).name()) + " precision";
35 plot1
.vertical_lines(10);
36 plot1
.add_fn(pdf_coarse
);
37 plot1
.write(filename1
);