1 // Copyright Thijs van den Berg, 2008.
2 // Copyright John Maddock 2008.
3 // Copyright Paul A. Bristow 2008, 2009, 2014.
4
5 // Use, modification and distribution are subject to the
6 // Boost Software License, Version 1.0. (See accompanying file
7 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8
9 // add few more tests for farther out than 2??
10 // long double test
11 // add test for convenience typedef laplace.
12 // Permit infinity arguments.
13 #ifdef _MSC_VER
14 #pragma warning (disable : 4127) // conditional expression is constant.
15 #endif
16
17 /*
18
19 This module tests the Laplace distribution.
20
21 Test 1: test_pdf_cdf_ocatave()
22 Compare pdf, cdf against results obtained from GNU Octave.
23
24 Test 2: test_cdf_quantile_symmetry()
25 Checks if quantile is the inverse of cdf by testing
26 quantile(cdf(x)) == x
27
28 Test 3: test_hazard_pdf_cdf_symmetry()
29 Checks the relation between hazard, pdf and cdf.
30 hazard = pdf/(1-cdf)
31
32
33 Test 4: test_location_scale_symmetry()
34 Checks the pdf, cdf invariant for translation and scaling invariant
35 cdf(x,location,scale) = cdf( (x-location)/scale, 0, 1)
36 scale * pdf(x,location,scale) = pdf( (x-location)/scale, 0, 1)
37
38 Test 5: test_mmm_moments()
39 Tests...
40 mean == location
41 mode == location
42 median == location
43
44 standard_deviation = sqrt(2)*scale
45 skewness == 0
46 kurtosis == 6
47 excess kurtosis == 3
48
49 Test 6: test_complemented()
50 Test the cdf an quantile complemented function.
51 cdf(L,x) + cdf(complement(l,x)) == 1
52 quantile(L,p) == quantile(complement(l,1-p))
53
54 Test 7: test_bad_dist_parameters()
55 Test invalid distribution construction.
56
57 Test 8: test_extreme_function_arguments()
58 Test x = +/- inf. for cdf(), pdf()
59 Test p ={0,1} for quantile()
60 */
61
62
63 #define BOOST_TEST_MAIN
64 #include <boost/test/unit_test.hpp>
65 #include <boost/math/tools/test.hpp>
66 #include <boost/math/constants/constants.hpp>
67 #include <boost/math/distributions/laplace.hpp>
68 #include "test_out_of_range.hpp"
69 using boost::math::laplace_distribution;
70
71 /*
72 #include <iostream>
73 using std::cout;
74 using std::endl;
75 using std::setprecision;
76
77 #include <limits>
78 using std::numeric_limits;
79 */
80
81 /*
82 This function test various values of the standard Laplace distribution pdf,cdf
83 against values generated by GNU Octave
84 The test code is generated with the following Octave script:
85
86 f = fopen('octave_boost_laplace.cpp', 'w');
87
88 for x = [real(-2.0), real(-1.0), real(-0.5), real(0.0), real(0.5), real(1.0), real(2.0)]
89
90 # pdf tests
91 # -----------------------
92 fdisp(f, " BOOST_CHECK_CLOSE(" ),;
93 fdisp(f, (sprintf (" pdf(laplace_distribution<RealType>(), static_cast<RealType>(%16.14fL)),", x)));
94 fdisp(f, (sprintf (" static_cast<RealType>(%16.14fL),", laplace_pdf(x) )) );
95 fdisp(f, " tolerance);" );
96 fdisp(f, "" );
97
98 # cdf tests
99 # -----------------------
100 fdisp(f, " BOOST_CHECK_CLOSE(" );
101 fdisp(f, (sprintf (" cdf(laplace_distribution<RealType>(), static_cast<RealType>(%16.14fL)),", x)));
102 fdisp(f, (sprintf (" static_cast<RealType>(%16.14fL),", laplace_cdf(x) )) );
103 fdisp(f, " tolerance);" );
104 fdisp(f, "" );
105
106 endfor
107
108 fclose(f);
109
110
111 Laplace distribution values version 2.0
112
113 Using NTL version 5.4 and the formula in Wikipedia Paul A. Bristow
114 NTL class RR precision 150 bits.
115 NTL class RR output precision 50 decimal digits OK.
116 Laplace pdf
117 -10 0.22699964881242425767795757780275305118959044437696e-4
118 -9.5 0.37425914943850295735594659677277583056493449453316e-4
119 -9 0.61704902043339774748818345365016913036076416123496e-4
120 -8.5 0.00010173418450532208718446671524353319364865576338509
121 -8 0.00016773131395125591941069456289043050965545006686111
122 -7.5 0.00027654218507391679155100004426517859890566829114007
123 -7 0.00045594098277725810400156804220464131323686226383407
124 -6.5 0.00075171959648878622369145166608382691500025647887521
125 -6 0.0012393760883331792115225837154083339457532397924584
126 -5.5 0.0020433857192320334967323513423603842041953283241185
127 -5 0.0033689734995427335483180242115742121244247925136568
128 -4.5 0.0055544982691211532480715671434652638857696337503689
129 -4 0.0091578194443670901468590106366206211059560337810038
130 -3.5 0.015098691711159250369893146181809922535830266119032
131 -3 0.024893534183931971489671207825030888315849796096331
132 -2.5 0.041042499311949397584764337233579903918902060509316
133 -2 0.067667641618306345946999747486242201703815772944649
134 -1.5 0.11156508007421491446664023538200626067108581471131
135 -1 0.18393972058572116079776188508073043372290556554506
136 -0.5 0.30326532985631671180189976749559022672095906778368
137 0 0.5
138 0.5 0.30326532985631671180189976749559022672095906778368
139 1 0.18393972058572116079776188508073043372290556554506
140 1.5 0.11156508007421491446664023538200626067108581471131
141 2 0.067667641618306345946999747486242201703815772944649
142 2.5 0.041042499311949397584764337233579903918902060509316
143 3 0.024893534183931971489671207825030888315849796096331
144 3.5 0.015098691711159250369893146181809922535830266119032
145 4 0.0091578194443670901468590106366206211059560337810038
146 4.5 0.0055544982691211532480715671434652638857696337503689
147 5 0.0033689734995427335483180242115742121244247925136568
148 5.5 0.0020433857192320334967323513423603842041953283241185
149 6 0.0012393760883331792115225837154083339457532397924584
150 6.5 0.00075171959648878622369145166608382691500025647887521
151 7 0.00045594098277725810400156804220464131323686226383407
152 7.5 0.00027654218507391679155100004426517859890566829114007
153 8 0.00016773131395125591941069456289043050965545006686111
154 8.5 0.00010173418450532208718446671524353319364865576338509
155 9 0.61704902043339774748818345365016913036076416123496e-4
156 9.5 0.37425914943850295735594659677277583056493449453316e-4
157 10 0.22699964881242425767795757780275305118959044437696e-4
158
159 Laplace cdf
160 -10 0.9999773000351187575742322042422197246948810411152
161 -9.5 0.99996257408505614970426440534032272241694350636029
162 -9 0.99993829509795666022525118165463498308696392404693
163 -8.5 0.99989826581549467791281553328475646680635134420916
164 -8 0.99983226868604874408058930543710956949034454956485
165 -7.5 0.9997234578149260832084489999557348214010943317417
166 -7 0.99954405901722274189599843195779535868676313746042
167 -6.5 0.99924828040351121377630854833391617308499974328643
168 -6 0.99876062391166682078847741628459166605424676032523
169 -5.5 0.99795661428076796650326764865763961579580467117776
170 -5 0.99663102650045726645168197578842578787557520756024
171 -4.5 0.9944455017308788467519284328565347361142303666328
172 -4 0.99084218055563290985314098936337937889404396651458
173 -3.5 0.98490130828884074963010685381819007746416973359633
174 -3 0.9751064658160680285103287921749691116841502037504
175 -2.5 0.95895750068805060241523566276642009608109793962206
176 -2 0.93233235838169365405300025251375779829618422688019
177 -1.5 0.8884349199257850855333597646179937393289141857266
178 -1 0.81606027941427883920223811491926956627709443427977
179 -0.5 0.69673467014368328819810023250440977327904093221632
180 0 0.5
181 0.5 0.30326532985631671180189976749559022672095906778368
182 1 0.18393972058572116079776188508073043372290556572023
183 1.5 0.11156508007421491446664023538200626067108581462372
184 2 0.067667641618306345946999747486242201703815773119812
185 2.5 0.041042499311949397584764337233579903918902060377944
186 3 0.024893534183931971489671207825030888315849796249598
187 3.5 0.015098691711159250369893146181809922535830266053346
188 4 0.009157819444367090146859010636620621105956033835742
189 4.5 0.005554498269121153248071567143465263885769633717526
190 5 0.0033689734995427335483180242115742121244247924397602
191 5.5 0.0020433857192320334967323513423603842041953284719117
192 6 0.0012393760883331792115225837154083339457532396747712
193 6.5 0.00075171959648878622369145166608382691500025636324071
194 7 0.00045594098277725810400156804220464131323686218925325
195 7.5 0.00027654218507391679155100004426517859890566825829713
196 8 0.00016773131395125591941069456289043050965545008482209
197 8.5 0.00010173418450532208718446671524353319364865579083973
198 9 0.61704902043339774748818345365016913036076303396971e-4
199 9.5 0.37425914943850295735594659677277583056493289386783e-4
200 10 0.22699964881242425767795757780275305118958884798806e-4
201
202 */
203 template <class RealType>
test_pdf_cdf_ocatave()204 void test_pdf_cdf_ocatave()
205 {
206 RealType tolerance(1e-10f);
207
208 BOOST_CHECK_CLOSE(
209 pdf(laplace_distribution<RealType>(), static_cast<RealType>(-2.L)),
210 // static_cast<RealType>(0.06766764161831L),
211 static_cast<RealType>(0.067667641618306345946999747486242201703815773119812L),
212 tolerance);
213
214 BOOST_CHECK_CLOSE(
215 cdf(laplace_distribution<RealType>(), static_cast<RealType>(-2.L)),
216 //static_cast<RealType>(0.06766764161831L),
217 static_cast<RealType>(0.067667641618306345946999747486242201703815773119812L),
218 tolerance);
219
220 BOOST_CHECK_CLOSE(
221 pdf(laplace_distribution<RealType>(), static_cast<RealType>(-1.L)),
222 //static_cast<RealType>(0.18393972058572L),
223 static_cast<RealType>(0.18393972058572116079776188508073043372290556554506L),
224 tolerance);
225
226 BOOST_CHECK_CLOSE(
227 cdf(laplace_distribution<RealType>(), static_cast<RealType>(-1.L)),
228 static_cast<RealType>(0.18393972058572L),
229 tolerance);
230
231 BOOST_CHECK_CLOSE(
232 pdf(laplace_distribution<RealType>(), static_cast<RealType>(-0.5L)),
233 // static_cast<RealType>(0.30326532985632L),
234 static_cast<RealType>(0.30326532985631671180189976749559022672095906778368L),
235 tolerance);
236
237 BOOST_CHECK_CLOSE(
238 cdf(laplace_distribution<RealType>(), static_cast<RealType>(-0.5L)),
239 //static_cast<RealType>(0.30326532985632L),
240 static_cast<RealType>(0.30326532985631671180189976749559022672095906778368L),
241 tolerance);
242
243 BOOST_CHECK_CLOSE(
244 pdf(laplace_distribution<RealType>(), static_cast<RealType>(0.0L)),
245 static_cast<RealType>(0.5L),
246 tolerance);
247
248 BOOST_CHECK_CLOSE(
249 cdf(laplace_distribution<RealType>(), static_cast<RealType>(0.0L)),
250 static_cast<RealType>(0.5L),
251 tolerance);
252
253 BOOST_CHECK_CLOSE(
254 pdf(laplace_distribution<RealType>(), static_cast<RealType>(0.5L)),
255 //static_cast<RealType>(0.30326532985632L),
256 static_cast<RealType>(0.30326532985631671180189976749559022672095906778368L),
257 tolerance);
258
259 BOOST_CHECK_CLOSE(
260 cdf(laplace_distribution<RealType>(), static_cast<RealType>(0.5L)),
261 // static_cast<RealType>(0.69673467014368L),
262 static_cast<RealType>(0.69673467014368328819810023250440977327904093221632L),
263 tolerance);
264
265 BOOST_CHECK_CLOSE(
266 pdf(laplace_distribution<RealType>(), static_cast<RealType>(1.0L)),
267 // static_cast<RealType>(0.18393972058572L),
268 static_cast<RealType>(0.18393972058572116079776188508073043372290556554506L),
269 tolerance);
270
271 BOOST_CHECK_CLOSE(
272 cdf(laplace_distribution<RealType>(), static_cast<RealType>(1.00000000000000L)),
273 // static_cast<RealType>(0.81606027941428L),
274 static_cast<RealType>(0.81606027941427883920223811491926956627709443427977L),
275 tolerance);
276
277 BOOST_CHECK_CLOSE(
278 pdf(laplace_distribution<RealType>(), static_cast<RealType>(2.0L)),
279 // static_cast<RealType>(0.06766764161831L),
280 static_cast<RealType>(0.067667641618306345946999747486242201703815772944649L),
281 tolerance);
282
283 BOOST_CHECK_CLOSE(
284 cdf(laplace_distribution<RealType>(), static_cast<RealType>(2.0L)),
285 // static_cast<RealType>(0.93233235838169L),
286 static_cast<RealType>(0.93233235838169365405300025251375779829618422688019L),
287 tolerance);
288
289 check_out_of_range<laplace_distribution<RealType> >(0, 1);
290 BOOST_MATH_CHECK_THROW(laplace_distribution<RealType>(0, 0), std::domain_error);
291 BOOST_MATH_CHECK_THROW(laplace_distribution<RealType>(0, -1), std::domain_error);
292 }
293
294 template <class RealType>
test_cdf_quantile_symmetry()295 void test_cdf_quantile_symmetry()
296 {
297 RealType tolerance(boost::math::tools::epsilon<RealType>() * 500); // 5 eps as a percentage.
298
299 const float xtest[7] = { -2.0, -1.0, -0.5, 0.0, 0.5, 1.0, 2.0 };
300
301 for (int i=0; i<7; ++i)
302 {
303 RealType x( static_cast<RealType>(xtest[i]) );
304 RealType x2( quantile(laplace_distribution<RealType>(), cdf(laplace_distribution<RealType>(), x)) );
305 BOOST_CHECK_CLOSE( x, x2, tolerance);
306 }
307 }
308
309 template <class RealType>
test_hazard_pdf_cdf_symmetry()310 void test_hazard_pdf_cdf_symmetry()
311 {
312 RealType tolerance(boost::math::tools::epsilon<RealType>() * 500); // 5 eps as a percentage
313
314 const float xtest[7] = { -2.0, -1.0, -0.5, 0.0, 0.5, 1.0, 2.0 };
315
316 for (int xi=0; xi<7; ++xi)
317 {
318 RealType x( static_cast<RealType>(xtest[xi]) );
319 RealType p( pdf(laplace_distribution<RealType>(), x) );
320 RealType c( cdf(laplace_distribution<RealType>(), x) );
321 RealType h1( p/(static_cast<RealType>(1.0) - c) );
322 RealType h2( hazard(laplace_distribution<RealType>(), x) );
323 BOOST_CHECK_CLOSE( h1, h2, tolerance);
324 }
325 }
326
327 template <class RealType>
test_location_scale_symmetry()328 void test_location_scale_symmetry()
329 {
330 RealType tolerance(boost::math::tools::epsilon<RealType>() * 500); // 5 eps as a percentage
331
332 const float xtest[7] = { -2.0, -1.0, -0.5, 0.0, 0.5, 1.0, 2.0 };
333 const float ltest[7] = { -2.0, -1.0, -0.5, 0.0, 0.5, 1.0, 2.0 };
334 const float stest[3] = { 0.5, 1.0, 2.0 };
335
336 for (int xi=0; xi<7; ++xi)
337 for (int li=0; li<7; ++li)
338 for (int si=0; si<3; ++si)
339 {
340 RealType x( static_cast<RealType>(xtest[xi]) );
341 RealType l( static_cast<RealType>(ltest[li]) );
342 RealType s( static_cast<RealType>(stest[si]) );
343 RealType x0( (x-l)/s );
344
345 BOOST_CHECK_CLOSE(
346 pdf(laplace_distribution<RealType>(l,s), x) * s,
347 pdf(laplace_distribution<RealType>(), x0),
348 tolerance);
349
350 BOOST_CHECK_CLOSE(
351 cdf(laplace_distribution<RealType>(l,s), x),
352 cdf(laplace_distribution<RealType>(), x0),
353 tolerance);
354
355 }
356 }
357
358 template <class RealType>
test_mmm_moments()359 void test_mmm_moments()
360 {
361 RealType tolerance(boost::math::tools::epsilon<RealType>() * 500); // 5 eps as a percentage
362
363 // const float xtest[7] = { -2.0, -1.0, -0.5, 0.0, 0.5, 1.0, 2.0 };
364 const float ltest[7] = { -2.0, -1.0, -0.5, 0.0, 0.5, 1.0, 2.0 };
365 const float stest[3] = { 0.5, 1.0, 2.0 };
366
367 for (int xi=0; xi<7; ++xi)
368 for (int li=0; li<7; ++li)
369 for (int si=0; si<3; ++si)
370 {
371 //RealType x( static_cast<RealType>(xtest[xi]) );
372 RealType l( static_cast<RealType>(ltest[li]) );
373 RealType s( static_cast<RealType>(stest[si]) );
374
375 BOOST_CHECK_CLOSE(
376 mean( laplace_distribution<RealType>(l,s) ),
377 l,
378 tolerance);
379
380 BOOST_CHECK_CLOSE(
381 median( laplace_distribution<RealType>(l,s) ),
382 l,
383 tolerance);
384
385 BOOST_CHECK_CLOSE(
386 mode( laplace_distribution<RealType>(l,s) ),
387 l,
388 tolerance);
389
390
391 BOOST_CHECK_CLOSE(
392 standard_deviation( laplace_distribution<RealType>(l,s) ),
393 static_cast<RealType>( s * boost::math::constants::root_two<RealType>() ),
394 tolerance);
395
396 BOOST_CHECK_CLOSE(
397 skewness( laplace_distribution<RealType>(l,s) ),
398 static_cast<RealType>(0),
399 tolerance);
400
401 BOOST_CHECK_CLOSE(
402 kurtosis( laplace_distribution<RealType>(l,s) ),
403 static_cast<RealType>(6),
404 tolerance);
405
406 BOOST_CHECK_CLOSE(
407 kurtosis_excess( laplace_distribution<RealType>(l,s) ),
408 static_cast<RealType>(3),
409 tolerance);
410
411 RealType expected_entropy = log(2*s*boost::math::constants::e<RealType>());
412 BOOST_CHECK_CLOSE(
413 entropy(laplace_distribution<RealType>(l,s) ),
414 expected_entropy,
415 tolerance);
416
417 }
418 } // template <class RealType> void test_mmm_moments()
419
420 template <class RealType>
test_complemented()421 void test_complemented()
422 {
423 RealType tolerance(boost::math::tools::epsilon<RealType>() * 500); // 5 eps as a percentage.
424
425 const float xtest[7] = { -2.0, -1.0, -0.5, 0.0, 0.5, 1.0, 2.0 }; // x values.
426 const float ptest[7] = { 0.125, 0.25, 0.5, 0.75, 0.875 }; // probability values.
427 const float ltest[7] = { -2.0, -1.0, -0.5, 0.0, 0.5, 1.0, 2.0 }; // locations.
428 const float stest[3] = { 0.5, 1.0, 2.0 }; // scales.
429
430 for (int li=0; li<7; ++li)
431 for (int si=0; si<3; ++si)
432 {
433 RealType l( static_cast<RealType>(ltest[li]) );
434 RealType s( static_cast<RealType>(stest[si]) );
435
436 for (int xi=0; xi<7; ++xi)
437 {
438 RealType x( static_cast<RealType>(xtest[xi]) );
439
440 // Check sum of cdf and complement = unity.
441 BOOST_CHECK_CLOSE(
442 cdf(complement(laplace_distribution<RealType>(l,s), x))
443 + cdf(laplace_distribution<RealType>(l,s), x),
444 static_cast<RealType>(1),
445 tolerance);
446
447 }
448
449 for (int pi=0; pi<5; ++pi)
450 {
451 RealType p( static_cast<RealType>(ptest[pi]) );
452
453 BOOST_CHECK_CLOSE(
454 quantile(complement(laplace_distribution<RealType>(l,s), 1-p )),
455 quantile(laplace_distribution<RealType>(l,s), p),
456 tolerance);
457 }
458 }
459 } // void test_complemented()
460
461 template <class RealType>
test_bad_dist_parameters()462 void test_bad_dist_parameters()
463 {
464 // Check that can generate laplace distribution using both convenience methods:
465 laplace_distribution<double> lp1(0.5); // Using default RealType double.
466 boost::math::laplace lp2(0.5); // Using typedef.
467 #ifndef BOOST_NO_EXCEPTIONS
468 BOOST_MATH_CHECK_THROW(boost::math::laplace_distribution<RealType> lbad1(0, 0), std::domain_error);
469 BOOST_MATH_CHECK_THROW(boost::math::laplace_distribution<RealType> lbad2(0, -1), std::domain_error);
470 #else
471 BOOST_MATH_CHECK_THROW(boost::math::laplace_distribution<RealType>(0, 0), std::domain_error);
472 BOOST_MATH_CHECK_THROW(boost::math::laplace_distribution<RealType>(0, -1), std::domain_error);
473 #endif
474 }
475
476 template <class RealType>
test_extreme_function_arguments()477 void test_extreme_function_arguments()
478 {
479 using boost::math::laplace_distribution;
480 using boost::math::policies::policy;
481 using boost::math::policies::overflow_error;
482 using boost::math::policies::ignore_error;
483
484 typedef policy<
485 overflow_error<ignore_error> // Ignore if argument value causes overflow.
486 > ignore_overflow_policy;
487
488 laplace_distribution<RealType> L01(0, 1);
489 // Compare random variate x = infinity with RealType max value, usually std::numeric_limits<RealType>::max().
490 using boost::math::tools::max_value; // In case std::numeric_limits<RealType>::max() is not defined.
491 BOOST_CHECK_EQUAL(pdf(L01, +max_value<RealType>()), pdf(L01, +std::numeric_limits<RealType>::infinity()) );
492 BOOST_CHECK_EQUAL(pdf(L01, -max_value<RealType>()), pdf(L01, -std::numeric_limits<RealType>::infinity()) );
493
494 if(std::numeric_limits<RealType>::has_infinity)
495 {
496 laplace_distribution<RealType, ignore_overflow_policy> L1(0, 1);
497 laplace_distribution<RealType, ignore_overflow_policy> L2(1, 2);
498 laplace_distribution<RealType> l01;
499
500 // Check pdf == 0 at x = +/- infinity.
501 BOOST_CHECK_EQUAL(pdf(L01, +std::numeric_limits<RealType>::infinity()), 0 );
502 BOOST_CHECK_EQUAL(pdf(L01, -std::numeric_limits<RealType>::infinity()), 0 );
503
504 BOOST_CHECK_EQUAL(cdf(L01, +std::numeric_limits<RealType>::infinity()), 1 );
505 BOOST_CHECK_EQUAL(cdf(L01, -std::numeric_limits<RealType>::infinity()), 0 );
506 BOOST_CHECK_EQUAL(cdf(complement(L01, +std::numeric_limits<RealType>::infinity())), 0 );
507 BOOST_CHECK_EQUAL(cdf(complement(L01, -std::numeric_limits<RealType>::infinity())), 1 );
508
509 // Trac #9672 Feb 2014 x = infinity is now allowed.
510 //BOOST_MATH_CHECK_THROW(pdf(L1, +std::numeric_limits<RealType>::infinity()), std::domain_error);
511 //BOOST_MATH_CHECK_THROW(pdf(L1, -std::numeric_limits<RealType>::infinity()), std::domain_error);
512 //BOOST_MATH_CHECK_THROW(pdf(L2, +std::numeric_limits<RealType>::infinity()), std::domain_error);
513 //BOOST_MATH_CHECK_THROW(pdf(L2, -std::numeric_limits<RealType>::infinity()), std::domain_error);
514
515 // Check cdf at x = +/- infinity.
516 //BOOST_MATH_CHECK_THROW(cdf(L1, +std::numeric_limits<RealType>::infinity()), std::domain_error);
517 //BOOST_MATH_CHECK_THROW(cdf(L1, -std::numeric_limits<RealType>::infinity()), std::domain_error);
518 //BOOST_MATH_CHECK_THROW(cdf(L2, +std::numeric_limits<RealType>::infinity()), std::domain_error);
519 //BOOST_MATH_CHECK_THROW(cdf(L2, -std::numeric_limits<RealType>::infinity()), std::domain_error);
520
521 // Check quantile at p = 0, 1 which return infinity.
522 BOOST_CHECK_EQUAL(quantile(L1, 0), -std::numeric_limits<RealType>::infinity() );
523 BOOST_CHECK_EQUAL(quantile(L1, 1), +std::numeric_limits<RealType>::infinity() );
524 BOOST_CHECK_EQUAL(quantile(L2, 0), -std::numeric_limits<RealType>::infinity() );
525 BOOST_CHECK_EQUAL(quantile(L2, 1), +std::numeric_limits<RealType>::infinity() );
526 }
527 }
528
BOOST_AUTO_TEST_CASE(vs_GNU_Octave)529 BOOST_AUTO_TEST_CASE( vs_GNU_Octave )
530 {
531 test_pdf_cdf_ocatave<float>();
532 test_pdf_cdf_ocatave<double>();
533 }
534
BOOST_AUTO_TEST_CASE(cdf_quantile_symmetry)535 BOOST_AUTO_TEST_CASE( cdf_quantile_symmetry )
536 {
537 test_cdf_quantile_symmetry<float>();
538 test_cdf_quantile_symmetry<double>();
539 }
540
BOOST_AUTO_TEST_CASE(hazard_pdf_cdf_symmetry)541 BOOST_AUTO_TEST_CASE( hazard_pdf_cdf_symmetry )
542 {
543 test_hazard_pdf_cdf_symmetry<float>();
544 test_hazard_pdf_cdf_symmetry<double>();
545 }
546
BOOST_AUTO_TEST_CASE(location_scale_symmetry)547 BOOST_AUTO_TEST_CASE( location_scale_symmetry )
548 {
549 test_location_scale_symmetry<float>();
550 test_location_scale_symmetry<double>();
551 }
552
BOOST_AUTO_TEST_CASE(mmm_moments)553 BOOST_AUTO_TEST_CASE( mmm_moments )
554 {
555 test_mmm_moments<float>();
556 test_mmm_moments<double>();
557 }
558
BOOST_AUTO_TEST_CASE(t_complemented)559 BOOST_AUTO_TEST_CASE( t_complemented )
560 {
561 test_complemented<float>();
562 test_complemented<double>();
563 }
564
BOOST_AUTO_TEST_CASE(bad_dist_parameters)565 BOOST_AUTO_TEST_CASE( bad_dist_parameters )
566 {
567 test_bad_dist_parameters<float>();
568 test_bad_dist_parameters<double>();
569 }
570
BOOST_AUTO_TEST_CASE(extreme_function_arguments)571 BOOST_AUTO_TEST_CASE( extreme_function_arguments )
572 {
573 BOOST_TEST_MESSAGE("extreme arguments");
574 test_extreme_function_arguments<float>();
575 test_extreme_function_arguments<double>();
576 }
577
578 /*
579
580 Output:
581
582 ------ Rebuild All started: Project: test_laplace, Configuration: Debug Win32 ------
583 test_laplace.cpp
584 test_laplace.vcxproj -> J:\Cpp\MathToolkit\test\Math_test\Debug\test_laplace.exe
585 Running 8 test cases...
586
587 *** No errors detected
588 ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
589
590
591 */
592
593