Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / math / test / test_inverse_gamma_distribution.cpp
1 // test_inverse_gamma.cpp
2
3 // Copyright Paul A. Bristow 2010.
4 // Copyright John Maddock 2010.
5
6 // Use, modification and distribution are subject to the
7 // Boost Software License, Version 1.0.
8 // (See accompanying file LICENSE_1_0.txt
9 // or copy at http://www.boost.org/LICENSE_1_0.txt)
10
11 #ifdef _MSC_VER
12 #  pragma warning (disable : 4224) // nonstandard extension used : formal parameter 'type' was previously defined as a type
13 // in Boost.test and lexical_cast
14 #  pragma warning (disable : 4310) // cast truncates constant value
15 #endif
16
17 #include <boost/math/tools/test.hpp>
18 #include <boost/math/concepts/real_concept.hpp> // for real_concept
19 using ::boost::math::concepts::real_concept;
20
21 //#include <boost/math/tools/test.hpp>
22 #define BOOST_TEST_MAIN
23 #include <boost/test/unit_test.hpp> // for test_main
24 #include <boost/test/tools/floating_point_comparison.hpp> // for BOOST_CHECK_CLOSE_FRACTION
25 #include "test_out_of_range.hpp"
26
27 #include <boost/math/distributions/inverse_gamma.hpp> // for inverse_gamma_distribution
28 using boost::math::inverse_gamma_distribution;
29 using  ::boost::math::inverse_gamma;
30 //  using  ::boost::math::cdf;
31 //  using  ::boost::math::pdf;
32
33 #include <boost/math/special_functions/gamma.hpp> 
34 using boost::math::tgamma; // for naive pdf.
35
36 #include <iostream>
37 using std::cout;
38 using std::endl;
39 #include <limits>
40 using std::numeric_limits;
41
42 template <class RealType>
43 RealType naive_pdf(RealType shape, RealType scale, RealType x)
44 { // Formula from Wikipedia
45    using namespace std; // For ADL of std functions.
46    using boost::math::tgamma;
47    RealType result = (pow(scale, shape) * pow(x, (-shape -1)) * exp(-scale/x) ) / tgamma(shape);
48    return result;
49 }
50
51 // Test using a spot value from some other reference source,
52 // in this case test values from output from R provided by Thomas Mang.
53
54 template <class RealType>
55 void test_spot(
56      RealType shape, // shape,
57      RealType scale, // scale,
58      RealType x, // random variate x,
59      RealType pd, // expected pdf,
60      RealType P, // expected CDF,
61      RealType Q, // expected complement of CDF,
62      RealType tol) // test tolerance.
63 {
64    boost::math::inverse_gamma_distribution<RealType> dist(shape, scale);
65
66    BOOST_CHECK_CLOSE_FRACTION
67       ( // Compare to expected PDF.
68       pdf(dist, x), // calculated.
69       pd, // expected
70       tol);
71
72     BOOST_CHECK_CLOSE_FRACTION( // Compare to naive formula (might be less accurate).
73       pdf(dist, x), naive_pdf(dist.shape(), dist.scale(), x), tol);
74
75    BOOST_CHECK_CLOSE_FRACTION( // Compare to expected CDF.
76       cdf(dist, x), P, tol);
77
78    if((P < 0.999) && (Q < 0.999))
79    {  // We can only check this if P is not too close to 1,
80       // so that we can guarantee Q is accurate:
81       BOOST_CHECK_CLOSE_FRACTION(
82         cdf(complement(dist, x)), Q, tol);
83       BOOST_CHECK_CLOSE_FRACTION(
84         quantile(dist, P), x, tol); // quantile(pdf) = x
85       BOOST_CHECK_CLOSE_FRACTION(
86         quantile(complement(dist, Q)), x, tol);
87    }
88 } // test_spot
89
90 // Test using a spot value from some other reference source.
91
92 template <class RealType> // Any floating-point type RealType.
93 void test_spots(RealType)
94 {
95   // Basic sanity checks, test data is to six decimal places only
96   // so set tolerance to 0.000001 expressed as a percentage = 0.0001%.
97
98   RealType tolerance = 0.000001f; // as fraction.
99   cout << "Tolerance = " << tolerance * 100 << "%." << endl;
100
101 // This test values from output from R provided by Thomas Mang.
102   test_spot(static_cast<RealType>(2), static_cast<RealType>(1), // shape, scale
103   static_cast<RealType>(2.L), // x
104   static_cast<RealType>(0.075816332464079136L), // pdf
105   static_cast<RealType>(0.90979598956895047L), // cdf
106   static_cast<RealType>(1 - 0.90979598956895047L), // cdf complement
107   tolerance  // tol
108   );
109
110   test_spot(static_cast<RealType>(1.593), static_cast<RealType>( 0.5), // shape, scale
111   static_cast<RealType>( 0.5), // x
112   static_cast<RealType>(0.82415241749687074L), // pdf
113   static_cast<RealType>(0.60648042700409865L), // cdf
114   static_cast<RealType>(1 - 0.60648042700409865L), // cdf complement
115   tolerance  // tol
116   );
117
118   test_spot(static_cast<RealType>(13.319), static_cast<RealType>(0.5), // shape, scale
119   static_cast<RealType>(0.5), // x
120   static_cast<RealType>(0.00000000068343206235379223), // pdf
121   static_cast<RealType>(0.99999999997242739L), // cdf
122   static_cast<RealType>(1 - 0.99999999997242739L), // cdf complement
123   tolerance  // tol
124   );
125
126   test_spot(static_cast<RealType>(1.593), static_cast<RealType>(1), // shape, scale
127   static_cast<RealType>(1.977), // x
128   static_cast<RealType>(0.11535946773398653L), // pdf
129   static_cast<RealType>(0.82449794420341549L), // cdf
130   static_cast<RealType>(1 - 0.82449794420341549L), // cdf complement
131   tolerance  // tol
132   );
133   
134   test_spot(static_cast<RealType>(6.666), static_cast<RealType>(1.411), // shape, scale
135   static_cast<RealType>(5), // x
136   static_cast<RealType>(0.000000084415758206386872), // pdf
137   static_cast<RealType>(0.99999993427280998L), // cdf
138   static_cast<RealType>(1 - 0.99999993427280998L), // cdf complement
139   tolerance  // tol
140   );
141
142   // Check some bad parameters to the distribution,
143 #ifndef BOOST_NO_EXCEPTIONS
144   BOOST_MATH_CHECK_THROW(boost::math::inverse_gamma_distribution<RealType> igbad1(-1, 0), std::domain_error); // negative shape.
145   BOOST_MATH_CHECK_THROW(boost::math::inverse_gamma_distribution<RealType> igbad2(0, -1), std::domain_error); // negative scale.
146   BOOST_MATH_CHECK_THROW(boost::math::inverse_gamma_distribution<RealType> igbad2(-1, -1), std::domain_error); // negative scale and shape.
147 #else
148   BOOST_MATH_CHECK_THROW(boost::math::inverse_gamma_distribution<RealType>(-1, 0), std::domain_error); // negative shape.
149   BOOST_MATH_CHECK_THROW(boost::math::inverse_gamma_distribution<RealType>(0, -1), std::domain_error); // negative scale.
150   BOOST_MATH_CHECK_THROW(boost::math::inverse_gamma_distribution<RealType>(-1, -1), std::domain_error); // negative scale and shape.
151 #endif
152
153   inverse_gamma_distribution<RealType> ig21(2, 1);
154
155   if(std::numeric_limits<RealType>::has_infinity)
156   {
157     BOOST_MATH_CHECK_THROW(pdf(ig21, +std::numeric_limits<RealType>::infinity()), std::domain_error); // x = + infinity, pdf = 0
158     BOOST_MATH_CHECK_THROW(pdf(ig21, -std::numeric_limits<RealType>::infinity()),  std::domain_error); // x = - infinity, pdf = 0
159     BOOST_MATH_CHECK_THROW(cdf(ig21, +std::numeric_limits<RealType>::infinity()),std::domain_error ); // x = + infinity, cdf = 1
160     BOOST_MATH_CHECK_THROW(cdf(ig21, -std::numeric_limits<RealType>::infinity()), std::domain_error); // x = - infinity, cdf = 0
161     BOOST_MATH_CHECK_THROW(cdf(complement(ig21, +std::numeric_limits<RealType>::infinity())), std::domain_error); // x = + infinity, c cdf = 0
162     BOOST_MATH_CHECK_THROW(cdf(complement(ig21, -std::numeric_limits<RealType>::infinity())), std::domain_error); // x = - infinity, c cdf = 1
163 #ifndef BOOST_NO_EXCEPTIONS
164     BOOST_MATH_CHECK_THROW(boost::math::inverse_gamma_distribution<RealType> nbad1(std::numeric_limits<RealType>::infinity(), static_cast<RealType>(1)), std::domain_error); // +infinite mean
165     BOOST_MATH_CHECK_THROW(boost::math::inverse_gamma_distribution<RealType> nbad1(-std::numeric_limits<RealType>::infinity(),  static_cast<RealType>(1)), std::domain_error); // -infinite mean
166     BOOST_MATH_CHECK_THROW(boost::math::inverse_gamma_distribution<RealType> nbad1(static_cast<RealType>(0), std::numeric_limits<RealType>::infinity()), std::domain_error); // infinite sd
167 #else
168     BOOST_MATH_CHECK_THROW(boost::math::inverse_gamma_distribution<RealType>(std::numeric_limits<RealType>::infinity(), static_cast<RealType>(1)), std::domain_error); // +infinite mean
169     BOOST_MATH_CHECK_THROW(boost::math::inverse_gamma_distribution<RealType>(-std::numeric_limits<RealType>::infinity(),  static_cast<RealType>(1)), std::domain_error); // -infinite mean
170     BOOST_MATH_CHECK_THROW(boost::math::inverse_gamma_distribution<RealType>(static_cast<RealType>(0), std::numeric_limits<RealType>::infinity()), std::domain_error); // infinite sd
171 #endif
172   }
173
174   if (std::numeric_limits<RealType>::has_quiet_NaN)
175   {
176     // No longer allow x to be NaN, then these tests should throw.
177     BOOST_MATH_CHECK_THROW(pdf(ig21, +std::numeric_limits<RealType>::quiet_NaN()), std::domain_error); // x = NaN
178     BOOST_MATH_CHECK_THROW(cdf(ig21, +std::numeric_limits<RealType>::quiet_NaN()), std::domain_error); // x = NaN
179     BOOST_MATH_CHECK_THROW(cdf(complement(ig21, +std::numeric_limits<RealType>::quiet_NaN())), std::domain_error); // x = + infinity
180     BOOST_MATH_CHECK_THROW(quantile(ig21, +std::numeric_limits<RealType>::quiet_NaN()), std::domain_error); // p = + infinity
181     BOOST_MATH_CHECK_THROW(quantile(complement(ig21, +std::numeric_limits<RealType>::quiet_NaN())), std::domain_error); // p = + infinity
182   }
183     // Spot check for pdf using 'naive pdf' function
184   for(RealType x = 0.5; x < 5; x += 0.5)
185   {
186     BOOST_CHECK_CLOSE_FRACTION(
187       pdf(inverse_gamma_distribution<RealType>(5, 6), x),
188       naive_pdf(RealType(5), RealType(6), x),
189       tolerance);
190   }   // Spot checks for parameters:
191
192   RealType tol_few_eps = boost::math::tools::epsilon<RealType>() * 5; // 5 eps as a fraction.
193   inverse_gamma_distribution<RealType> dist51(5, 1);
194   inverse_gamma_distribution<RealType> dist52(5, 2);
195   inverse_gamma_distribution<RealType> dist31(3, 1);
196   inverse_gamma_distribution<RealType> dist111(11, 1);
197   // 11 mean 0.10000000000000001, variance  0.0011111111111111111, sd 0.033333333333333333
198
199   RealType x = static_cast<RealType>(0.125);
200   using namespace std; // ADL of std names.
201   using namespace boost::math;
202
203   //  mean, variance etc
204   BOOST_CHECK_CLOSE_FRACTION(mean(dist52), static_cast<RealType>(0.5), tol_few_eps);
205   BOOST_CHECK_CLOSE_FRACTION(mean(dist111), static_cast<RealType>(0.1L), tol_few_eps);
206   inverse_gamma_distribution<RealType> igamma41(static_cast<RealType>(4.), static_cast<RealType>(1.) );
207   BOOST_CHECK_CLOSE_FRACTION(mean(igamma41), static_cast<RealType>(0.3333333333333333333333333333333333333333333333333333333L), tol_few_eps);
208   // variance:
209   BOOST_CHECK_CLOSE_FRACTION(variance(dist51), static_cast<RealType>(0.0208333333333333333333333333333333333333333333333333L), tol_few_eps);
210   BOOST_CHECK_CLOSE_FRACTION(variance(dist31), static_cast<RealType>(0.25), tol_few_eps);
211   BOOST_CHECK_CLOSE_FRACTION(variance(dist111), static_cast<RealType>(0.001111111111111111111111111111111111111111111111111L), tol_few_eps);
212   // std deviation:
213   BOOST_CHECK_CLOSE_FRACTION(standard_deviation(dist31), static_cast<RealType>(0.5), tol_few_eps);
214   BOOST_CHECK_CLOSE_FRACTION(standard_deviation(dist111), static_cast<RealType>(0.0333333333333333333333333333333333333333333333333L), tol_few_eps);
215   // hazard:
216   BOOST_CHECK_CLOSE_FRACTION(hazard(dist51, x), pdf(dist51, x) / cdf(complement(dist51, x)), tol_few_eps);
217  //  cumulative hazard:
218   BOOST_CHECK_CLOSE_FRACTION(chf(dist51, x), -log(cdf(complement(dist51, x))), tol_few_eps);
219   // coefficient_of_variation:
220   BOOST_CHECK_CLOSE_FRACTION(coefficient_of_variation(dist51), standard_deviation(dist51) / mean(dist51), tol_few_eps);
221   // mode:
222   BOOST_CHECK_CLOSE_FRACTION(mode(dist51), static_cast<RealType>(0.166666666666666666666666666666666666666666666666666L), tol_few_eps);
223   // median
224   //BOOST_CHECK_CLOSE_FRACTION(median(dist52), static_cast<RealType>(0), tol_few_eps);
225   // Useful to have an exact median?  Failing that use a loop back test.
226    BOOST_CHECK_CLOSE_FRACTION(cdf(dist111, median(dist111)), 0.5, tol_few_eps);
227   // skewness:
228   BOOST_CHECK_CLOSE_FRACTION(skewness(dist111), static_cast<RealType>(1.5), tol_few_eps);
229    //kurtosis:
230   BOOST_CHECK_CLOSE_FRACTION(kurtosis(dist51), static_cast<RealType>(42 + 3), tol_few_eps);
231   // kurtosis excess:
232   BOOST_CHECK_CLOSE_FRACTION(kurtosis_excess(dist51), static_cast<RealType>(42), tol_few_eps);
233
234   tol_few_eps = boost::math::tools::epsilon<RealType>() * 3; // 3 eps as a percentage.
235
236   // Special and limit cases:
237
238   if(std::numeric_limits<RealType>::is_specialized)
239   {
240     RealType mx = (std::numeric_limits<RealType>::max)();
241     RealType mi = (std::numeric_limits<RealType>::min)();
242
243      BOOST_CHECK_EQUAL(
244      pdf(inverse_gamma_distribution<RealType>(1),
245        static_cast<RealType>(mx)), // max()
246        static_cast<RealType>(0)
247        );
248
249      BOOST_CHECK_EQUAL(
250      pdf(inverse_gamma_distribution<RealType>(1),
251        static_cast<RealType>(mi)), // min()
252        static_cast<RealType>(0)
253        );
254
255   }
256
257   BOOST_CHECK_EQUAL(
258     pdf(inverse_gamma_distribution<RealType>(1), static_cast<RealType>(0)), static_cast<RealType>(0));
259   BOOST_CHECK_EQUAL(
260     pdf(inverse_gamma_distribution<RealType>(3), static_cast<RealType>(0))
261     , static_cast<RealType>(0.0f));
262   BOOST_CHECK_EQUAL(
263     cdf(inverse_gamma_distribution<RealType>(1), static_cast<RealType>(0))
264     , static_cast<RealType>(0.0f));
265   BOOST_CHECK_EQUAL(
266     cdf(inverse_gamma_distribution<RealType>(2), static_cast<RealType>(0))
267     , static_cast<RealType>(0.0f));
268   BOOST_CHECK_EQUAL(
269     cdf(inverse_gamma_distribution<RealType>(3), static_cast<RealType>(0))
270     , static_cast<RealType>(0.0f));
271   BOOST_CHECK_EQUAL(
272     cdf(complement(inverse_gamma_distribution<RealType>(1), static_cast<RealType>(0)))
273     , static_cast<RealType>(1));
274   BOOST_CHECK_EQUAL(
275     cdf(complement(inverse_gamma_distribution<RealType>(2), static_cast<RealType>(0)))
276     , static_cast<RealType>(1));
277   BOOST_CHECK_EQUAL(
278     cdf(complement(inverse_gamma_distribution<RealType>(3), static_cast<RealType>(0)))
279     , static_cast<RealType>(1));
280
281   BOOST_MATH_CHECK_THROW(
282     pdf(
283     inverse_gamma_distribution<RealType>(static_cast<RealType>(-1)), // shape negative.
284     static_cast<RealType>(1)), std::domain_error
285     );
286   BOOST_MATH_CHECK_THROW(
287     pdf(
288     inverse_gamma_distribution<RealType>(static_cast<RealType>(8)),
289     static_cast<RealType>(-1)), std::domain_error
290     );
291   BOOST_MATH_CHECK_THROW(
292     cdf(
293     inverse_gamma_distribution<RealType>(static_cast<RealType>(-1)),
294     static_cast<RealType>(1)), std::domain_error
295     );
296   BOOST_MATH_CHECK_THROW(
297     cdf(
298     inverse_gamma_distribution<RealType>(static_cast<RealType>(8)),
299     static_cast<RealType>(-1)), std::domain_error
300     );
301   BOOST_MATH_CHECK_THROW(
302     cdf(complement(
303     inverse_gamma_distribution<RealType>(static_cast<RealType>(-1)),
304     static_cast<RealType>(1))), std::domain_error
305     );
306   BOOST_MATH_CHECK_THROW(
307     cdf(complement(
308     inverse_gamma_distribution<RealType>(static_cast<RealType>(8)),
309     static_cast<RealType>(-1))), std::domain_error
310     );
311   BOOST_MATH_CHECK_THROW(
312     quantile(
313     inverse_gamma_distribution<RealType>(static_cast<RealType>(-1)),
314     static_cast<RealType>(0.5)), std::domain_error
315     );
316   BOOST_MATH_CHECK_THROW(
317     quantile(
318     inverse_gamma_distribution<RealType>(static_cast<RealType>(8)),
319     static_cast<RealType>(-1)), std::domain_error
320     );
321   BOOST_MATH_CHECK_THROW(
322     quantile(
323     inverse_gamma_distribution<RealType>(static_cast<RealType>(8)),
324     static_cast<RealType>(1.1)), std::domain_error
325     );
326   BOOST_MATH_CHECK_THROW(
327     quantile(complement(
328     inverse_gamma_distribution<RealType>(static_cast<RealType>(-1)),
329     static_cast<RealType>(0.5))), std::domain_error
330     );
331   BOOST_MATH_CHECK_THROW(
332     quantile(complement(
333     inverse_gamma_distribution<RealType>(static_cast<RealType>(8)),
334     static_cast<RealType>(-1))), std::domain_error
335     );
336   BOOST_MATH_CHECK_THROW(
337     quantile(complement(
338     inverse_gamma_distribution<RealType>(static_cast<RealType>(8)),
339     static_cast<RealType>(1.1))), std::domain_error
340     );
341    check_out_of_range<inverse_gamma_distribution<RealType> >(1, 1);
342 } // template <class RealType>void test_spots(RealType)
343
344 BOOST_AUTO_TEST_CASE( test_main )
345 {
346   BOOST_MATH_CONTROL_FP;
347
348   // Check that can generate inverse_gamma distribution using the two convenience methods:
349   // inverse_gamma_distribution; // with default parameters, shape = 1, scale - 1
350   using boost::math::inverse_gamma;
351   inverse_gamma ig2(2.); // Using typedef and shape parameter (and default scale = 1).
352   BOOST_CHECK_EQUAL(ig2.shape(), 2.); // scale  == 2.
353   BOOST_CHECK_EQUAL(ig2.scale(), 1.); // scale  == 1 (default).
354   inverse_gamma ig; // Using typedef, type double and default values, shape = 1 and scale = 1
355   // check default is (1, 1)
356   BOOST_CHECK_EQUAL(ig.shape(), 1.); // shape == 1
357   BOOST_CHECK_EQUAL(ig.scale(), 1.); // scale  == 1
358   BOOST_CHECK_EQUAL(mode(ig), 0.5); // mode = 1/2
359
360   // Used to find some 'exact' values for testing mean, variance ...
361  //for (int shape = 4; shape < 30; shape++)
362  // {
363  //   inverse_gamma ig(shape, 1);
364  //   cout.precision(17);
365  //   cout << shape << ' ' << mean(ig) << ' ' << variance(ig) << ' ' << standard_deviation(ig)
366  //     << ' ' << median(ig) << endl;
367  // }
368
369   // and "using boost::math::inverse_gamma_distribution;".
370   inverse_gamma_distribution<> ig23(2., 3.); // Using default RealType double.
371   BOOST_CHECK_EQUAL(ig23.shape(), 2.); //
372   BOOST_CHECK_EQUAL(ig23.scale(), 3.); //
373
374   inverse_gamma_distribution<float> igf23(1.f, 2.f); // Using explicit RealType float.
375   BOOST_CHECK_EQUAL(igf23.shape(), 1.f); //
376   BOOST_CHECK_EQUAL(igf23.scale(), 2.f); //
377   // Some tests using default double.
378   double tol5eps = boost::math::tools::epsilon<double>() * 5; // 5 eps as a fraction.
379   inverse_gamma_distribution<double> ig102(10., 2.); //
380   BOOST_CHECK_EQUAL(ig102.shape(), 10.); //
381   BOOST_CHECK_EQUAL(ig102.scale(), 2.); //
382   // formatC(SuppDists::dinvGauss(10, 1, 0.5), digits=17)[1] "0.0011774669940754754"
383   BOOST_CHECK_CLOSE_FRACTION(pdf(ig102, 0.5), 0.1058495335284024, tol5eps);
384   // formatC(SuppDists::pinvGauss(10, 1, 0.5), digits=17) [1] "0.99681494462166653"
385   BOOST_CHECK_CLOSE_FRACTION(cdf(ig102, 0.5), 0.99186775720306608, tol5eps);
386   BOOST_CHECK_CLOSE_FRACTION(quantile(ig102, 0.05), 0.12734622346137681, tol5eps);
387   BOOST_CHECK_CLOSE_FRACTION(quantile(ig102, 0.5), 0.20685272858879727, tol5eps);
388   BOOST_CHECK_CLOSE_FRACTION(quantile(ig102, 0.95),  0.36863602680851204, tol5eps);
389   // Check mean, etc spot values.
390   inverse_gamma_distribution<double> ig51(5., 1.); // shape = 5, scale = 1
391   BOOST_CHECK_CLOSE_FRACTION(mean(ig51), 0.25, tol5eps);
392   BOOST_CHECK_CLOSE_FRACTION(variance(ig51), 0.0208333333333333333333333333333333333333333, tol5eps);
393   BOOST_CHECK_CLOSE_FRACTION(skewness(ig51), 2 * std::sqrt(3.), tol5eps);
394   BOOST_CHECK_CLOSE_FRACTION(kurtosis_excess(ig51), 42, tol5eps);
395   // mode and median
396   inverse_gamma_distribution<double> ig21(1., 2.);
397   BOOST_CHECK_CLOSE_FRACTION(mode(ig21), 1, tol5eps);
398   BOOST_CHECK_CLOSE_FRACTION(median(ig21), 2.8853900817779268, tol5eps);
399
400   BOOST_CHECK_CLOSE_FRACTION(quantile(ig21, 0.5), 2.8853900817779268, tol5eps);
401   BOOST_CHECK_CLOSE_FRACTION(cdf(ig21, median(ig21)), 0.5, tol5eps);
402
403     // Check throws from bad parameters.
404   inverse_gamma ig051(0.5, 1.); // shape < 1, so wrong for mean.
405   BOOST_MATH_CHECK_THROW(mean(ig051), std::domain_error);
406   inverse_gamma ig191(1.9999, 1.); // shape < 2, so wrong for variance.
407   BOOST_MATH_CHECK_THROW(variance(ig191), std::domain_error);
408   inverse_gamma ig291(2.9999, 1.); // shape < 3, so wrong for skewness.
409   BOOST_MATH_CHECK_THROW(skewness(ig291), std::domain_error);
410   inverse_gamma ig391(3.9999, 1.); // shape < 1, so wrong for kurtosis and kurtosis_excess.
411   BOOST_MATH_CHECK_THROW(kurtosis(ig391), std::domain_error);
412   BOOST_MATH_CHECK_THROW(kurtosis_excess(ig391), std::domain_error);
413
414   // Basic sanity-check spot values.
415   // (Parameter value, arbitrarily zero, only communicates the floating point type).
416   test_spots(0.0F); // Test float. OK at decdigits = 0 tolerance = 0.0001 %
417   test_spots(0.0); // Test double. OK at decdigits 7, tolerance = 1e07 %
418 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
419   test_spots(0.0L); // Test long double.
420 #ifndef BOOST_MATH_NO_REAL_CONCEPT_TESTS
421   test_spots(boost::math::concepts::real_concept(0.)); // Test real concept.
422 #endif
423 #else
424   std::cout << "<note>The long double tests have been disabled on this platform "
425     "either because the long double overloads of the usual math functions are "
426     "not available at all, or because they are too inaccurate for these tests "
427     "to pass.</note>" << std::endl;
428 #endif
429   
430 } // BOOST_AUTO_TEST_CASE( test_main )
431
432 /*
433
434 Output:
435
436 ------ Build started: Project: test_inverse_gamma_distribution, Configuration: Release Win32 ------
437   test_inverse_gamma_distribution.cpp
438   Generating code
439   Finished generating code
440   test_inverse_gamma_distribution.vcxproj -> J:\Cpp\MathToolkit\test\Math_test\Release\test_inverse_gamma_distribution.exe
441   Running 1 test case...
442   Tolerance = 0.0001%.
443   Tolerance = 0.0001%.
444   Tolerance = 0.0001%.
445   Tolerance = 0.0001%.
446
447   *** No errors detected
448 ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
449
450
451 */
452
453
454