]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/test/test_skew_normal.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / math / test / test_skew_normal.cpp
1 // Copyright Paul A. Bristow 2012.
2 // Copyright John Maddock 2012.
3 // Copyright Benjamin Sobotta 2012
4
5 // Use, modification and distribution are subject to the
6 // Boost Software License, Version 1.0.
7 // (See accompanying file LICENSE_1_0.txt
8 // or copy at http://www.boost.org/LICENSE_1_0.txt)
9
10 #ifdef _MSC_VER
11 # pragma warning (disable : 4127) // conditional expression is constant.
12 # pragma warning (disable : 4305) // 'initializing' : truncation from 'double' to 'const float'.
13 # pragma warning (disable : 4310) // cast truncates constant value.
14 # pragma warning (disable : 4512) // assignment operator could not be generated.
15 #endif
16
17 //#include <pch.hpp> // include directory libs/math/src/tr1/ is needed.
18
19 #include <boost/math/concepts/real_concept.hpp> // for real_concept
20 #define BOOST_TEST_MAIN
21 #include <boost/test/unit_test.hpp> // Boost.Test
22 #include <boost/test/tools/floating_point_comparison.hpp>
23
24 #include <boost/math/distributions/skew_normal.hpp>
25 using boost::math::skew_normal_distribution;
26 using boost::math::skew_normal;
27 #include <boost/math/tools/test.hpp>
28
29 #include <iostream>
30 #include <iomanip>
31 using std::cout;
32 using std::endl;
33 using std::setprecision;
34 #include <limits>
35 using std::numeric_limits;
36 #include "test_out_of_range.hpp"
37
38 template <class RealType>
39 void check_skew_normal(RealType mean, RealType scale, RealType shape, RealType x, RealType p, RealType q, RealType tol)
40 {
41 using boost::math::skew_normal_distribution;
42
43 BOOST_CHECK_CLOSE_FRACTION(
44 ::boost::math::cdf( // Check cdf
45 skew_normal_distribution<RealType>(mean, scale, shape), // distribution.
46 x), // random variable.
47 p, // probability.
48 tol); // tolerance.
49 BOOST_CHECK_CLOSE_FRACTION(
50 ::boost::math::cdf( // Check cdf complement
51 complement(
52 skew_normal_distribution<RealType>(mean, scale, shape), // distribution.
53 x)), // random variable.
54 q, // probability complement.
55 tol); // %tolerance.
56 BOOST_CHECK_CLOSE_FRACTION(
57 ::boost::math::quantile( // Check quantile
58 skew_normal_distribution<RealType>(mean, scale, shape), // distribution.
59 p), // probability.
60 x, // random variable.
61 tol); // tolerance.
62 BOOST_CHECK_CLOSE_FRACTION(
63 ::boost::math::quantile( // Check quantile complement
64 complement(
65 skew_normal_distribution<RealType>(mean, scale, shape), // distribution.
66 q)), // probability complement.
67 x, // random variable.
68 tol); // tolerance.
69
70 skew_normal_distribution<RealType> dist (mean, scale, shape);
71
72 if((p < 0.999) && (q < 0.999))
73 { // We can only check this if P is not too close to 1,
74 // so that we can guarantee Q is accurate:
75 BOOST_CHECK_CLOSE_FRACTION(
76 cdf(complement(dist, x)), q, tol); // 1 - cdf
77 BOOST_CHECK_CLOSE_FRACTION(
78 quantile(dist, p), x, tol); // quantile(cdf) = x
79 BOOST_CHECK_CLOSE_FRACTION(
80 quantile(complement(dist, q)), x, tol); // quantile(complement(1 - cdf)) = x
81 }
82 } // template <class RealType>void check_skew_normal()
83
84
85 template <class RealType>
86 void test_spots(RealType)
87 {
88 // Basic sanity checks
89 RealType tolerance = 1e-4f; // 1e-4 (as %)
90
91 // Check some bad parameters to the distribution,
92 #ifndef BOOST_NO_EXCEPTIONS
93 BOOST_MATH_CHECK_THROW(boost::math::skew_normal_distribution<RealType> nbad1(0, 0), std::domain_error); // zero sd
94 BOOST_MATH_CHECK_THROW(boost::math::skew_normal_distribution<RealType> nbad1(0, -1), std::domain_error); // negative sd
95 #else
96 BOOST_MATH_CHECK_THROW(boost::math::skew_normal_distribution<RealType>(0, 0), std::domain_error); // zero sd
97 BOOST_MATH_CHECK_THROW(boost::math::skew_normal_distribution<RealType>(0, -1), std::domain_error); // negative sd
98 #endif
99 // Tests on extreme values of random variate x, if has numeric_limit infinity etc.
100 skew_normal_distribution<RealType> N01;
101 if(std::numeric_limits<RealType>::has_infinity)
102 {
103 BOOST_CHECK_EQUAL(pdf(N01, +std::numeric_limits<RealType>::infinity()), 0); // x = + infinity, pdf = 0
104 BOOST_CHECK_EQUAL(pdf(N01, -std::numeric_limits<RealType>::infinity()), 0); // x = - infinity, pdf = 0
105 BOOST_CHECK_EQUAL(cdf(N01, +std::numeric_limits<RealType>::infinity()), 1); // x = + infinity, cdf = 1
106 BOOST_CHECK_EQUAL(cdf(N01, -std::numeric_limits<RealType>::infinity()), 0); // x = - infinity, cdf = 0
107 BOOST_CHECK_EQUAL(cdf(complement(N01, +std::numeric_limits<RealType>::infinity())), 0); // x = + infinity, c cdf = 0
108 BOOST_CHECK_EQUAL(cdf(complement(N01, -std::numeric_limits<RealType>::infinity())), 1); // x = - infinity, c cdf = 1
109 #ifndef BOOST_NO_EXCEPTIONS
110 BOOST_MATH_CHECK_THROW(boost::math::skew_normal_distribution<RealType> nbad1(std::numeric_limits<RealType>::infinity(), static_cast<RealType>(1)), std::domain_error); // +infinite mean
111 BOOST_MATH_CHECK_THROW(boost::math::skew_normal_distribution<RealType> nbad1(-std::numeric_limits<RealType>::infinity(), static_cast<RealType>(1)), std::domain_error); // -infinite mean
112 BOOST_MATH_CHECK_THROW(boost::math::skew_normal_distribution<RealType> nbad1(static_cast<RealType>(0), std::numeric_limits<RealType>::infinity()), std::domain_error); // infinite sd
113 #else
114 BOOST_MATH_CHECK_THROW(boost::math::skew_normal_distribution<RealType>(std::numeric_limits<RealType>::infinity(), static_cast<RealType>(1)), std::domain_error); // +infinite mean
115 BOOST_MATH_CHECK_THROW(boost::math::skew_normal_distribution<RealType>(-std::numeric_limits<RealType>::infinity(), static_cast<RealType>(1)), std::domain_error); // -infinite mean
116 BOOST_MATH_CHECK_THROW(boost::math::skew_normal_distribution<RealType>(static_cast<RealType>(0), std::numeric_limits<RealType>::infinity()), std::domain_error); // infinite sd
117 #endif
118 }
119
120 if (std::numeric_limits<RealType>::has_quiet_NaN)
121 {
122 // No longer allow x to be NaN, then these tests should throw.
123 BOOST_MATH_CHECK_THROW(pdf(N01, +std::numeric_limits<RealType>::quiet_NaN()), std::domain_error); // x = NaN
124 BOOST_MATH_CHECK_THROW(cdf(N01, +std::numeric_limits<RealType>::quiet_NaN()), std::domain_error); // x = NaN
125 BOOST_MATH_CHECK_THROW(cdf(complement(N01, +std::numeric_limits<RealType>::quiet_NaN())), std::domain_error); // x = + infinity
126 BOOST_MATH_CHECK_THROW(quantile(N01, +std::numeric_limits<RealType>::quiet_NaN()), std::domain_error); // p = + infinity
127 BOOST_MATH_CHECK_THROW(quantile(complement(N01, +std::numeric_limits<RealType>::quiet_NaN())), std::domain_error); // p = + infinity
128 }
129
130 BOOST_CHECK_EQUAL(mean(N01), 0);
131 BOOST_CHECK_EQUAL(mode(N01), 0);
132 BOOST_CHECK_EQUAL(variance(N01), 1);
133 BOOST_CHECK_EQUAL(skewness(N01), 0);
134 BOOST_CHECK_EQUAL(kurtosis_excess(N01), 0);
135
136 cout << "Tolerance for type " << typeid(RealType).name() << " is " << tolerance << " %" << endl;
137
138 // Tests where shape = 0, so same as normal tests.
139 // (These might be removed later).
140 check_skew_normal(
141 static_cast<RealType>(5),
142 static_cast<RealType>(2),
143 static_cast<RealType>(0),
144 static_cast<RealType>(4.8),
145 static_cast<RealType>(0.46017),
146 static_cast<RealType>(1 - 0.46017),
147 tolerance);
148
149 check_skew_normal(
150 static_cast<RealType>(5),
151 static_cast<RealType>(2),
152 static_cast<RealType>(0),
153 static_cast<RealType>(5.2),
154 static_cast<RealType>(1 - 0.46017),
155 static_cast<RealType>(0.46017),
156 tolerance);
157
158 check_skew_normal(
159 static_cast<RealType>(5),
160 static_cast<RealType>(2),
161 static_cast<RealType>(0),
162 static_cast<RealType>(2.2),
163 static_cast<RealType>(0.08076),
164 static_cast<RealType>(1 - 0.08076),
165 tolerance);
166
167 check_skew_normal(
168 static_cast<RealType>(5),
169 static_cast<RealType>(2),
170 static_cast<RealType>(0),
171 static_cast<RealType>(7.8),
172 static_cast<RealType>(1 - 0.08076),
173 static_cast<RealType>(0.08076),
174 tolerance);
175
176 check_skew_normal(
177 static_cast<RealType>(-3),
178 static_cast<RealType>(5),
179 static_cast<RealType>(0),
180 static_cast<RealType>(-4.5),
181 static_cast<RealType>(0.38209),
182 static_cast<RealType>(1 - 0.38209),
183 tolerance);
184
185 check_skew_normal(
186 static_cast<RealType>(-3),
187 static_cast<RealType>(5),
188 static_cast<RealType>(0),
189 static_cast<RealType>(-1.5),
190 static_cast<RealType>(1 - 0.38209),
191 static_cast<RealType>(0.38209),
192 tolerance);
193
194 check_skew_normal(
195 static_cast<RealType>(-3),
196 static_cast<RealType>(5),
197 static_cast<RealType>(0),
198 static_cast<RealType>(-8.5),
199 static_cast<RealType>(0.13567),
200 static_cast<RealType>(1 - 0.13567),
201 tolerance);
202
203 check_skew_normal(
204 static_cast<RealType>(-3),
205 static_cast<RealType>(5),
206 static_cast<RealType>(0),
207 static_cast<RealType>(2.5),
208 static_cast<RealType>(1 - 0.13567),
209 static_cast<RealType>(0.13567),
210 tolerance);
211
212 // Tests where shape != 0, specific to skew_normal distribution.
213 //void check_skew_normal(RealType mean, RealType scale, RealType shape, RealType x, RealType p, RealType q, RealType tol)
214 check_skew_normal( // 1st R example.
215 static_cast<RealType>(1.1),
216 static_cast<RealType>(2.2),
217 static_cast<RealType>(-3.3),
218 static_cast<RealType>(0.4), // x
219 static_cast<RealType>(0.733918618927874), // p == psn
220 static_cast<RealType>(1 - 0.733918618927874), // q
221 tolerance);
222
223 // Not sure about these yet.
224 //check_skew_normal( // 2nd R example.
225 //static_cast<RealType>(1.1),
226 //static_cast<RealType>(0.02),
227 //static_cast<RealType>(0.03),
228 //static_cast<RealType>(1.3), // x
229 //static_cast<RealType>(0.01), // p
230 //static_cast<RealType>(0.09), // q
231 //tolerance);
232 //check_skew_normal( // 3nd R example.
233 //static_cast<RealType>(10.1),
234 //static_cast<RealType>(5.),
235 //static_cast<RealType>(-0.03),
236 //static_cast<RealType>(-1.3), // x
237 //static_cast<RealType>(0.01201290665838824), // p
238 //static_cast<RealType>(1. - 0.01201290665838824), // q 0.987987101
239 //tolerance);
240
241 // Tests for PDF: we know that the normal peak value is at 1/sqrt(2*pi)
242 //
243 tolerance = boost::math::tools::epsilon<RealType>() * 5; // 5 eps as a fraction
244 BOOST_CHECK_CLOSE_FRACTION(
245 pdf(skew_normal_distribution<RealType>(), static_cast<RealType>(0)),
246 static_cast<RealType>(0.3989422804014326779399460599343818684759L), // 1/sqrt(2*pi)
247 tolerance);
248 BOOST_CHECK_CLOSE_FRACTION(
249 pdf(skew_normal_distribution<RealType>(3), static_cast<RealType>(3)),
250 static_cast<RealType>(0.3989422804014326779399460599343818684759L),
251 tolerance);
252 BOOST_CHECK_CLOSE_FRACTION(
253 pdf(skew_normal_distribution<RealType>(3, 5), static_cast<RealType>(3)),
254 static_cast<RealType>(0.3989422804014326779399460599343818684759L / 5),
255 tolerance);
256
257 // Shape != 0.
258 BOOST_CHECK_CLOSE_FRACTION(
259 pdf(skew_normal_distribution<RealType>(3,5,1e-6), static_cast<RealType>(3)),
260 static_cast<RealType>(0.3989422804014326779399460599343818684759L / 5),
261 tolerance);
262
263
264 // Checks on mean, variance cumulants etc.
265 // Checks on shape ==0
266
267 RealType tol5 = boost::math::tools::epsilon<RealType>() * 5;
268 skew_normal_distribution<RealType> dist(8, 3);
269 RealType x = static_cast<RealType>(0.125);
270
271 BOOST_MATH_STD_USING // ADL of std math lib names
272
273 // mean:
274 BOOST_CHECK_CLOSE(
275 mean(dist)
276 , static_cast<RealType>(8), tol5);
277 // variance:
278 BOOST_CHECK_CLOSE(
279 variance(dist)
280 , static_cast<RealType>(9), tol5);
281 // std deviation:
282 BOOST_CHECK_CLOSE(
283 standard_deviation(dist)
284 , static_cast<RealType>(3), tol5);
285 // hazard:
286 BOOST_CHECK_CLOSE(
287 hazard(dist, x)
288 , pdf(dist, x) / cdf(complement(dist, x)), tol5);
289 // cumulative hazard:
290 BOOST_CHECK_CLOSE(
291 chf(dist, x)
292 , -log(cdf(complement(dist, x))), tol5);
293 // coefficient_of_variation:
294 BOOST_CHECK_CLOSE(
295 coefficient_of_variation(dist)
296 , standard_deviation(dist) / mean(dist), tol5);
297 // mode:
298 BOOST_CHECK_CLOSE_FRACTION(mode(dist), static_cast<RealType>(8), 0.001f);
299
300 BOOST_CHECK_CLOSE(
301 median(dist)
302 , static_cast<RealType>(8), tol5);
303
304 // skewness:
305 BOOST_CHECK_CLOSE(
306 skewness(dist)
307 , static_cast<RealType>(0), tol5);
308 // kurtosis:
309 BOOST_CHECK_CLOSE(
310 kurtosis(dist)
311 , static_cast<RealType>(3), tol5);
312 // kurtosis excess:
313 BOOST_CHECK_CLOSE(
314 kurtosis_excess(dist)
315 , static_cast<RealType>(0), tol5);
316
317 skew_normal_distribution<RealType> norm01(0, 1); // Test default (0, 1)
318 BOOST_CHECK_CLOSE(
319 mean(norm01),
320 static_cast<RealType>(0), 0); // Mean == zero
321
322 skew_normal_distribution<RealType> defsd_norm01(0); // Test default (0, sd = 1)
323 BOOST_CHECK_CLOSE(
324 mean(defsd_norm01),
325 static_cast<RealType>(0), 0); // Mean == zero
326
327 skew_normal_distribution<RealType> def_norm01; // Test default (0, sd = 1)
328 BOOST_CHECK_CLOSE(
329 mean(def_norm01),
330 static_cast<RealType>(0), 0); // Mean == zero
331
332 BOOST_CHECK_CLOSE(
333 standard_deviation(def_norm01),
334 static_cast<RealType>(1), 0); //
335
336 BOOST_CHECK_CLOSE(
337 mode(def_norm01),
338 static_cast<RealType>(0), 0); // Mode == zero
339
340
341 // Skew_normal tests with shape != 0.
342 {
343 // Note these tolerances are expressed as percentages, hence the extra * 100 on the end:
344 RealType tol10 = boost::math::tools::epsilon<RealType>() * 10 * 100;
345 RealType tol100 = boost::math::tools::epsilon<RealType>() * 100 * 100;
346
347 //skew_normal_distribution<RealType> dist(1.1, 0.02, 0.03);
348
349 BOOST_MATH_STD_USING // ADL of std math lib names.
350
351 // Test values from R = see skew_normal_drv.cpp which included the R code used.
352 {
353 dist = skew_normal_distribution<RealType>(static_cast<RealType>(1.1l), static_cast<RealType>(2.2l), static_cast<RealType>(-3.3l));
354
355 BOOST_CHECK_CLOSE( // mean:
356 mean(dist)
357 , static_cast<RealType>(-0.579908992539856825862549L), tol10 * 2);
358
359 std::cout << std::setprecision(17) << "Variance = " << variance(dist) << std::endl;
360 BOOST_CHECK_CLOSE( // variance: N[variance[skewnormaldistribution[1.1, 2.2, -3.3]], 50]
361 variance(dist)
362 , static_cast<RealType>(2.0179057767837232633904061072049998357047989154484L), tol10);
363
364 BOOST_CHECK_CLOSE( // skewness:
365 skewness(dist)
366 , static_cast<RealType>(-0.709854548171537509192897824663L), tol100);
367 BOOST_CHECK_CLOSE( // kurtosis:
368 kurtosis(dist)
369 , static_cast<RealType>(3.5538752625241790601377L), tol100);
370 BOOST_CHECK_CLOSE( // kurtosis excess:
371 kurtosis_excess(dist)
372 , static_cast<RealType>(0.5538752625241790601377L), tol100);
373
374 BOOST_CHECK_CLOSE(
375 pdf(dist, static_cast<RealType>(0.4L)),
376 static_cast<RealType>(0.294140110156599539564571L),
377 tol10);
378
379 BOOST_CHECK_CLOSE(
380 cdf(dist, static_cast<RealType>(0.4L)),
381 static_cast<RealType>(0.7339186189278737976326676452L),
382 tol100);
383
384 BOOST_CHECK_CLOSE(
385 quantile(dist, static_cast<RealType>(0.3L)),
386 static_cast<RealType>(-1.180104068086875314419247L),
387 tol100);
388
389
390 { // mode tests
391
392 dist = skew_normal_distribution<RealType>(static_cast<RealType>(0.l), static_cast<RealType>(1.l), static_cast<RealType>(4.l));
393
394 // cout << "pdf(dist, 0) = " << pdf(dist, 0) << ", pdf(dist, 0.45) = " << pdf(dist, 0.45) << endl;
395 // BOOST_CHECK_CLOSE(mode(dist), boost::math::constants::root_two<RealType>() / 2, tol5);
396 BOOST_CHECK_CLOSE(mode(dist), static_cast<RealType>(0.41697299497388863932L), tol100);
397 }
398
399
400 }
401 {
402 dist = skew_normal_distribution<RealType>(static_cast<RealType>(1.1l), static_cast<RealType>(0.02l), static_cast<RealType>(0.03l));
403
404 BOOST_CHECK_CLOSE( // mean:
405 mean(dist)
406 , static_cast<RealType>(1.1004785154529557886162L), tol10);
407 BOOST_CHECK_CLOSE( // variance:
408 variance(dist)
409 , static_cast<RealType>(0.00039977102296128251645L), tol10);
410
411 BOOST_CHECK_CLOSE( // skewness:
412 skewness(dist)
413 , static_cast<RealType>(5.8834811259890359782e-006L), tol100);
414 BOOST_CHECK_CLOSE( // kurtosis:
415 kurtosis(dist)
416 , static_cast<RealType>(3.L + 9.2903475812137800239002e-008L), tol100);
417 BOOST_CHECK_CLOSE( // kurtosis excess:
418 kurtosis_excess(dist)
419 , static_cast<RealType>(9.2903475812137800239002e-008L), tol100);
420 }
421 {
422 dist = skew_normal_distribution<RealType>(static_cast<RealType>(10.1l), static_cast<RealType>(5.l), static_cast<RealType>(-0.03l));
423 BOOST_CHECK_CLOSE( // mean:
424 mean(dist)
425 , static_cast<RealType>(9.9803711367610528459485937L), tol10);
426 BOOST_CHECK_CLOSE( // variance:
427 variance(dist)
428 , static_cast<RealType>(24.98568893508015727823L), tol10);
429
430 BOOST_CHECK_CLOSE( // skewness:
431 skewness(dist)
432 , static_cast<RealType>(-5.8834811259890359782085e-006L), tol100);
433 BOOST_CHECK_CLOSE( // kurtosis:
434 kurtosis(dist)
435 , static_cast<RealType>(3.L + 9.2903475812137800239002e-008L), tol100);
436 BOOST_CHECK_CLOSE( // kurtosis excess:
437 kurtosis_excess(dist)
438 , static_cast<RealType>(9.2903475812137800239002e-008L), tol100);
439 }
440 {
441 dist = skew_normal_distribution<RealType>(static_cast<RealType>(-10.1l), static_cast<RealType>(5.l), static_cast<RealType>(30.l));
442 BOOST_CHECK_CLOSE( // mean:
443 mean(dist)
444 , static_cast<RealType>(-6.11279169674138408531365L), 2 * tol10);
445 BOOST_CHECK_CLOSE( // variance:
446 variance(dist)
447 , static_cast<RealType>(9.10216994642554914628242L), tol10 * 2);
448
449 BOOST_CHECK_CLOSE( // skewness:
450 skewness(dist)
451 , static_cast<RealType>(0.99072425443686904424L), tol100);
452 BOOST_CHECK_CLOSE( // kurtosis:
453 kurtosis(dist)
454 , static_cast<RealType>(3.L + 0.8638862008406084244563L), tol100);
455 BOOST_CHECK_CLOSE( // kurtosis excess:
456 kurtosis_excess(dist)
457 , static_cast<RealType>(0.8638862008406084244563L), tol100);
458 }
459
460 BOOST_MATH_CHECK_THROW(cdf(skew_normal_distribution<RealType>(0, 0, 0), 0), std::domain_error);
461 BOOST_MATH_CHECK_THROW(cdf(skew_normal_distribution<RealType>(0, -1, 0), 0), std::domain_error);
462 BOOST_MATH_CHECK_THROW(quantile(skew_normal_distribution<RealType>(0, 1, 0), -1), std::domain_error);
463 BOOST_MATH_CHECK_THROW(quantile(skew_normal_distribution<RealType>(0, 1, 0), 2), std::domain_error);
464 check_out_of_range<skew_normal_distribution<RealType> >(1, 1, 1);
465 }
466
467
468 } // template <class RealType>void test_spots(RealType)
469
470 BOOST_AUTO_TEST_CASE( test_main )
471 {
472
473
474 using boost::math::skew_normal;
475 using boost::math::skew_normal_distribution;
476
477 //int precision = 17; // std::numeric_limits<double::max_digits10;
478 double tolfeweps = numeric_limits<double>::epsilon() * 5;
479 //double tol6decdigits = numeric_limits<float>::epsilon() * 2;
480 // Check that can generate skew_normal distribution using the two convenience methods:
481 boost::math::skew_normal w12(1., 2); // Using typedef.
482 boost::math::skew_normal_distribution<> w01; // Use default unity values for mean and scale.
483 // Note NOT myn01() as the compiler will interpret as a function!
484
485 // Checks on constructors.
486 // Default parameters.
487 BOOST_CHECK_EQUAL(w01.location(), 0);
488 BOOST_CHECK_EQUAL(w01.scale(), 1);
489 BOOST_CHECK_EQUAL(w01.shape(), 0);
490
491 skew_normal_distribution<> w23(2., 3); // Using default RealType double.
492 BOOST_CHECK_EQUAL(w23.scale(), 3);
493 BOOST_CHECK_EQUAL(w23.shape(), 0);
494
495 skew_normal_distribution<> w123(1., 2., 3.); // Using default RealType double.
496 BOOST_CHECK_EQUAL(w123.location(), 1.);
497 BOOST_CHECK_EQUAL(w123.scale(), 2.);
498 BOOST_CHECK_EQUAL(w123.shape(), 3.);
499
500 BOOST_CHECK_CLOSE_FRACTION(mean(w01), static_cast<double>(0), tolfeweps); // Default mean == zero
501 BOOST_CHECK_CLOSE_FRACTION(scale(w01), static_cast<double>(1), tolfeweps); // Default scale == unity
502
503 // Basic sanity-check spot values for all floating-point types..
504 // (Parameter value, arbitrarily zero, only communicates the floating point type).
505 test_spots(0.0F); // Test float. OK at decdigits = 0 tolerance = 0.0001 %
506 test_spots(0.0); // Test double. OK at decdigits 7, tolerance = 1e07 %
507 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
508 test_spots(0.0L); // Test long double.
509 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
510 test_spots(boost::math::concepts::real_concept(0.)); // Test real concept.
511 #endif
512 #else
513 std::cout << "<note>The long double tests have been disabled on this platform "
514 "either because the long double overloads of the usual math functions are "
515 "not available at all, or because they are too inaccurate for these tests "
516 "to pass.</note>" << std::endl;
517 #endif
518 /* */
519
520 } // BOOST_AUTO_TEST_CASE( test_main )
521
522 /*
523
524 Output:
525
526
527 */
528
529