]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/reporting/accuracy/plot_kolmogorov_smirnov_pdf.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / math / reporting / accuracy / plot_kolmogorov_smirnov_pdf.cpp
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)
5
6 #include <iostream>
7 #include <boost/math/tools/ulps_plot.hpp>
8 #include <boost/core/demangle.hpp>
9 #include <boost/math/distributions/kolmogorov_smirnov.hpp>
10
11 using boost::math::tools::ulps_plot;
12
13 int main() {
14 using PreciseReal = long double;
15 using CoarseReal = float;
16
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);
20 };
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);
24 };
25
26 int samples = 2500;
27 int width = 800;
28 PreciseReal clip = 100;
29
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";
34 plot1.title(title1);
35 plot1.vertical_lines(10);
36 plot1.add_fn(pdf_coarse);
37 plot1.write(filename1);
38 }