2 * Copyright Nick Thompson, 2019
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)
8 #include "math_unit_test.hpp"
12 #include <boost/core/demangle.hpp>
13 #include <boost/math/statistics/anderson_darling.hpp>
14 #ifdef BOOST_HAS_FLOAT128
15 #include <boost/multiprecision/float128.hpp>
16 using boost::multiprecision::float128
;
20 using boost::math::statistics::anderson_darling_normality_statistic
;
22 void test_ad_normal_agreement_w_mathematica()
25 // data = RandomVariate[NormalDistribution[0.0, 1], 32];
26 // AndersonDarlingTest[data, NormalDistribution[0.0, 1.0], "TestStatistic"]
27 std::vector
<double> v
= {0.6018671202167422, 0.34935310534248165, -0.2975464874480147, 0.19075371678288966, 0.7871329594028097, 1.153968559452821,
28 -0.22255484635945819, 0.08509539017654276, -1.3495873906132927, 0.5579622886226612, -0.8781637835839865, 1.144016010880056,
29 0.3117638373078617, 1.2774825413798292, 0.24847416220730323, -0.5002468827503855, -0.23124277830160153, 0.1880980838556693,
30 -1.2249409521605903, 2.583585311795, -1.4237305768919715, -0.7613985266437971, -1.089096700141564, -1.2595396780059587,
31 -0.735507006841229, -0.6957024998691735, 0.24671590370045435, 0.24620128485023313, -2.4445908627621833, 0.1882647961008893,
32 1.8527432579288248, -0.1908629038857823, -1.6542624501251562, 1.414542907065601, 0.8188282235404601, -0.5040501225935047,
33 -1.634617885381599, -0.43608956281596023, -1.7347258501594351, 0.8387606547880405, 0.3554282034994122, -0.27872688042721255,
34 -1.6445047421517192, 1.0262620986278987, -0.14517030192098415, -0.15386932114942647, -0.13364750619758223, 0.27194802295714676,
35 -0.6396907621289796, 0.3390884293844603, -0.08298748318375798, -0.7165572035514544, -0.2580817977433051, -1.9250094572058072,
36 -0.07995578394716944, -1.146629910012214, -2.0053073148074665, -1.6745995591714353, 0.2973860474005926, -0.4981763213542575,
37 0.22190763958244972, 0.699111028057888, -1.1872952966557475, 0.6151420566782272};
39 double expected
= 1.542329830419774;
40 std::sort(v
.begin(), v
.end());
41 double ADtest
= anderson_darling_normality_statistic(v
, 0.0, 1.0);
43 CHECK_ULP_CLOSE(expected
, ADtest
, 250);
49 ADtest
= anderson_darling_normality_statistic(v
, 0.0, sigma
);
50 CHECK_ULP_CLOSE(expected
, ADtest
, 250);
56 ADtest
= anderson_darling_normality_statistic(v
, mu
, sigma
);
57 CHECK_ULP_CLOSE(expected
, ADtest
, 250);
62 test_ad_normal_agreement_w_mathematica();
63 return boost::math::test::report_errors();